author | rubidium |
Wed, 17 Dec 2008 23:08:11 +0000 | |
changeset 10434 | 3659467c844c |
parent 10421 | 7791220faa40 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
9098
diff
changeset
|
3 |
/** @file newgrf.cpp Base of all NewGRF support. */ |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
6 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
7 |
#include <stdarg.h> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
8 |
|
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1883
diff
changeset
|
9 |
#include "openttd.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1183
diff
changeset
|
10 |
#include "debug.h" |
10039
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10038
diff
changeset
|
11 |
#include "fileio_func.h" |
8786
1823ff88a054
(svn r12490) -Codechange: rename engine.h to engine_func.h and remove unneeded inclusions of engine.h and/or replace them with engine_type.h.
rubidium
parents:
8785
diff
changeset
|
12 |
#include "engine_func.h" |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
13 |
#include "engine_base.h" |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
14 |
#include "spritecache.h" |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
15 |
#include "sprite.h" |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
16 |
#include "newgrf.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2013
diff
changeset
|
17 |
#include "variables.h" |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
18 |
#include "bridge.h" |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
19 |
#include "town.h" |
2962
f0a49b646c48
(svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
peter1138
parents:
2958
diff
changeset
|
20 |
#include "newgrf_engine.h" |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
21 |
#include "newgrf_text.h" |
5108
aeaef6fe53b7
(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
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
23 |
#include "currency.h" |
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
24 |
#include "landscape.h" |
5228
26dc9acf7d94
(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" |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
26 |
#include "newgrf_house.h" |
4656
9c1d8c4d3e60
(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
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
28 |
#include "newgrf_spritegroup.h" |
8787
41d9d5adbe87
(svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium
parents:
8786
diff
changeset
|
29 |
#include "newgrf_station.h" |
6091
c8827d9ae04a
(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:
6090
diff
changeset
|
30 |
#include "cargotype.h" |
6533
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6529
diff
changeset
|
31 |
#include "industry.h" |
6583
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
32 |
#include "newgrf_canal.h" |
6629
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
6623
diff
changeset
|
33 |
#include "newgrf_commons.h" |
6956
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
34 |
#include "newgrf_townname.h" |
7233
aadfbb505671
(svn r10514) -Codechange: add support for getting the nearest industry with a given type.
rubidium
parents:
7229
diff
changeset
|
35 |
#include "newgrf_industries.h" |
7772
c89384e3f8de
(svn r11321) -Codechange: add support to load different graphics for halftile slopes using a NewGRF. Patch by frosch.
rubidium
parents:
7757
diff
changeset
|
36 |
#include "gfxinit.h" |
9085
8b3897a75aed
(svn r12944) -Codechange: use rev.h instead of externs at many places
smatz
parents:
9073
diff
changeset
|
37 |
#include "rev.h" |
7805
7ab20f94cc80
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents:
7796
diff
changeset
|
38 |
#include "fios.h" |
8103
cf92483a0abf
(svn r11664) -Codechange: use more specific ("rail_type.h" instead of "rail.h" that includes way more than only "rail_type.h") includes at some places.
rubidium
parents:
8089
diff
changeset
|
39 |
#include "rail.h" |
8114
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8104
diff
changeset
|
40 |
#include "strings_func.h" |
8123
ce31d2843a95
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents:
8121
diff
changeset
|
41 |
#include "gfx_func.h" |
8140
0d0d8c94f84b
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8131
diff
changeset
|
42 |
#include "date_func.h" |
8144
65cec0877b78
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8140
diff
changeset
|
43 |
#include "vehicle_func.h" |
8157
1505def01945
(svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents:
8150
diff
changeset
|
44 |
#include "sound_func.h" |
8214
971f861d5543
(svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents:
8198
diff
changeset
|
45 |
#include "string_func.h" |
8236
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8235
diff
changeset
|
46 |
#include "road_func.h" |
10208
72c00af5c95d
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents:
10066
diff
changeset
|
47 |
#include "company_base.h" |
8270
e7c342f6b14c
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8264
diff
changeset
|
48 |
#include "settings_type.h" |
9556
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
49 |
#include "network/network.h" |
8391
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
50 |
#include "map_func.h" |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
51 |
#include <map> |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
52 |
|
8264
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8258
diff
changeset
|
53 |
#include "table/strings.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8258
diff
changeset
|
54 |
#include "table/sprites.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8258
diff
changeset
|
55 |
#include "table/town_land.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8258
diff
changeset
|
56 |
#include "table/build_industry.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8258
diff
changeset
|
57 |
#include "table/landscape_sprite.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8258
diff
changeset
|
58 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
59 |
/* TTDPatch extended GRF format codec |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
60 |
* (c) Petr Baudis 2004 (GPL'd) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
61 |
* Changes by Florian octo Forster are (c) by the OpenTTD development team. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
62 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
63 |
* Contains portions of documentation by TTDPatch team. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
64 |
* Thanks especially to Josef Drexler for the documentation as well as a lot |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
65 |
* of help at #tycoon. Also thanks to Michael Blunck for is GRF files which |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
66 |
* served as subject to the initial testing of this codec. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
67 |
|
455 | 68 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
69 |
static int _skip_sprites; // XXX |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
70 |
static uint _file_index; // XXX |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
71 |
|
2340
e18ef06bc59a
(svn r2866) Move all functions and tables which aren't directly involved in managing the sprite heap to a new file gfxinit.c.
tron
parents:
2336
diff
changeset
|
72 |
static GRFFile *_cur_grffile; |
1477 | 73 |
GRFFile *_first_grffile; |
3707
7dc7e4d2487e
(svn r4650) - NewGRF: use the correct type for _cur_spriteid
peter1138
parents:
3704
diff
changeset
|
74 |
static SpriteID _cur_spriteid; |
5225
af5d9de16c8d
(svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents:
5211
diff
changeset
|
75 |
static GrfLoadingStage _cur_stage; |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
76 |
static uint32 _nfo_line; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
77 |
|
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
78 |
static GRFConfig *_cur_grfconfig; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
79 |
|
3814
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
80 |
/* Miscellaneous GRF features, set by Action 0x0D, parameter 0x9E */ |
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
81 |
static byte _misc_grf_features = 0; |
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
82 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
83 |
/* 32 * 8 = 256 flags. Apparently TTDPatch uses this many.. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
84 |
static uint32 _ttdpatch_flags[8]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
85 |
|
6769
13ccbd0f86b3
(svn r10005) -Codechange: Merge two flags (2cc and newhouses) indicating some newgrf features have been loaded, and introduce the newindustry one.
belugas
parents:
6765
diff
changeset
|
86 |
/* Indicates which are the newgrf features currently loaded ingame */ |
6914
6219e65dd7bf
(svn r10167) -Codechange: Change the flagging system of grf loaded feature from a bitset to a bool evaluation.
belugas
parents:
6908
diff
changeset
|
87 |
GRFLoadedFeatures _loaded_newgrf_features; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
88 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
89 |
enum GrfDataType { |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
90 |
GDT_SOUND, |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
91 |
}; |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
92 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
93 |
static byte _grf_data_blocks; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
94 |
static GrfDataType _grf_data_type; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
95 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
96 |
|
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
97 |
typedef void (*SpecialSpriteHandler)(byte *buf, size_t len); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
98 |
|
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
99 |
enum { |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
100 |
MAX_STATIONS = 256, |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
101 |
}; |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
102 |
|
9025
be4668a781b8
(svn r12839) -Codechange: Allocate temporary engine data when loading GRFs as needed instead of statically.
peter1138
parents:
9003
diff
changeset
|
103 |
/* Temporary data used when loading only */ |
be4668a781b8
(svn r12839) -Codechange: Allocate temporary engine data when loading GRFs as needed instead of statically.
peter1138
parents:
9003
diff
changeset
|
104 |
struct GRFTempEngineData { |
be4668a781b8
(svn r12839) -Codechange: Allocate temporary engine data when loading GRFs as needed instead of statically.
peter1138
parents:
9003
diff
changeset
|
105 |
uint16 cargo_allowed; |
be4668a781b8
(svn r12839) -Codechange: Allocate temporary engine data when loading GRFs as needed instead of statically.
peter1138
parents:
9003
diff
changeset
|
106 |
uint16 cargo_disallowed; |
be4668a781b8
(svn r12839) -Codechange: Allocate temporary engine data when loading GRFs as needed instead of statically.
peter1138
parents:
9003
diff
changeset
|
107 |
}; |
be4668a781b8
(svn r12839) -Codechange: Allocate temporary engine data when loading GRFs as needed instead of statically.
peter1138
parents:
9003
diff
changeset
|
108 |
|
be4668a781b8
(svn r12839) -Codechange: Allocate temporary engine data when loading GRFs as needed instead of statically.
peter1138
parents:
9003
diff
changeset
|
109 |
static GRFTempEngineData *_gted; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
110 |
|
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
111 |
/* Contains the GRF ID of the owner of a vehicle if it has been reserved. |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
112 |
* GRM for vehicles is only used if dynamic engine allocation is disabled, |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
113 |
* so 256 is the number of original engines. */ |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
114 |
static uint32 _grm_engines[256]; |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
115 |
|
6781
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
116 |
/* Contains the GRF ID of the owner of a cargo if it has been reserved */ |
8675
9ad701979822
(svn r12341) -Fix (r11224) [FS#1827]: GRM buffer for cargos was incorrect size.
peter1138
parents:
8668
diff
changeset
|
117 |
static uint32 _grm_cargos[NUM_CARGO * 2]; |
6781
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
118 |
|
9113
c2856e41abf3
(svn r12973) -Codechange: Rename GRMSpriteEntry to GRFLocation, as it is not necessarily specific to GRM sprites...
peter1138
parents:
9111
diff
changeset
|
119 |
struct GRFLocation { |
9098
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
120 |
uint32 grfid; |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
121 |
uint32 nfoline; |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
122 |
|
9113
c2856e41abf3
(svn r12973) -Codechange: Rename GRMSpriteEntry to GRFLocation, as it is not necessarily specific to GRM sprites...
peter1138
parents:
9111
diff
changeset
|
123 |
GRFLocation(uint32 grfid, uint32 nfoline) : grfid(grfid), nfoline(nfoline) { } |
c2856e41abf3
(svn r12973) -Codechange: Rename GRMSpriteEntry to GRFLocation, as it is not necessarily specific to GRM sprites...
peter1138
parents:
9111
diff
changeset
|
124 |
|
c2856e41abf3
(svn r12973) -Codechange: Rename GRMSpriteEntry to GRFLocation, as it is not necessarily specific to GRM sprites...
peter1138
parents:
9111
diff
changeset
|
125 |
bool operator<(const GRFLocation &other) const |
9098
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
126 |
{ |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
127 |
return this->grfid < other.grfid || (this->grfid == other.grfid && this->nfoline < other.nfoline); |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
128 |
} |
9947
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
129 |
|
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
130 |
bool operator==(const GRFLocation &other) const |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
131 |
{ |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
132 |
return this->grfid == other.grfid && this->nfoline == other.nfoline; |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
133 |
} |
9098
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
134 |
}; |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
135 |
|
9113
c2856e41abf3
(svn r12973) -Codechange: Rename GRMSpriteEntry to GRFLocation, as it is not necessarily specific to GRM sprites...
peter1138
parents:
9111
diff
changeset
|
136 |
static std::map<GRFLocation, SpriteID> _grm_sprites; |
9947
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
137 |
typedef std::map<GRFLocation, byte*> GRFLineToSpriteOverride; |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
138 |
GRFLineToSpriteOverride _grf_line_to_action6_sprite_override; |
9098
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
139 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
140 |
/** DEBUG() function dedicated to newGRF debugging messages |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
141 |
* Function is essentialy the same as DEBUG(grf, severity, ...) with the |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
142 |
* addition of file:line information when parsing grf files. |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
143 |
* NOTE: for the above reason(s) grfmsg() should ONLY be used for |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
144 |
* loading/parsing grf files, not for runtime debug messages as there |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
145 |
* is no file information available during that time. |
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
146 |
* @param severity debugging severity level, see debug.h |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6479
diff
changeset
|
147 |
* @param str message in printf() format */ |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
148 |
void CDECL grfmsg(int severity, const char *str, ...) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
149 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
150 |
char buf[1024]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
151 |
va_list va; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
152 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
153 |
va_start(va, str); |
1477 | 154 |
vsnprintf(buf, sizeof(buf), str, va); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
155 |
va_end(va); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
156 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
157 |
DEBUG(grf, severity, "[%s:%d] %s", _cur_grfconfig->filename, _nfo_line, buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
158 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
159 |
|
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
160 |
static inline bool check_length(size_t real, size_t wanted, const char *str) |
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
161 |
{ |
5590
6a0c2739e124
(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:
5587
diff
changeset
|
162 |
if (real >= wanted) return true; |
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
163 |
grfmsg(0, "%s: Invalid pseudo sprite length %d (expected %d)!", str, real, wanted); |
5590
6a0c2739e124
(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:
5587
diff
changeset
|
164 |
return false; |
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
165 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
166 |
|
500
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
490
diff
changeset
|
167 |
static inline byte grf_load_byte(byte **buf) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
168 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
169 |
return *(*buf)++; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
170 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
171 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
172 |
static uint16 grf_load_word(byte **buf) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
173 |
{ |
3711
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
174 |
uint16 val = grf_load_byte(buf); |
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
175 |
return val | (grf_load_byte(buf) << 8); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
176 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
177 |
|
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
178 |
static uint16 grf_load_extended(byte** buf) |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
179 |
{ |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
180 |
uint16 val; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
181 |
val = grf_load_byte(buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
182 |
if (val == 0xFF) val = grf_load_word(buf); |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
183 |
return val; |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
184 |
} |
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
185 |
|
2324 | 186 |
static uint32 grf_load_dword(byte **buf) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
187 |
{ |
3711
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
188 |
uint32 val = grf_load_word(buf); |
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
189 |
return val | (grf_load_word(buf) << 16); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
190 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
191 |
|
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
192 |
static uint32 grf_load_var(byte size, byte **buf) |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
193 |
{ |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
194 |
switch (size) { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
195 |
case 1: return grf_load_byte(buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
196 |
case 2: return grf_load_word(buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
197 |
case 4: return grf_load_dword(buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
198 |
default: |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
199 |
NOT_REACHED(); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
200 |
return 0; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
201 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
202 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
203 |
|
6090
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
204 |
static const char *grf_load_string(byte **buf, size_t max_len) |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
205 |
{ |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
206 |
const char *string = *(const char **)buf; |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
207 |
size_t string_length = ttd_strnlen(string, max_len); |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
208 |
|
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
209 |
if (string_length == max_len) { |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
210 |
/* String was not NUL terminated, so make sure it is now. */ |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
211 |
(*buf)[string_length - 1] = '\0'; |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
212 |
grfmsg(7, "String was not terminated with a zero byte."); |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
213 |
} else { |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
214 |
/* Increase the string length to include the NUL byte. */ |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
215 |
string_length++; |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
216 |
} |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
217 |
*buf += string_length; |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
218 |
|
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
219 |
return string; |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
220 |
} |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
221 |
|
1477 | 222 |
static GRFFile *GetFileByGRFID(uint32 grfid) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
223 |
{ |
1477 | 224 |
GRFFile *file; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
225 |
|
1477 | 226 |
for (file = _first_grffile; file != NULL; file = file->next) { |
227 |
if (file->grfid == grfid) break; |
|
228 |
} |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
229 |
return file; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
230 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
231 |
|
1477 | 232 |
static GRFFile *GetFileByFilename(const char *filename) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
233 |
{ |
1477 | 234 |
GRFFile *file; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
235 |
|
1477 | 236 |
for (file = _first_grffile; file != NULL; file = file->next) { |
237 |
if (strcmp(file->filename, filename) == 0) break; |
|
238 |
} |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
239 |
return file; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
240 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
241 |
|
9619
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
242 |
/** Reset all NewGRFData that was used only while processing data */ |
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
243 |
static void ClearTemporaryNewGRFData() |
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
244 |
{ |
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
245 |
/* Clear the GOTO labels used for GRF processing */ |
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
246 |
for (GRFLabel *l = _cur_grffile->label; l != NULL;) { |
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
247 |
GRFLabel *l2 = l->next; |
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
248 |
free(l); |
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
249 |
l = l2; |
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
250 |
} |
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
251 |
_cur_grffile->label = NULL; |
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
252 |
|
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
253 |
/* Clear the list of spritegroups */ |
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
254 |
free(_cur_grffile->spritegroups); |
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
255 |
_cur_grffile->spritegroups = NULL; |
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
256 |
_cur_grffile->spritegroups_count = 0; |
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
257 |
} |
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
258 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
259 |
|
8959
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
260 |
typedef std::map<StringID *, uint32> StringIDToGRFIDMapping; |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
261 |
StringIDToGRFIDMapping _string_to_grf_mapping; |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
262 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
263 |
/** Used when setting an object's property to map to the GRF's strings |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
264 |
* while taking in consideration the "drift" between TTDPatch string system and OpenTTD's one |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6479
diff
changeset
|
265 |
* @param grfid Id of the grf file |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
266 |
* @param str StringID that we want to have the equivalent in OoenTTD |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
267 |
* @return the properly adjusted StringID |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
268 |
*/ |
7615
8ffd309681c2
(svn r11144) -Codechange: add support for newgrf callbacks 29 and 35
glx
parents:
7605
diff
changeset
|
269 |
StringID MapGRFStringID(uint32 grfid, StringID str) |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
270 |
{ |
7879
27da043a4f69
(svn r11429) -Fix (r11129): some TextID to StringID 'translations' didn't follow our format
glx
parents:
7873
diff
changeset
|
271 |
/* StringID table for TextIDs 0x4E->0x6D */ |
27da043a4f69
(svn r11429) -Fix (r11129): some TextID to StringID 'translations' didn't follow our format
glx
parents:
7873
diff
changeset
|
272 |
static StringID units_volume[] = { |
27da043a4f69
(svn r11429) -Fix (r11129): some TextID to StringID 'translations' didn't follow our format
glx
parents:
7873
diff
changeset
|
273 |
STR_NOTHING, STR_PASSENGERS, STR_TONS, STR_BAGS, |
27da043a4f69
(svn r11429) -Fix (r11129): some TextID to StringID 'translations' didn't follow our format
glx
parents:
7873
diff
changeset
|
274 |
STR_LITERS, STR_ITEMS, STR_CRATES, STR_TONS, |
27da043a4f69
(svn r11429) -Fix (r11129): some TextID to StringID 'translations' didn't follow our format
glx
parents:
7873
diff
changeset
|
275 |
STR_TONS, STR_TONS, STR_TONS, STR_BAGS, |
27da043a4f69
(svn r11429) -Fix (r11129): some TextID to StringID 'translations' didn't follow our format
glx
parents:
7873
diff
changeset
|
276 |
STR_TONS, STR_TONS, STR_TONS, STR_BAGS, |
27da043a4f69
(svn r11429) -Fix (r11129): some TextID to StringID 'translations' didn't follow our format
glx
parents:
7873
diff
changeset
|
277 |
STR_TONS, STR_TONS, STR_BAGS, STR_LITERS, |
27da043a4f69
(svn r11429) -Fix (r11129): some TextID to StringID 'translations' didn't follow our format
glx
parents:
7873
diff
changeset
|
278 |
STR_TONS, STR_LITERS, STR_TONS, STR_NOTHING, |
27da043a4f69
(svn r11429) -Fix (r11129): some TextID to StringID 'translations' didn't follow our format
glx
parents:
7873
diff
changeset
|
279 |
STR_BAGS, STR_LITERS, STR_TONS, STR_NOTHING, |
27da043a4f69
(svn r11429) -Fix (r11129): some TextID to StringID 'translations' didn't follow our format
glx
parents:
7873
diff
changeset
|
280 |
STR_TONS, STR_NOTHING, STR_LITERS, STR_NOTHING |
27da043a4f69
(svn r11429) -Fix (r11129): some TextID to StringID 'translations' didn't follow our format
glx
parents:
7873
diff
changeset
|
281 |
}; |
8655
091434f42207
(svn r12316) -Codechange: Support loading full range of 0xD0xx NewGRF strings which
peter1138
parents:
8649
diff
changeset
|
282 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
283 |
/* 0xD0 and 0xDC stand for all the TextIDs in the range |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
284 |
* of 0xD000 (misc graphics texts) and 0xDC00 (misc persistent texts). |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
285 |
* These strings are unique to each grf file, and thus require to be used with the |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
286 |
* grfid in which they are declared */ |
8655
091434f42207
(svn r12316) -Codechange: Support loading full range of 0xD0xx NewGRF strings which
peter1138
parents:
8649
diff
changeset
|
287 |
switch (GB(str, 8, 8)) { |
091434f42207
(svn r12316) -Codechange: Support loading full range of 0xD0xx NewGRF strings which
peter1138
parents:
8649
diff
changeset
|
288 |
case 0xD0: case 0xD1: case 0xD2: case 0xD3: |
091434f42207
(svn r12316) -Codechange: Support loading full range of 0xD0xx NewGRF strings which
peter1138
parents:
8649
diff
changeset
|
289 |
case 0xDC: |
091434f42207
(svn r12316) -Codechange: Support loading full range of 0xD0xx NewGRF strings which
peter1138
parents:
8649
diff
changeset
|
290 |
return GetGRFStringID(grfid, str); |
091434f42207
(svn r12316) -Codechange: Support loading full range of 0xD0xx NewGRF strings which
peter1138
parents:
8649
diff
changeset
|
291 |
|
091434f42207
(svn r12316) -Codechange: Support loading full range of 0xD0xx NewGRF strings which
peter1138
parents:
8649
diff
changeset
|
292 |
case 0xD4: case 0xD5: case 0xD6: case 0xD7: |
091434f42207
(svn r12316) -Codechange: Support loading full range of 0xD0xx NewGRF strings which
peter1138
parents:
8649
diff
changeset
|
293 |
/* Strings embedded via 0x81 have 0x400 added to them (no real |
091434f42207
(svn r12316) -Codechange: Support loading full range of 0xD0xx NewGRF strings which
peter1138
parents:
8649
diff
changeset
|
294 |
* explanation why...) */ |
091434f42207
(svn r12316) -Codechange: Support loading full range of 0xD0xx NewGRF strings which
peter1138
parents:
8649
diff
changeset
|
295 |
return GetGRFStringID(grfid, str - 0x400); |
091434f42207
(svn r12316) -Codechange: Support loading full range of 0xD0xx NewGRF strings which
peter1138
parents:
8649
diff
changeset
|
296 |
|
091434f42207
(svn r12316) -Codechange: Support loading full range of 0xD0xx NewGRF strings which
peter1138
parents:
8649
diff
changeset
|
297 |
default: break; |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
298 |
} |
8655
091434f42207
(svn r12316) -Codechange: Support loading full range of 0xD0xx NewGRF strings which
peter1138
parents:
8649
diff
changeset
|
299 |
|
7602
9f2631198c8a
(svn r11129) -Fix: update some TextID to StringID 'translations' to reflect changes in language files
glx
parents:
7570
diff
changeset
|
300 |
#define TEXID_TO_STRINGID(begin, end, stringid) if (str >= begin && str <= end) return str + (stringid - begin) |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
301 |
/* We have some changes in our cargo strings, resulting in some missing. */ |
7602
9f2631198c8a
(svn r11129) -Fix: update some TextID to StringID 'translations' to reflect changes in language files
glx
parents:
7570
diff
changeset
|
302 |
TEXID_TO_STRINGID(0x000E, 0x002D, STR_000E); |
9f2631198c8a
(svn r11129) -Fix: update some TextID to StringID 'translations' to reflect changes in language files
glx
parents:
7570
diff
changeset
|
303 |
TEXID_TO_STRINGID(0x002E, 0x004D, STR_002E); |
7879
27da043a4f69
(svn r11429) -Fix (r11129): some TextID to StringID 'translations' didn't follow our format
glx
parents:
7873
diff
changeset
|
304 |
if (str >= 0x004E && str <= 0x006D) str = units_volume[str - 0x004E]; |
7602
9f2631198c8a
(svn r11129) -Fix: update some TextID to StringID 'translations' to reflect changes in language files
glx
parents:
7570
diff
changeset
|
305 |
TEXID_TO_STRINGID(0x006E, 0x008D, STR_QUANTITY_NOTHING); |
9f2631198c8a
(svn r11129) -Fix: update some TextID to StringID 'translations' to reflect changes in language files
glx
parents:
7570
diff
changeset
|
306 |
TEXID_TO_STRINGID(0x008E, 0x00AD, STR_ABBREV_NOTHING); |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
307 |
|
8150
7c4a5e8d94ff
(svn r11712) -Fix (r9315): Add more house string id ranges to MapGRFStringID so NewGRFs use the proper string ids.
maedhros
parents:
8144
diff
changeset
|
308 |
/* Map building names according to our lang file changes. There are several |
7c4a5e8d94ff
(svn r11712) -Fix (r9315): Add more house string id ranges to MapGRFStringID so NewGRFs use the proper string ids.
maedhros
parents:
8144
diff
changeset
|
309 |
* ranges of house ids, all of which need to be remapped to allow newgrfs |
7c4a5e8d94ff
(svn r11712) -Fix (r9315): Add more house string id ranges to MapGRFStringID so NewGRFs use the proper string ids.
maedhros
parents:
8144
diff
changeset
|
310 |
* to use original house names. */ |
7602
9f2631198c8a
(svn r11129) -Fix: update some TextID to StringID 'translations' to reflect changes in language files
glx
parents:
7570
diff
changeset
|
311 |
TEXID_TO_STRINGID(0x200F, 0x201F, STR_200F_TALL_OFFICE_BLOCK); |
8150
7c4a5e8d94ff
(svn r11712) -Fix (r9315): Add more house string id ranges to MapGRFStringID so NewGRFs use the proper string ids.
maedhros
parents:
8144
diff
changeset
|
312 |
TEXID_TO_STRINGID(0x2036, 0x2041, STR_2036_COTTAGES); |
7c4a5e8d94ff
(svn r11712) -Fix (r9315): Add more house string id ranges to MapGRFStringID so NewGRFs use the proper string ids.
maedhros
parents:
8144
diff
changeset
|
313 |
TEXID_TO_STRINGID(0x2059, 0x205C, STR_2059_IGLOO); |
7602
9f2631198c8a
(svn r11129) -Fix: update some TextID to StringID 'translations' to reflect changes in language files
glx
parents:
7570
diff
changeset
|
314 |
|
9f2631198c8a
(svn r11129) -Fix: update some TextID to StringID 'translations' to reflect changes in language files
glx
parents:
7570
diff
changeset
|
315 |
/* Same thing for industries, since the introduction of 4 new strings above STR_482A_PRODUCTION_LAST_MONTH */ |
9f2631198c8a
(svn r11129) -Fix: update some TextID to StringID 'translations' to reflect changes in language files
glx
parents:
7570
diff
changeset
|
316 |
TEXID_TO_STRINGID(0x482A, 0x483B, STR_482A_PRODUCTION_LAST_MONTH); |
9f2631198c8a
(svn r11129) -Fix: update some TextID to StringID 'translations' to reflect changes in language files
glx
parents:
7570
diff
changeset
|
317 |
#undef TEXTID_TO_STRINGID |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
318 |
|
7605
9b6226ed3384
(svn r11132) -Fix: NewGRFs seem to assume that STR_NULL is an empty string or so.
rubidium
parents:
7602
diff
changeset
|
319 |
if (str == STR_NULL) return STR_EMPTY; |
9b6226ed3384
(svn r11132) -Fix: NewGRFs seem to assume that STR_NULL is an empty string or so.
rubidium
parents:
7602
diff
changeset
|
320 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
321 |
return str; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
322 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
323 |
|
10063
29c32eeca86c
(svn r14230) -Codechange: Simplify MapDOSColour() using the new stuff.
frosch
parents:
10062
diff
changeset
|
324 |
static inline uint8 MapDOSColour(uint8 colour) |
6375
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
325 |
{ |
10063
29c32eeca86c
(svn r14230) -Codechange: Simplify MapDOSColour() using the new stuff.
frosch
parents:
10062
diff
changeset
|
326 |
extern const byte _palmap_d2w[]; |
29c32eeca86c
(svn r14230) -Codechange: Simplify MapDOSColour() using the new stuff.
frosch
parents:
10062
diff
changeset
|
327 |
return (_use_palette == PAL_DOS ? colour : _palmap_d2w[colour]); |
6375
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
328 |
} |
b22ee0b2ccd0
(svn r9438) -Codechange: Map cargo colours from DOS to Windows if necessary.
peter1138
parents:
6373
diff
changeset
|
329 |
|
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
330 |
static std::map<uint32, uint32> _grf_id_overrides; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
331 |
|
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
332 |
static void SetNewGRFOverride(uint32 source_grfid, uint32 target_grfid) |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
333 |
{ |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
334 |
_grf_id_overrides[source_grfid] = target_grfid; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
335 |
grfmsg(5, "SetNewGRFOverride: Added override of 0x%X to 0x%X", BSWAP32(source_grfid), BSWAP32(target_grfid)); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
336 |
} |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
337 |
|
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
338 |
static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 internal_id) |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
339 |
{ |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
340 |
/* Hack for add-on GRFs that need to modify another GRF's engines. This lets |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
341 |
* them use the same engine slots. */ |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
342 |
const GRFFile *grf_match = NULL; |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
343 |
if (_settings_game.vehicle.dynamic_engines) { |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
344 |
uint32 override = _grf_id_overrides[file->grfid]; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
345 |
if (override != 0) { |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
346 |
grf_match = GetFileByGRFID(override); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
347 |
if (grf_match == NULL) { |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
348 |
grfmsg(5, "Tried mapping from GRFID %x to %x but target is not loaded", BSWAP32(file->grfid), BSWAP32(override)); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
349 |
} else { |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
350 |
grfmsg(5, "Mapping from GRFID %x to %x", BSWAP32(file->grfid), BSWAP32(override)); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
351 |
} |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
352 |
} |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
353 |
} |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
354 |
|
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
355 |
/* Check if this vehicle is already defined... */ |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
356 |
Engine *e = NULL; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
357 |
FOR_ALL_ENGINES(e) { |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
358 |
if (_settings_game.vehicle.dynamic_engines && e->grffile != NULL && e->grffile != file && e->grffile != grf_match) continue; |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
359 |
if (e->type != type) continue; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
360 |
if (e->internal_id != internal_id) continue; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
361 |
|
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
362 |
if (e->grffile == NULL) { |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
363 |
e->grffile = file; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
364 |
grfmsg(5, "Replaced engine at index %d for GRFID %x, type %d, index %d", e->index, BSWAP32(file->grfid), type, internal_id); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
365 |
} |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
366 |
return e; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
367 |
} |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
368 |
|
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
369 |
uint engine_pool_size = GetEnginePoolSize(); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
370 |
|
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
371 |
/* ... it's not, so create a new one based off an existing engine */ |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
372 |
e = new Engine(type, internal_id); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
373 |
e->grffile = file; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
374 |
|
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
375 |
if (engine_pool_size != GetEnginePoolSize()) { |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
376 |
/* Resize temporary engine data ... */ |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
377 |
_gted = ReallocT(_gted, GetEnginePoolSize()); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
378 |
|
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
379 |
/* and blank the new block. */ |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
380 |
size_t len = (GetEnginePoolSize() - engine_pool_size) * sizeof(*_gted); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
381 |
memset(_gted + engine_pool_size, 0, len); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
382 |
} |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
383 |
|
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
384 |
grfmsg(5, "Created new engine at index %d for GRFID %x, type %d, index %d", e->index, BSWAP32(file->grfid), type, internal_id); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
385 |
|
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
386 |
return e; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
387 |
} |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
388 |
|
9073
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
389 |
EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16 internal_id) |
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
390 |
{ |
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
391 |
extern uint32 GetNewGRFOverride(uint32 grfid); |
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
392 |
|
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
393 |
const GRFFile *grf_match = NULL; |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
394 |
if (_settings_game.vehicle.dynamic_engines) { |
9073
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
395 |
uint32 override = _grf_id_overrides[file->grfid]; |
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
396 |
if (override != 0) grf_match = GetFileByGRFID(override); |
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
397 |
} |
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
398 |
|
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
399 |
const Engine *e = NULL; |
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
400 |
FOR_ALL_ENGINES(e) { |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
401 |
if (_settings_game.vehicle.dynamic_engines && e->grffile != file && (grf_match == NULL || e->grffile != grf_match)) continue; |
9073
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
402 |
if (e->type != type) continue; |
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
403 |
if (e->internal_id != internal_id) continue; |
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
404 |
|
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
405 |
return e->index; |
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
406 |
} |
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
407 |
|
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
408 |
return INVALID_ENGINE; |
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
409 |
} |
0e06e1f08e31
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
peter1138
parents:
9070
diff
changeset
|
410 |
|
8577
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
411 |
/** Map the colour modifiers of TTDPatch to those that Open is using. |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
412 |
* @param grf_sprite pointer to the structure been modified |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
413 |
*/ |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
414 |
static void MapSpriteMappingRecolour(PalSpriteID *grf_sprite) |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
415 |
{ |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
416 |
if (HasBit(grf_sprite->pal, 14)) { |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
417 |
ClrBit(grf_sprite->pal, 14); |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
418 |
SetBit(grf_sprite->sprite, SPRITE_MODIFIER_OPAQUE); |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
419 |
} |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
420 |
|
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
421 |
if (HasBit(grf_sprite->sprite, 14)) { |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
422 |
ClrBit(grf_sprite->sprite, 14); |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
423 |
SetBit(grf_sprite->sprite, PALETTE_MODIFIER_TRANSPARENT); |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
424 |
} |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
425 |
|
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
426 |
if (HasBit(grf_sprite->sprite, 15)) { |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
427 |
ClrBit(grf_sprite->sprite, 15); |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
428 |
SetBit(grf_sprite->sprite, PALETTE_MODIFIER_COLOR); |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
429 |
} |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
430 |
} |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
431 |
|
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
432 |
enum ChangeInfoResult { |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
433 |
CIR_SUCCESS, ///< Variable was parsed and read |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
434 |
CIR_UNHANDLED, ///< Variable was parsed but unread |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
435 |
CIR_UNKNOWN, ///< Variable is unknown |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
436 |
CIR_INVALID_ID, ///< Attempt to modify an invalid ID |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
437 |
}; |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
438 |
|
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
439 |
typedef ChangeInfoResult (*VCI_Handler)(uint engine, int numinfo, int prop, byte **buf, int len); |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
440 |
|
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
441 |
static ChangeInfoResult CommonVehicleChangeInfo(EngineInfo *ei, int prop, byte **buf) |
10038
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
442 |
{ |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
443 |
switch (prop) { |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
444 |
case 0x00: // Introduction date |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
445 |
ei->base_intro = grf_load_word(buf) + DAYS_TILL_ORIGINAL_BASE_YEAR; |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
446 |
break; |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
447 |
|
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
448 |
case 0x02: // Decay speed |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
449 |
ei->decay_speed = grf_load_byte(buf); |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
450 |
break; |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
451 |
|
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
452 |
case 0x03: // Vehicle life |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
453 |
ei->lifelength = grf_load_byte(buf); |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
454 |
break; |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
455 |
|
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
456 |
case 0x04: // Model life |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
457 |
ei->base_life = grf_load_byte(buf); |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
458 |
break; |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
459 |
|
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
460 |
case 0x06: // Climates available |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
461 |
ei->climates = grf_load_byte(buf); |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
462 |
/* Sometimes a GRF wants hidden vehicles. Setting climates to |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
463 |
* zero may cause the ID to be reallocated. */ |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
464 |
if (ei->climates == 0) ei->climates = 0x80; |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
465 |
break; |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
466 |
|
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
467 |
case 0x07: // Loading speed |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
468 |
/* Amount of cargo loaded during a vehicle's "loading tick" */ |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
469 |
ei->load_amount = grf_load_byte(buf); |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
470 |
break; |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
471 |
|
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
472 |
default: |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
473 |
return CIR_UNKNOWN; |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
474 |
} |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
475 |
|
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
476 |
return CIR_SUCCESS; |
10038
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
477 |
} |
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
478 |
|
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
479 |
static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
480 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
481 |
byte *buf = *bufp; |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
482 |
ChangeInfoResult ret = CIR_SUCCESS; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
483 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
484 |
for (int i = 0; i < numinfo; i++) { |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
485 |
Engine *e = GetNewEngine(_cur_grffile, VEH_TRAIN, engine + i); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
486 |
EngineInfo *ei = &e->info; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
487 |
RailVehicleInfo *rvi = &e->u.rail; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
488 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
489 |
switch (prop) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
490 |
case 0x05: { // Track type |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
491 |
uint8 tracktype = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
492 |
|
3026
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
493 |
switch (tracktype) { |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
494 |
case 0: rvi->railtype = rvi->engclass >= 2 ? RAILTYPE_ELECTRIC : RAILTYPE_RAIL; break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
495 |
case 1: rvi->railtype = RAILTYPE_MONO; break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
496 |
case 2: rvi->railtype = RAILTYPE_MAGLEV; break; |
3026
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
497 |
default: |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
498 |
grfmsg(1, "RailVehicleChangeInfo: Invalid track type %d specified, ignoring", tracktype); |
3026
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
499 |
break; |
7bbf6cbf3749
(svn r3606) - NewGRF: Convert from TTDP railtype values to our own railtypes. (These are currently the same, but won't be forever...)
peter1138
parents:
3023
diff
changeset
|
500 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
501 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
502 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
503 |
case 0x08: // AI passenger service |
8449
64c872ab3ed3
(svn r12019) -Codechange: Add support for passenger engine designation for AI-use, NewGRF property 0x08 for trains.
peter1138
parents:
8431
diff
changeset
|
504 |
/* Tells the AI that this engine is designed for |
7162
6435ada4bc34
(svn r10436) -Cleanup: Doxygenise some comments, update others, and make a few statements more consistent with everything else.
maedhros
parents:
7161
diff
changeset
|
505 |
* passenger services and shouldn't be used for freight. */ |
8449
64c872ab3ed3
(svn r12019) -Codechange: Add support for passenger engine designation for AI-use, NewGRF property 0x08 for trains.
peter1138
parents:
8431
diff
changeset
|
506 |
rvi->ai_passenger_only = grf_load_byte(&buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
507 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
508 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
509 |
case 0x09: { // Speed (1 unit is 1 kmh) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
510 |
uint16 speed = grf_load_word(&buf); |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
511 |
if (speed == 0xFFFF) speed = 0; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
512 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
513 |
rvi->max_speed = speed; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
514 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
515 |
|
9208
191eb01c025a
(svn r13074) -Fix: For multiheaded engines, halve power and running cost when used instead of when loading, to allow callback values to work properly.
peter1138
parents:
9146
diff
changeset
|
516 |
case 0x0B: // Power |
191eb01c025a
(svn r13074) -Fix: For multiheaded engines, halve power and running cost when used instead of when loading, to allow callback values to work properly.
peter1138
parents:
9146
diff
changeset
|
517 |
rvi->power = grf_load_word(&buf); |
9468
7087fa70cfd4
(svn r13388) -Codechange: Remove "my invented flag for something that is a wagon"
peter1138
parents:
9458
diff
changeset
|
518 |
|
7087fa70cfd4
(svn r13388) -Codechange: Remove "my invented flag for something that is a wagon"
peter1138
parents:
9458
diff
changeset
|
519 |
/* Set engine / wagon state based on power */ |
7087fa70cfd4
(svn r13388) -Codechange: Remove "my invented flag for something that is a wagon"
peter1138
parents:
9458
diff
changeset
|
520 |
if (rvi->power != 0) { |
7087fa70cfd4
(svn r13388) -Codechange: Remove "my invented flag for something that is a wagon"
peter1138
parents:
9458
diff
changeset
|
521 |
if (rvi->railveh_type == RAILVEH_WAGON) { |
7087fa70cfd4
(svn r13388) -Codechange: Remove "my invented flag for something that is a wagon"
peter1138
parents:
9458
diff
changeset
|
522 |
rvi->railveh_type = RAILVEH_SINGLEHEAD; |
7087fa70cfd4
(svn r13388) -Codechange: Remove "my invented flag for something that is a wagon"
peter1138
parents:
9458
diff
changeset
|
523 |
} |
7087fa70cfd4
(svn r13388) -Codechange: Remove "my invented flag for something that is a wagon"
peter1138
parents:
9458
diff
changeset
|
524 |
} else { |
7087fa70cfd4
(svn r13388) -Codechange: Remove "my invented flag for something that is a wagon"
peter1138
parents:
9458
diff
changeset
|
525 |
rvi->railveh_type = RAILVEH_WAGON; |
7087fa70cfd4
(svn r13388) -Codechange: Remove "my invented flag for something that is a wagon"
peter1138
parents:
9458
diff
changeset
|
526 |
} |
9208
191eb01c025a
(svn r13074) -Fix: For multiheaded engines, halve power and running cost when used instead of when loading, to allow callback values to work properly.
peter1138
parents:
9146
diff
changeset
|
527 |
break; |
191eb01c025a
(svn r13074) -Fix: For multiheaded engines, halve power and running cost when used instead of when loading, to allow callback values to work properly.
peter1138
parents:
9146
diff
changeset
|
528 |
|
191eb01c025a
(svn r13074) -Fix: For multiheaded engines, halve power and running cost when used instead of when loading, to allow callback values to work properly.
peter1138
parents:
9146
diff
changeset
|
529 |
case 0x0D: // Running cost factor |
191eb01c025a
(svn r13074) -Fix: For multiheaded engines, halve power and running cost when used instead of when loading, to allow callback values to work properly.
peter1138
parents:
9146
diff
changeset
|
530 |
rvi->running_cost = grf_load_byte(&buf); |
191eb01c025a
(svn r13074) -Fix: For multiheaded engines, halve power and running cost when used instead of when loading, to allow callback values to work properly.
peter1138
parents:
9146
diff
changeset
|
531 |
break; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
532 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
533 |
case 0x0E: { // Running cost base |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
534 |
uint32 base = grf_load_dword(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
535 |
|
8626
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
536 |
/* These magic numbers are used in GRFs to specify the base cost: |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
537 |
* http://wiki.ttdpatch.net/tiki-index.php?page=BaseCosts |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
538 |
*/ |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
539 |
if (base == 0) { |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
540 |
rvi->running_cost_class = 0xFF; |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
541 |
} else if (base < 0x4B34 || base > 0x4C54 || (base - 0x4B34) % 6 != 0) { |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
542 |
grfmsg(1, "RailVehicleChangeInfo: Unsupported running cost base 0x%04X, ignoring", base); |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
543 |
} else { |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
544 |
/* Convert the magic number to an index into the price data */ |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
545 |
rvi->running_cost_class = (base - 0x4B34) / 6; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
546 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
547 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
548 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
549 |
case 0x12: { // Sprite ID |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
550 |
uint8 spriteid = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
551 |
|
2895
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
552 |
/* TTD sprite IDs point to a location in a 16bit array, but we use it |
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
553 |
* as an array index, so we need it to be half the original value. */ |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
554 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
555 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
556 |
rvi->image_index = spriteid; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
557 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
558 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
559 |
case 0x13: { // Dual-headed |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
560 |
uint8 dual = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
561 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
562 |
if (dual != 0) { |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
563 |
rvi->railveh_type = RAILVEH_MULTIHEAD; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
564 |
} else { |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
565 |
rvi->railveh_type = rvi->power == 0 ? |
5875
fabb49e65684
(svn r8465) -Regression (r8455): Switching from dual to single head should switch to wagon if power is zero. .Or something.
peter1138
parents:
5868
diff
changeset
|
566 |
RAILVEH_WAGON : RAILVEH_SINGLEHEAD; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
567 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
568 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
569 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
570 |
case 0x14: // Cargo capacity |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
571 |
rvi->capacity = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
572 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
573 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
574 |
case 0x15: { // Cargo type |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
575 |
uint8 ctype = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
576 |
|
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
577 |
if (ctype < NUM_CARGO && HasBit(_cargo_mask, ctype)) { |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
578 |
rvi->cargo_type = ctype; |
10029
8253082647a9
(svn r14188) -Codechange: [NewGRF] Cargo type of 0xFF is specified to be 'use first refittable cargo', so don't issue a warning for it.
peter1138
parents:
10025
diff
changeset
|
579 |
} else if (ctype == 0xFF) { |
8253082647a9
(svn r14188) -Codechange: [NewGRF] Cargo type of 0xFF is specified to be 'use first refittable cargo', so don't issue a warning for it.
peter1138
parents:
10025
diff
changeset
|
580 |
/* 0xFF is specified as 'use first refittable' */ |
8253082647a9
(svn r14188) -Codechange: [NewGRF] Cargo type of 0xFF is specified to be 'use first refittable cargo', so don't issue a warning for it.
peter1138
parents:
10025
diff
changeset
|
581 |
rvi->cargo_type = CT_INVALID; |
2846
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
582 |
} else { |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
583 |
rvi->cargo_type = CT_INVALID; |
6142
80f876e7bb9f
(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:
6139
diff
changeset
|
584 |
grfmsg(2, "RailVehicleChangeInfo: Invalid cargo type %d, using first refittable", ctype); |
2846
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
585 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
586 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
587 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
588 |
case 0x16: // Weight |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
589 |
SB(rvi->weight, 0, 8, grf_load_byte(&buf)); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
590 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
591 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
592 |
case 0x17: // Cost factor |
9923
3056bf623139
(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
peter1138
parents:
9750
diff
changeset
|
593 |
rvi->cost_factor = grf_load_byte(&buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
594 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
595 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
596 |
case 0x18: // AI rank |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
597 |
rvi->ai_rank = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
598 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
599 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
600 |
case 0x19: { // Engine traction type |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
601 |
/* What do the individual numbers mean? |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
602 |
* 0x00 .. 0x07: Steam |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
603 |
* 0x08 .. 0x27: Diesel |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
604 |
* 0x28 .. 0x31: Electric |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
605 |
* 0x32 .. 0x37: Monorail |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
606 |
* 0x38 .. 0x41: Maglev |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
607 |
*/ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
608 |
uint8 traction = grf_load_byte(&buf); |
6581
3641873f4f3f
(svn r9795) -Codechange: enumify the EngineClass.
rubidium
parents:
6579
diff
changeset
|
609 |
EngineClass engclass; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
610 |
|
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
611 |
if (traction <= 0x07) { |
6581
3641873f4f3f
(svn r9795) -Codechange: enumify the EngineClass.
rubidium
parents:
6579
diff
changeset
|
612 |
engclass = EC_STEAM; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
613 |
} else if (traction <= 0x27) { |
6581
3641873f4f3f
(svn r9795) -Codechange: enumify the EngineClass.
rubidium
parents:
6579
diff
changeset
|
614 |
engclass = EC_DIESEL; |
3355
e414a0b104a6
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3095
diff
changeset
|
615 |
} else if (traction <= 0x31) { |
6581
3641873f4f3f
(svn r9795) -Codechange: enumify the EngineClass.
rubidium
parents:
6579
diff
changeset
|
616 |
engclass = EC_ELECTRIC; |
6585
46035c6baa8d
(svn r9799) -Codechange: separate engine class and engine running cost class (mart3p).
rubidium
parents:
6583
diff
changeset
|
617 |
} else if (traction <= 0x37) { |
46035c6baa8d
(svn r9799) -Codechange: separate engine class and engine running cost class (mart3p).
rubidium
parents:
6583
diff
changeset
|
618 |
engclass = EC_MONORAIL; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
619 |
} else if (traction <= 0x41) { |
6585
46035c6baa8d
(svn r9799) -Codechange: separate engine class and engine running cost class (mart3p).
rubidium
parents:
6583
diff
changeset
|
620 |
engclass = EC_MAGLEV; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
621 |
} else { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
622 |
break; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
623 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
624 |
if (rvi->railtype == RAILTYPE_RAIL && engclass >= EC_ELECTRIC) rvi->railtype = RAILTYPE_ELECTRIC; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
625 |
if (rvi->railtype == RAILTYPE_ELECTRIC && engclass < EC_ELECTRIC) rvi->railtype = RAILTYPE_RAIL; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
626 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
627 |
rvi->engclass = engclass; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
628 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
629 |
|
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
630 |
case 0x1A: // Alter purchase list sort order |
9715
b3dbb8b51870
(svn r13831) -Codechange: Make purchase list order NewGRF property an extended byte.
peter1138
parents:
9674
diff
changeset
|
631 |
AlterVehicleListOrder(e->index, grf_load_extended(&buf)); |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
632 |
break; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
633 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
634 |
case 0x1B: // Powered wagons power bonus |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
635 |
rvi->pow_wag_power = grf_load_word(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
636 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
637 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
638 |
case 0x1C: // Refit cost |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
639 |
ei->refit_cost = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
640 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
641 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
642 |
case 0x1D: // Refit cargo |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
643 |
ei->refit_mask = grf_load_dword(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
644 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
645 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
646 |
case 0x1E: // Callback |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
647 |
ei->callbackmask = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
648 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
649 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
650 |
case 0x1F: // Tractive effort coefficient |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
651 |
rvi->tractive_effort = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
652 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
653 |
|
7791
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
654 |
case 0x20: // Air drag |
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
655 |
/** @todo Air drag for trains. */ |
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
656 |
grf_load_byte(&buf); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
657 |
ret = CIR_UNHANDLED; |
7791
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
658 |
break; |
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
659 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
660 |
case 0x21: // Shorter vehicle |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
661 |
rvi->shorten_factor = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
662 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
663 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
664 |
case 0x22: // Visual effect |
7162
6435ada4bc34
(svn r10436) -Cleanup: Doxygenise some comments, update others, and make a few statements more consistent with everything else.
maedhros
parents:
7161
diff
changeset
|
665 |
/** @see note in engine.h about rvi->visual_effect */ |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
666 |
rvi->visual_effect = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
667 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
668 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
669 |
case 0x23: // Powered wagons weight bonus |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
670 |
rvi->pow_wag_weight = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
671 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
672 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
673 |
case 0x24: { // High byte of vehicle weight |
2542
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
674 |
byte weight = grf_load_byte(&buf); |
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
675 |
|
2545
aa71b3d576ce
(svn r3074) -NewGrf: Fix stupid typo in weight setting.
peter1138
parents:
2542
diff
changeset
|
676 |
if (weight > 4) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
677 |
grfmsg(2, "RailVehicleChangeInfo: Nonsensical weight of %d tons, ignoring", weight << 8); |
2542
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
678 |
} else { |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
679 |
SB(rvi->weight, 8, 8, weight); |
2542
812fc4357594
(svn r3071) -NewGRF: Add support for rail vehicle weight greater than 255 tons.
peter1138
parents:
2530
diff
changeset
|
680 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
681 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
682 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
683 |
case 0x25: // User-defined bit mask to set when checking veh. var. 42 |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
684 |
rvi->user_def_data = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
685 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
686 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
687 |
case 0x26: // Retire vehicle early |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
688 |
ei->retire_early = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
689 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
690 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
691 |
case 0x27: // Miscellaneous flags |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
692 |
ei->misc_flags = grf_load_byte(&buf); |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
693 |
_loaded_newgrf_features.has_2CC |= HasBit(ei->misc_flags, EF_USES_2CC); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
694 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
695 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
696 |
case 0x28: // Cargo classes allowed |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
697 |
_gted[e->index].cargo_allowed = grf_load_word(&buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
698 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
699 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
700 |
case 0x29: // Cargo classes disallowed |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
701 |
_gted[e->index].cargo_disallowed = grf_load_word(&buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
702 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
703 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
704 |
case 0x2A: // Long format introduction date (days since year 0) |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
705 |
ei->base_intro = grf_load_dword(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
706 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
707 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
708 |
default: |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
709 |
ret = CommonVehicleChangeInfo(ei, prop, &buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
710 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
711 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
712 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
713 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
714 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
715 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
716 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
717 |
|
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
718 |
static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
719 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
720 |
byte *buf = *bufp; |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
721 |
ChangeInfoResult ret = CIR_SUCCESS; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
722 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
723 |
for (int i = 0; i < numinfo; i++) { |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
724 |
Engine *e = GetNewEngine(_cur_grffile, VEH_ROAD, engine + i); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
725 |
EngineInfo *ei = &e->info; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
726 |
RoadVehicleInfo *rvi = &e->u.road; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
727 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
728 |
switch (prop) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
729 |
case 0x08: // Speed (1 unit is 0.5 kmh) |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
730 |
rvi->max_speed = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
731 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
732 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
733 |
case 0x09: // Running cost factor |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
734 |
rvi->running_cost = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
735 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
736 |
|
8626
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
737 |
case 0x0A: { // Running cost base |
10038
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
738 |
uint32 base = grf_load_dword(&buf); |
8626
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
739 |
|
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
740 |
/* These magic numbers are used in GRFs to specify the base cost: |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
741 |
* http://wiki.ttdpatch.net/tiki-index.php?page=BaseCosts |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
742 |
*/ |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
743 |
if (base == 0) { |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
744 |
rvi->running_cost_class = 0xFF; |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
745 |
} else if (base < 0x4B34 || base > 0x4C54 || (base - 0x4B34) % 6 != 0) { |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
746 |
grfmsg(1, "RailVehicleChangeInfo: Unsupported running cost base 0x%04X, ignoring", base); |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
747 |
} else { |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
748 |
/* Convert the magic number to an index into the price data */ |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
749 |
rvi->running_cost_class = (base - 0x4B34) / 6; |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
750 |
} |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
751 |
|
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
752 |
break; |
9781464622be
(svn r12209) -Fix: [NewGRF] Support using any base price for rail and road vehicles' running cost, and show running cost of wagons if they have it.
peter1138
parents:
8622
diff
changeset
|
753 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
754 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
755 |
case 0x0E: { // Sprite ID |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
756 |
uint8 spriteid = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
757 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
758 |
/* cars have different custom id in the GRF file */ |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
759 |
if (spriteid == 0xFF) spriteid = 0xFD; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
760 |
|
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
761 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
762 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
763 |
rvi->image_index = spriteid; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
764 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
765 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
766 |
case 0x0F: // Cargo capacity |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
767 |
rvi->capacity = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
768 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
769 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
770 |
case 0x10: { // Cargo type |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
771 |
uint8 cargo = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
772 |
|
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
773 |
if (cargo < NUM_CARGO && HasBit(_cargo_mask, cargo)) { |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
774 |
rvi->cargo_type = cargo; |
10029
8253082647a9
(svn r14188) -Codechange: [NewGRF] Cargo type of 0xFF is specified to be 'use first refittable cargo', so don't issue a warning for it.
peter1138
parents:
10025
diff
changeset
|
775 |
} else if (cargo == 0xFF) { |
8253082647a9
(svn r14188) -Codechange: [NewGRF] Cargo type of 0xFF is specified to be 'use first refittable cargo', so don't issue a warning for it.
peter1138
parents:
10025
diff
changeset
|
776 |
rvi->cargo_type = CT_INVALID; |
2846
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
777 |
} else { |
10030
f57f0b2e056d
(svn r14189) -Fix (r14188): Accidental line removal
peter1138
parents:
10029
diff
changeset
|
778 |
rvi->cargo_type = CT_INVALID; |
6142
80f876e7bb9f
(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:
6139
diff
changeset
|
779 |
grfmsg(2, "RoadVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo); |
2846
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
780 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
781 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
782 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
783 |
case 0x11: // Cost factor |
9923
3056bf623139
(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
peter1138
parents:
9750
diff
changeset
|
784 |
rvi->cost_factor = grf_load_byte(&buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
785 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
786 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
787 |
case 0x12: // SFX |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
788 |
rvi->sfx = (SoundFx)grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
789 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
790 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
791 |
case 0x13: // Power in 10hp |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
792 |
case 0x14: // Weight in 1/4 tons |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
793 |
case 0x15: // Speed in mph*0.8 |
7162
6435ada4bc34
(svn r10436) -Cleanup: Doxygenise some comments, update others, and make a few statements more consistent with everything else.
maedhros
parents:
7161
diff
changeset
|
794 |
/** @todo Support for road vehicles realistic power |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
795 |
* computations (called rvpower in TTDPatch) is just |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
796 |
* missing in OTTD yet. --pasky */ |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
797 |
grf_load_byte(&buf); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
798 |
ret = CIR_UNHANDLED; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
799 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
800 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
801 |
case 0x16: // Cargos available for refitting |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
802 |
ei->refit_mask = grf_load_dword(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
803 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
804 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
805 |
case 0x17: // Callback mask |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
806 |
ei->callbackmask = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
807 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
808 |
|
7791
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
809 |
case 0x18: // Tractive effort |
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
810 |
case 0x19: // Air drag |
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
811 |
/** @todo Tractive effort and air drag for road vehicles. */ |
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
812 |
grf_load_byte(&buf); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
813 |
ret = CIR_UNHANDLED; |
7791
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
814 |
break; |
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
815 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
816 |
case 0x1A: // Refit cost |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
817 |
ei->refit_cost = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
818 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
819 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
820 |
case 0x1B: // Retire vehicle early |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
821 |
ei->retire_early = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
822 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
823 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
824 |
case 0x1C: // Miscellaneous flags |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
825 |
ei->misc_flags = grf_load_byte(&buf); |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
826 |
_loaded_newgrf_features.has_2CC |= HasBit(ei->misc_flags, EF_USES_2CC); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
827 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
828 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
829 |
case 0x1D: // Cargo classes allowed |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
830 |
_gted[e->index].cargo_allowed = grf_load_word(&buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
831 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
832 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
833 |
case 0x1E: // Cargo classes disallowed |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
834 |
_gted[e->index].cargo_disallowed = grf_load_word(&buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
835 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
836 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
837 |
case 0x1F: // Long format introduction date (days since year 0) |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
838 |
ei->base_intro = grf_load_dword(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
839 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
840 |
|
9674
3d401a3233e2
(svn r13774) -Codechange: Add support for changing vehicle purchase list position for all vehicle types.
peter1138
parents:
9672
diff
changeset
|
841 |
case 0x20: // Alter purchase list sort order |
9715
b3dbb8b51870
(svn r13831) -Codechange: Make purchase list order NewGRF property an extended byte.
peter1138
parents:
9674
diff
changeset
|
842 |
AlterVehicleListOrder(e->index, grf_load_extended(&buf)); |
9674
3d401a3233e2
(svn r13774) -Codechange: Add support for changing vehicle purchase list position for all vehicle types.
peter1138
parents:
9672
diff
changeset
|
843 |
break; |
3d401a3233e2
(svn r13774) -Codechange: Add support for changing vehicle purchase list position for all vehicle types.
peter1138
parents:
9672
diff
changeset
|
844 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
845 |
default: |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
846 |
ret = CommonVehicleChangeInfo(ei, prop, &buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
847 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
848 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
849 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
850 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
851 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
852 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
853 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
854 |
|
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
855 |
static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
856 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
857 |
byte *buf = *bufp; |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
858 |
ChangeInfoResult ret = CIR_SUCCESS; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
859 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
860 |
for (int i = 0; i < numinfo; i++) { |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
861 |
Engine *e = GetNewEngine(_cur_grffile, VEH_SHIP, engine + i); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
862 |
EngineInfo *ei = &e->info; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
863 |
ShipVehicleInfo *svi = &e->u.ship; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
864 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
865 |
switch (prop) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
866 |
case 0x08: { // Sprite ID |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
867 |
uint8 spriteid = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
868 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
869 |
/* ships have different custom id in the GRF file */ |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
870 |
if (spriteid == 0xFF) spriteid = 0xFD; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
871 |
|
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
872 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
873 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
874 |
svi->image_index = spriteid; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
875 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
876 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
877 |
case 0x09: // Refittable |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
878 |
svi->refittable = (grf_load_byte(&buf) != 0); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
879 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
880 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
881 |
case 0x0A: // Cost factor |
9923
3056bf623139
(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
peter1138
parents:
9750
diff
changeset
|
882 |
svi->cost_factor = grf_load_byte(&buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
883 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
884 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
885 |
case 0x0B: // Speed (1 unit is 0.5 kmh) |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
886 |
svi->max_speed = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
887 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
888 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
889 |
case 0x0C: { // Cargo type |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
890 |
uint8 cargo = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
891 |
|
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
892 |
if (cargo < NUM_CARGO && HasBit(_cargo_mask, cargo)) { |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
893 |
svi->cargo_type = cargo; |
10029
8253082647a9
(svn r14188) -Codechange: [NewGRF] Cargo type of 0xFF is specified to be 'use first refittable cargo', so don't issue a warning for it.
peter1138
parents:
10025
diff
changeset
|
894 |
} else if (cargo == 0xFF) { |
8253082647a9
(svn r14188) -Codechange: [NewGRF] Cargo type of 0xFF is specified to be 'use first refittable cargo', so don't issue a warning for it.
peter1138
parents:
10025
diff
changeset
|
895 |
svi->cargo_type = CT_INVALID; |
2846
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
896 |
} else { |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
897 |
svi->cargo_type = CT_INVALID; |
6142
80f876e7bb9f
(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:
6139
diff
changeset
|
898 |
grfmsg(2, "ShipVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo); |
2846
0972c297c410
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
peter1138
parents:
2840
diff
changeset
|
899 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
900 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
901 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
902 |
case 0x0D: // Cargo capacity |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
903 |
svi->capacity = grf_load_word(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
904 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
905 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
906 |
case 0x0F: // Running cost factor |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
907 |
svi->running_cost = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
908 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
909 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
910 |
case 0x10: // SFX |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
911 |
svi->sfx = (SoundFx)grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
912 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
913 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
914 |
case 0x11: // Cargos available for refitting |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
915 |
ei->refit_mask = grf_load_dword(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
916 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
917 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
918 |
case 0x12: // Callback mask |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
919 |
ei->callbackmask = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
920 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
921 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
922 |
case 0x13: // Refit cost |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
923 |
ei->refit_cost = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
924 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
925 |
|
7791
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
926 |
case 0x14: // Ocean speed fraction |
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
927 |
case 0x15: // Canal speed fraction |
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
928 |
/** @todo Speed fractions for ships on oceans and canals */ |
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
929 |
grf_load_byte(&buf); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
930 |
ret = CIR_UNHANDLED; |
7791
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
931 |
break; |
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
932 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
933 |
case 0x16: // Retire vehicle early |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
934 |
ei->retire_early = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
935 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
936 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
937 |
case 0x17: // Miscellaneous flags |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
938 |
ei->misc_flags = grf_load_byte(&buf); |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
939 |
_loaded_newgrf_features.has_2CC |= HasBit(ei->misc_flags, EF_USES_2CC); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
940 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
941 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
942 |
case 0x18: // Cargo classes allowed |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
943 |
_gted[e->index].cargo_allowed = grf_load_word(&buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
944 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
945 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
946 |
case 0x19: // Cargo classes disallowed |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
947 |
_gted[e->index].cargo_disallowed = grf_load_word(&buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
948 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
949 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
950 |
case 0x1A: // Long format introduction date (days since year 0) |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
951 |
ei->base_intro = grf_load_dword(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
952 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
953 |
|
9674
3d401a3233e2
(svn r13774) -Codechange: Add support for changing vehicle purchase list position for all vehicle types.
peter1138
parents:
9672
diff
changeset
|
954 |
case 0x1B: // Alter purchase list sort order |
9715
b3dbb8b51870
(svn r13831) -Codechange: Make purchase list order NewGRF property an extended byte.
peter1138
parents:
9674
diff
changeset
|
955 |
AlterVehicleListOrder(e->index, grf_load_extended(&buf)); |
9674
3d401a3233e2
(svn r13774) -Codechange: Add support for changing vehicle purchase list position for all vehicle types.
peter1138
parents:
9672
diff
changeset
|
956 |
break; |
3d401a3233e2
(svn r13774) -Codechange: Add support for changing vehicle purchase list position for all vehicle types.
peter1138
parents:
9672
diff
changeset
|
957 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
958 |
default: |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
959 |
ret = CommonVehicleChangeInfo(ei, prop, &buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
960 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
961 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
962 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
963 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
964 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
965 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
966 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
967 |
|
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
968 |
static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
969 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
970 |
byte *buf = *bufp; |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
971 |
ChangeInfoResult ret = CIR_SUCCESS; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
972 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
973 |
for (int i = 0; i < numinfo; i++) { |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
974 |
Engine *e = GetNewEngine(_cur_grffile, VEH_AIRCRAFT, engine + i); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
975 |
EngineInfo *ei = &e->info; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
976 |
AircraftVehicleInfo *avi = &e->u.air; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
977 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
978 |
switch (prop) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
979 |
case 0x08: { // Sprite ID |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
980 |
uint8 spriteid = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
981 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
982 |
/* aircraft have different custom id in the GRF file */ |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
983 |
if (spriteid == 0xFF) spriteid = 0xFD; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
984 |
|
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
985 |
if (spriteid < 0xFD) spriteid >>= 1; |
2895
8e15f64c4934
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
peter1138
parents:
2876
diff
changeset
|
986 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
987 |
avi->image_index = spriteid; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
988 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
989 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
990 |
case 0x09: // Helicopter |
4926
4b2f470a4355
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
991 |
if (grf_load_byte(&buf) == 0) { |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
992 |
avi->subtype = AIR_HELI; |
4926
4b2f470a4355
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
993 |
} else { |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
994 |
SB(avi->subtype, 0, 1, 1); // AIR_CTOL |
4926
4b2f470a4355
(svn r6906) - Fix [FS#370]: Clear 'large plane' flag if 'helicopter' flag is set. (mart3p)
peter1138
parents:
4918
diff
changeset
|
995 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
996 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
997 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
998 |
case 0x0A: // Large |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
999 |
SB(avi->subtype, 1, 1, (grf_load_byte(&buf) != 0 ? 1 : 0)); // AIR_FAST |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1000 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1001 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1002 |
case 0x0B: // Cost factor |
9923
3056bf623139
(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
peter1138
parents:
9750
diff
changeset
|
1003 |
avi->cost_factor = grf_load_byte(&buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1004 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1005 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1006 |
case 0x0C: // Speed (1 unit is 8 mph, we translate to 1 unit is 1 km/h) |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1007 |
avi->max_speed = (grf_load_byte(&buf) * 129) / 10; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1008 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1009 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1010 |
case 0x0D: // Acceleration |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1011 |
avi->acceleration = (grf_load_byte(&buf) * 129) / 10; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1012 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1013 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1014 |
case 0x0E: // Running cost factor |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1015 |
avi->running_cost = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1016 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1017 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1018 |
case 0x0F: // Passenger capacity |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1019 |
avi->passenger_capacity = grf_load_word(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1020 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1021 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1022 |
case 0x11: // Mail capacity |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1023 |
avi->mail_capacity = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1024 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1025 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1026 |
case 0x12: // SFX |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1027 |
avi->sfx = (SoundFx)grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1028 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1029 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1030 |
case 0x13: // Cargos available for refitting |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1031 |
ei->refit_mask = grf_load_dword(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1032 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1033 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1034 |
case 0x14: // Callback mask |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1035 |
ei->callbackmask = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1036 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1037 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1038 |
case 0x15: // Refit cost |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1039 |
ei->refit_cost = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1040 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1041 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1042 |
case 0x16: // Retire vehicle early |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1043 |
ei->retire_early = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1044 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1045 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1046 |
case 0x17: // Miscellaneous flags |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1047 |
ei->misc_flags = grf_load_byte(&buf); |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
1048 |
_loaded_newgrf_features.has_2CC |= HasBit(ei->misc_flags, EF_USES_2CC); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1049 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1050 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1051 |
case 0x18: // Cargo classes allowed |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
1052 |
_gted[e->index].cargo_allowed = grf_load_word(&buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1053 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1054 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1055 |
case 0x19: // Cargo classes disallowed |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
1056 |
_gted[e->index].cargo_disallowed = grf_load_word(&buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1057 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1058 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1059 |
case 0x1A: // Long format introduction date (days since year 0) |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1060 |
ei->base_intro = grf_load_dword(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1061 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1062 |
|
9674
3d401a3233e2
(svn r13774) -Codechange: Add support for changing vehicle purchase list position for all vehicle types.
peter1138
parents:
9672
diff
changeset
|
1063 |
case 0x1B: // Alter purchase list sort order |
9715
b3dbb8b51870
(svn r13831) -Codechange: Make purchase list order NewGRF property an extended byte.
peter1138
parents:
9674
diff
changeset
|
1064 |
AlterVehicleListOrder(e->index, grf_load_extended(&buf)); |
9674
3d401a3233e2
(svn r13774) -Codechange: Add support for changing vehicle purchase list position for all vehicle types.
peter1138
parents:
9672
diff
changeset
|
1065 |
break; |
3d401a3233e2
(svn r13774) -Codechange: Add support for changing vehicle purchase list position for all vehicle types.
peter1138
parents:
9672
diff
changeset
|
1066 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1067 |
default: |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1068 |
ret = CommonVehicleChangeInfo(ei, prop, &buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1069 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1070 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1071 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1072 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1073 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1074 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1075 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1076 |
|
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1077 |
static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1078 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1079 |
byte *buf = *bufp; |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1080 |
ChangeInfoResult ret = CIR_SUCCESS; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1081 |
|
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1082 |
if (stid + numinfo > MAX_STATIONS) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1083 |
grfmsg(1, "StationChangeInfo: Station %u is invalid, max %u, ignoring", stid + numinfo, MAX_STATIONS); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1084 |
return CIR_INVALID_ID; |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1085 |
} |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1086 |
|
3501
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
1087 |
/* Allocate station specs if necessary */ |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
1088 |
if (_cur_grffile->stations == NULL) _cur_grffile->stations = CallocT<StationSpec*>(MAX_STATIONS); |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1089 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1090 |
for (int i = 0; i < numinfo; i++) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1091 |
StationSpec *statspec = _cur_grffile->stations[stid + i]; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1092 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1093 |
/* Check that the station we are modifying is defined. */ |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1094 |
if (statspec == NULL && prop != 0x08) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1095 |
grfmsg(2, "StationChangeInfo: Attempt to modify undefined station %u, ignoring", stid + i); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1096 |
return CIR_INVALID_ID; |
3501
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
1097 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1098 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1099 |
switch (prop) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1100 |
case 0x08: { // Class ID |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1101 |
StationSpec **spec = &_cur_grffile->stations[stid + i]; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1102 |
|
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1103 |
/* Property 0x08 is special; it is where the station is allocated */ |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1104 |
if (*spec == NULL) *spec = CallocT<StationSpec>(1); |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1105 |
|
3711
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
1106 |
/* Swap classid because we read it in BE meaning WAYP or DFLT */ |
6281 | 1107 |
uint32 classid = grf_load_dword(&buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1108 |
(*spec)->sclass = AllocateStationClass(BSWAP32(classid)); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1109 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1110 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1111 |
case 0x09: // Define sprite layout |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1112 |
statspec->tiles = grf_load_extended(&buf); |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
1113 |
statspec->renderdata = CallocT<DrawTileSprites>(statspec->tiles); |
3740
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
1114 |
statspec->copied_renderdata = false; |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
1115 |
|
6281 | 1116 |
for (uint t = 0; t < statspec->tiles; t++) { |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1117 |
DrawTileSprites *dts = &statspec->renderdata[t]; |
3570
707f93772b0a
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
1118 |
uint seq_count = 0; |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
1119 |
|
3737
1e4df4eb9298
(svn r4719) - Newstations: instead of drawing nothing, fall back to the default sprite layout if a station layout specifies so.
peter1138
parents:
3736
diff
changeset
|
1120 |
dts->seq = NULL; |
8571
53c94d717e99
(svn r12149) -Codechange: Merge 'ground_sprite' and 'ground_pal' of DrawTileSprites into one PalSpriteID
frosch
parents:
8570
diff
changeset
|
1121 |
dts->ground.sprite = grf_load_word(&buf); |
53c94d717e99
(svn r12149) -Codechange: Merge 'ground_sprite' and 'ground_pal' of DrawTileSprites into one PalSpriteID
frosch
parents:
8570
diff
changeset
|
1122 |
dts->ground.pal = grf_load_word(&buf); |
53c94d717e99
(svn r12149) -Codechange: Merge 'ground_sprite' and 'ground_pal' of DrawTileSprites into one PalSpriteID
frosch
parents:
8570
diff
changeset
|
1123 |
if (dts->ground.sprite == 0) continue; |
53c94d717e99
(svn r12149) -Codechange: Merge 'ground_sprite' and 'ground_pal' of DrawTileSprites into one PalSpriteID
frosch
parents:
8570
diff
changeset
|
1124 |
if (HasBit(dts->ground.pal, 15)) { |
53c94d717e99
(svn r12149) -Codechange: Merge 'ground_sprite' and 'ground_pal' of DrawTileSprites into one PalSpriteID
frosch
parents:
8570
diff
changeset
|
1125 |
ClrBit(dts->ground.pal, 15); |
53c94d717e99
(svn r12149) -Codechange: Merge 'ground_sprite' and 'ground_pal' of DrawTileSprites into one PalSpriteID
frosch
parents:
8570
diff
changeset
|
1126 |
SetBit(dts->ground.sprite, SPRITE_MODIFIER_USE_OFFSET); |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1127 |
} |
8577
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
1128 |
|
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
1129 |
MapSpriteMappingRecolour(&dts->ground); |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
1130 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1131 |
while (buf < *bufp + len) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1132 |
DrawTileSeqStruct *dtss; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1133 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1134 |
/* no relative bounding box support */ |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
1135 |
dts->seq = ReallocT((DrawTileSeqStruct*)dts->seq, ++seq_count); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1136 |
dtss = (DrawTileSeqStruct*) &dts->seq[seq_count - 1]; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1137 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1138 |
dtss->delta_x = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1139 |
if ((byte) dtss->delta_x == 0x80) break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1140 |
dtss->delta_y = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1141 |
dtss->delta_z = grf_load_byte(&buf); |
4230
f4e93251e2f6
(svn r5787) Rename width, height and unk of struct DrawTileSeqStruct to size_{x,y,z}
tron
parents:
4201
diff
changeset
|
1142 |
dtss->size_x = grf_load_byte(&buf); |
f4e93251e2f6
(svn r5787) Rename width, height and unk of struct DrawTileSeqStruct to size_{x,y,z}
tron
parents:
4201
diff
changeset
|
1143 |
dtss->size_y = grf_load_byte(&buf); |
f4e93251e2f6
(svn r5787) Rename width, height and unk of struct DrawTileSeqStruct to size_{x,y,z}
tron
parents:
4201
diff
changeset
|
1144 |
dtss->size_z = grf_load_byte(&buf); |
8570
f50de4804ff1
(svn r12148) -Codechange: Merge 'image' and 'pal' of DrawTileSeqStruct into one PalSpriteID
frosch
parents:
8546
diff
changeset
|
1145 |
dtss->image.sprite = grf_load_word(&buf); |
f50de4804ff1
(svn r12148) -Codechange: Merge 'image' and 'pal' of DrawTileSeqStruct into one PalSpriteID
frosch
parents:
8546
diff
changeset
|
1146 |
dtss->image.pal = grf_load_word(&buf); |
3771
9bce8ac706b2
(svn r4763) - Newstations: revert r4762, instead map bit the palette modifier from bit 14 to bit 31 on GRF load.
peter1138
parents:
3768
diff
changeset
|
1147 |
|
3775
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3771
diff
changeset
|
1148 |
/* Remap flags as ours collide */ |
8570
f50de4804ff1
(svn r12148) -Codechange: Merge 'image' and 'pal' of DrawTileSeqStruct into one PalSpriteID
frosch
parents:
8546
diff
changeset
|
1149 |
if (HasBit(dtss->image.pal, 15)) { |
f50de4804ff1
(svn r12148) -Codechange: Merge 'image' and 'pal' of DrawTileSeqStruct into one PalSpriteID
frosch
parents:
8546
diff
changeset
|
1150 |
ClrBit(dtss->image.pal, 15); |
f50de4804ff1
(svn r12148) -Codechange: Merge 'image' and 'pal' of DrawTileSeqStruct into one PalSpriteID
frosch
parents:
8546
diff
changeset
|
1151 |
SetBit(dtss->image.sprite, SPRITE_MODIFIER_USE_OFFSET); |
8158
2946a316540b
(svn r11720) -Codechange: [NewGRF] Add support for bit 30 of station tile layouts; forcing a sprite to always be opaque.
peter1138
parents:
8157
diff
changeset
|
1152 |
} |
8577
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
1153 |
|
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
1154 |
MapSpriteMappingRecolour(&dtss->image); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1155 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1156 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1157 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1158 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1159 |
case 0x0A: { // Copy sprite layout |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1160 |
byte srcid = grf_load_byte(&buf); |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
1161 |
const StationSpec *srcstatspec = _cur_grffile->stations[srcid]; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1162 |
|
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1163 |
statspec->tiles = srcstatspec->tiles; |
3738
4694e7a0e2e4
(svn r4720) - Newstations: instead of literally copying sprite layout data, just copy the pointer to the existing data.
peter1138
parents:
3737
diff
changeset
|
1164 |
statspec->renderdata = srcstatspec->renderdata; |
3740
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
1165 |
statspec->copied_renderdata = true; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1166 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1167 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1168 |
case 0x0B: // Callback mask |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1169 |
statspec->callbackmask = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1170 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1171 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1172 |
case 0x0C: // Disallowed number of platforms |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1173 |
statspec->disallowed_platforms = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1174 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1175 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1176 |
case 0x0D: // Disallowed platform lengths |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1177 |
statspec->disallowed_lengths = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1178 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1179 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1180 |
case 0x0E: // Define custom layout |
5060
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1181 |
statspec->copied_layouts = false; |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1182 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1183 |
while (buf < *bufp + len) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1184 |
byte length = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1185 |
byte number = grf_load_byte(&buf); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1186 |
StationLayout layout; |
3570
707f93772b0a
(svn r4452) - NewGRF: switch to unsigned ints for array indices.
peter1138
parents:
3566
diff
changeset
|
1187 |
uint l, p; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1188 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1189 |
if (length == 0 || number == 0) break; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1190 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1191 |
//debug("l %d > %d ?", length, stat->lengths); |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1192 |
if (length > statspec->lengths) { |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
1193 |
statspec->platforms = ReallocT(statspec->platforms, length); |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1194 |
memset(statspec->platforms + statspec->lengths, 0, length - statspec->lengths); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1195 |
|
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
1196 |
statspec->layouts = ReallocT(statspec->layouts, length); |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1197 |
memset(statspec->layouts + statspec->lengths, 0, |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1198 |
(length - statspec->lengths) * sizeof(*statspec->layouts)); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1199 |
|
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1200 |
statspec->lengths = length; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1201 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1202 |
l = length - 1; // index is zero-based |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1203 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1204 |
//debug("p %d > %d ?", number, stat->platforms[l]); |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1205 |
if (number > statspec->platforms[l]) { |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
1206 |
statspec->layouts[l] = ReallocT(statspec->layouts[l], number); |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
1207 |
/* We expect NULL being 0 here, but C99 guarantees that. */ |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1208 |
memset(statspec->layouts[l] + statspec->platforms[l], 0, |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1209 |
(number - statspec->platforms[l]) * sizeof(**statspec->layouts)); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1210 |
|
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1211 |
statspec->platforms[l] = number; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1212 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1213 |
|
542 | 1214 |
p = 0; |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
1215 |
layout = MallocT<byte>(length * number); |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1216 |
for (l = 0; l < length; l++) { |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1217 |
for (p = 0; p < number; p++) { |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1218 |
layout[l * number + p] = grf_load_byte(&buf); |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1219 |
} |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
1220 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1221 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1222 |
l--; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1223 |
p--; |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1224 |
free(statspec->layouts[l][p]); |
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3672
diff
changeset
|
1225 |
statspec->layouts[l][p] = layout; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1226 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1227 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1228 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1229 |
case 0x0F: { // Copy custom layout |
5060
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1230 |
byte srcid = grf_load_byte(&buf); |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1231 |
const StationSpec *srcstatspec = _cur_grffile->stations[srcid]; |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1232 |
|
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1233 |
statspec->lengths = srcstatspec->lengths; |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1234 |
statspec->platforms = srcstatspec->platforms; |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1235 |
statspec->layouts = srcstatspec->layouts; |
e942a3137724
(svn r7113) -Codechange: [NewStations] Add support for copying custom station layouts
peter1138
parents:
5037
diff
changeset
|
1236 |
statspec->copied_layouts = true; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1237 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1238 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1239 |
case 0x10: // Little/lots cargo threshold |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1240 |
statspec->cargo_threshold = grf_load_word(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1241 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1242 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1243 |
case 0x11: // Pylon placement |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1244 |
statspec->pylons = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1245 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1246 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1247 |
case 0x12: // Cargo types for random triggers |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1248 |
statspec->cargo_triggers = grf_load_dword(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1249 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1250 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1251 |
case 0x13: // General flags |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1252 |
statspec->flags = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1253 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1254 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1255 |
case 0x14: // Overhead wire placement |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1256 |
statspec->wires = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1257 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1258 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1259 |
case 0x15: // Blocked tiles |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1260 |
statspec->blocked = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1261 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1262 |
|
9003
7972fa66d9c9
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138
parents:
8969
diff
changeset
|
1263 |
case 0x16: // Animation info |
7972fa66d9c9
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138
parents:
8969
diff
changeset
|
1264 |
statspec->anim_frames = grf_load_byte(&buf); |
7972fa66d9c9
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138
parents:
8969
diff
changeset
|
1265 |
statspec->anim_status = grf_load_byte(&buf); |
7972fa66d9c9
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138
parents:
8969
diff
changeset
|
1266 |
break; |
7972fa66d9c9
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138
parents:
8969
diff
changeset
|
1267 |
|
7972fa66d9c9
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138
parents:
8969
diff
changeset
|
1268 |
case 0x17: // Animation speed |
7972fa66d9c9
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138
parents:
8969
diff
changeset
|
1269 |
statspec->anim_speed = grf_load_byte(&buf); |
7972fa66d9c9
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138
parents:
8969
diff
changeset
|
1270 |
break; |
7972fa66d9c9
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138
parents:
8969
diff
changeset
|
1271 |
|
7972fa66d9c9
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138
parents:
8969
diff
changeset
|
1272 |
case 0x18: // Animation triggers |
7972fa66d9c9
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138
parents:
8969
diff
changeset
|
1273 |
statspec->anim_triggers = grf_load_word(&buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1274 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1275 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1276 |
default: |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1277 |
ret = CIR_UNKNOWN; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1278 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1279 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1280 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1281 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1282 |
*bufp = buf; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1283 |
return ret; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1284 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1285 |
|
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1286 |
static ChangeInfoResult CanalChangeInfo(uint id, int numinfo, int prop, byte **bufp, int len) |
8372
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1287 |
{ |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1288 |
byte *buf = *bufp; |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1289 |
ChangeInfoResult ret = CIR_SUCCESS; |
8372
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1290 |
|
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1291 |
if (id + numinfo > CF_END) { |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1292 |
grfmsg(1, "CanalChangeInfo: Canal feature %u is invalid, max %u, ignoreing", id + numinfo, CF_END); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1293 |
return CIR_INVALID_ID; |
8372
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1294 |
} |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1295 |
|
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1296 |
for (int i = 0; i < numinfo; i++) { |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1297 |
WaterFeature *wf = &_water_feature[id + i]; |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1298 |
|
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1299 |
switch (prop) { |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1300 |
case 0x08: |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1301 |
wf->callbackmask = grf_load_byte(&buf); |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1302 |
break; |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1303 |
|
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1304 |
case 0x09: |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1305 |
wf->flags = grf_load_byte(&buf); |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1306 |
break; |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1307 |
|
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1308 |
default: |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1309 |
ret = CIR_UNKNOWN; |
8372
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1310 |
break; |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1311 |
} |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1312 |
} |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1313 |
|
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1314 |
*bufp = buf; |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1315 |
return ret; |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1316 |
} |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
1317 |
|
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1318 |
static ChangeInfoResult BridgeChangeInfo(uint brid, int numinfo, int prop, byte **bufp, int len) |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1319 |
{ |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1320 |
byte *buf = *bufp; |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1321 |
ChangeInfoResult ret = CIR_SUCCESS; |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1322 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1323 |
if (brid + numinfo > MAX_BRIDGES) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1324 |
grfmsg(1, "BridgeChangeInfo: Bridge %u is invalid, max %u, ignoring", brid + numinfo, MAX_BRIDGES); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1325 |
return CIR_INVALID_ID; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1326 |
} |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1327 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1328 |
for (int i = 0; i < numinfo; i++) { |
8535
ef36a2eb9345
(svn r12111) -Codechange: Rename Bridge to BridgeSpec, out of consistensy with other Specs in used.
belugas
parents:
8494
diff
changeset
|
1329 |
BridgeSpec *bridge = &_bridge[brid + i]; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1330 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1331 |
switch (prop) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1332 |
case 0x08: // Year of availability |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1333 |
bridge->avail_year = ORIGINAL_BASE_YEAR + grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1334 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1335 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1336 |
case 0x09: // Minimum length |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1337 |
bridge->min_length = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1338 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1339 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1340 |
case 0x0A: // Maximum length |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1341 |
bridge->max_length = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1342 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1343 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1344 |
case 0x0B: // Cost factor |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1345 |
bridge->price = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1346 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1347 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1348 |
case 0x0C: // Maximum speed |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1349 |
bridge->speed = grf_load_word(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1350 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1351 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1352 |
case 0x0D: { // Bridge sprite tables |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1353 |
byte tableid = grf_load_byte(&buf); |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1354 |
byte numtables = grf_load_byte(&buf); |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1355 |
|
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1356 |
if (bridge->sprite_table == NULL) { |
3555
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1357 |
/* Allocate memory for sprite table pointers and zero out */ |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
1358 |
bridge->sprite_table = CallocT<PalSpriteID*>(7); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1359 |
} |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1360 |
|
3555
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1361 |
for (; numtables-- != 0; tableid++) { |
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1362 |
if (tableid >= 7) { // skip invalid data |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1363 |
grfmsg(1, "BridgeChangeInfo: Table %d >= 7, skipping", tableid); |
6281 | 1364 |
for (byte sprite = 0; sprite < 32; sprite++) grf_load_dword(&buf); |
3555
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1365 |
continue; |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1366 |
} |
3555
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1367 |
|
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1368 |
if (bridge->sprite_table[tableid] == NULL) { |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
1369 |
bridge->sprite_table[tableid] = MallocT<PalSpriteID>(32); |
3555
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1370 |
} |
968a9f073113
(svn r4429) - CodeChange[newgrf]: Action0, prop 0x0D. use calloc to allocate memory and zero it out and change the loop a little
Darkvater
parents:
3548
diff
changeset
|
1371 |
|
6281 | 1372 |
for (byte sprite = 0; sprite < 32; sprite++) { |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1373 |
SpriteID image = grf_load_word(&buf); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1374 |
SpriteID pal = grf_load_word(&buf); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1375 |
|
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1376 |
bridge->sprite_table[tableid][sprite].sprite = image; |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1377 |
bridge->sprite_table[tableid][sprite].pal = pal; |
8577
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
1378 |
|
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
1379 |
MapSpriteMappingRecolour(&bridge->sprite_table[tableid][sprite]); |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5617
diff
changeset
|
1380 |
} |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1381 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1382 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1383 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1384 |
case 0x0E: // Flags; bit 0 - disable far pillars |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1385 |
bridge->flags = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1386 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1387 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1388 |
case 0x0F: // Long format year of availability (year since year 0) |
7922
a7e266f966d9
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents:
7902
diff
changeset
|
1389 |
bridge->avail_year = Clamp(grf_load_dword(&buf), MIN_YEAR, MAX_YEAR); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1390 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1391 |
|
8494
29ab03009759
(svn r12069) -Feature[newGRF]: Specify the purchase, rail and road description of a bridge.
belugas
parents:
8489
diff
changeset
|
1392 |
case 0x10: { // purchase string |
29ab03009759
(svn r12069) -Feature[newGRF]: Specify the purchase, rail and road description of a bridge.
belugas
parents:
8489
diff
changeset
|
1393 |
StringID newone = GetGRFStringID(_cur_grffile->grfid, grf_load_word(&buf)); |
29ab03009759
(svn r12069) -Feature[newGRF]: Specify the purchase, rail and road description of a bridge.
belugas
parents:
8489
diff
changeset
|
1394 |
if (newone != STR_UNDEFINED) bridge->material = newone; |
29ab03009759
(svn r12069) -Feature[newGRF]: Specify the purchase, rail and road description of a bridge.
belugas
parents:
8489
diff
changeset
|
1395 |
} break; |
29ab03009759
(svn r12069) -Feature[newGRF]: Specify the purchase, rail and road description of a bridge.
belugas
parents:
8489
diff
changeset
|
1396 |
|
8540
7d2f5260dc4b
(svn r12118) -Codechange: Put the two descriptions of bridges in an array instead of two single variables, following the transport type it represents
belugas
parents:
8535
diff
changeset
|
1397 |
case 0x11: // description of bridge with rails or roads |
7d2f5260dc4b
(svn r12118) -Codechange: Put the two descriptions of bridges in an array instead of two single variables, following the transport type it represents
belugas
parents:
8535
diff
changeset
|
1398 |
case 0x12: { |
8494
29ab03009759
(svn r12069) -Feature[newGRF]: Specify the purchase, rail and road description of a bridge.
belugas
parents:
8489
diff
changeset
|
1399 |
StringID newone = GetGRFStringID(_cur_grffile->grfid, grf_load_word(&buf)); |
8540
7d2f5260dc4b
(svn r12118) -Codechange: Put the two descriptions of bridges in an array instead of two single variables, following the transport type it represents
belugas
parents:
8535
diff
changeset
|
1400 |
if (newone != STR_UNDEFINED) bridge->transport_name[prop - 0x11] = newone; |
8494
29ab03009759
(svn r12069) -Feature[newGRF]: Specify the purchase, rail and road description of a bridge.
belugas
parents:
8489
diff
changeset
|
1401 |
} break; |
29ab03009759
(svn r12069) -Feature[newGRF]: Specify the purchase, rail and road description of a bridge.
belugas
parents:
8489
diff
changeset
|
1402 |
|
10013
cf6837425ca9
(svn r14172) -Feature[newGRF]: Add support for property 0x13 for Bridges.
belugas
parents:
10002
diff
changeset
|
1403 |
case 0x13: // 16 bits cost multiplier |
cf6837425ca9
(svn r14172) -Feature[newGRF]: Add support for property 0x13 for Bridges.
belugas
parents:
10002
diff
changeset
|
1404 |
bridge->price = grf_load_word(&buf); |
cf6837425ca9
(svn r14172) -Feature[newGRF]: Add support for property 0x13 for Bridges.
belugas
parents:
10002
diff
changeset
|
1405 |
break; |
cf6837425ca9
(svn r14172) -Feature[newGRF]: Add support for property 0x13 for Bridges.
belugas
parents:
10002
diff
changeset
|
1406 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1407 |
default: |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1408 |
ret = CIR_UNKNOWN; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1409 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1410 |
} |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1411 |
} |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1412 |
|
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1413 |
*bufp = buf; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1414 |
return ret; |
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
1415 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
1416 |
|
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1417 |
static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, byte **bufp, int len) |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1418 |
{ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1419 |
byte *buf = *bufp; |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1420 |
ChangeInfoResult ret = CIR_SUCCESS; |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1421 |
|
7161
0bb3acce3797
(svn r10435) -Fix (r9315): numinfo starts from 1, not 0, so make it possible to define a house with a local id of 255.
maedhros
parents:
7160
diff
changeset
|
1422 |
if (hid + numinfo > HOUSE_MAX) { |
0bb3acce3797
(svn r10435) -Fix (r9315): numinfo starts from 1, not 0, so make it possible to define a house with a local id of 255.
maedhros
parents:
7160
diff
changeset
|
1423 |
grfmsg(1, "TownHouseChangeInfo: Too many houses loaded (%u), max (%u). Ignoring.", hid + numinfo, HOUSE_MAX); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1424 |
return CIR_INVALID_ID; |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1425 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1426 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1427 |
/* Allocate house specs if they haven't been allocated already. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1428 |
if (_cur_grffile->housespec == NULL) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1429 |
_cur_grffile->housespec = CallocT<HouseSpec*>(HOUSE_MAX); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1430 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1431 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1432 |
for (int i = 0; i < numinfo; i++) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1433 |
HouseSpec *housespec = _cur_grffile->housespec[hid + i]; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1434 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1435 |
if (prop != 0x08 && housespec == NULL) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1436 |
grfmsg(2, "TownHouseChangeInfo: Attempt to modify undefined house %u. Ignoring.", hid + i); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1437 |
return CIR_INVALID_ID; |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1438 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1439 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1440 |
switch (prop) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1441 |
case 0x08: { // Substitute building type, and definition of a new house |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1442 |
HouseSpec **house = &_cur_grffile->housespec[hid + i]; |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1443 |
byte subs_id = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1444 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1445 |
if (subs_id == 0xFF) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1446 |
/* Instead of defining a new house, a substitute house id |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1447 |
* of 0xFF disables the old house with the current id. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1448 |
_house_specs[hid + i].enabled = false; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1449 |
continue; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1450 |
} else if (subs_id >= NEW_HOUSE_OFFSET) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1451 |
/* The substitute id must be one of the original houses. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1452 |
grfmsg(2, "TownHouseChangeInfo: Attempt to use new house %u as substitute house for %u. Ignoring.", subs_id, hid + i); |
10041
9b8ed66c3cf4
(svn r14201) -Codechange: [NewGRF] Don't continue processing an Action 0 if we didn't read the data for a property -- the data will be wrong for subsequent reads.
peter1138
parents:
10039
diff
changeset
|
1453 |
continue; |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1454 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1455 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1456 |
/* Allocate space for this house. */ |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1457 |
if (*house == NULL) *house = CallocT<HouseSpec>(1); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1458 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1459 |
housespec = *house; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1460 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1461 |
memcpy(housespec, &_house_specs[subs_id], sizeof(_house_specs[subs_id])); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1462 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1463 |
housespec->enabled = true; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1464 |
housespec->local_id = hid + i; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1465 |
housespec->substitute_id = subs_id; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1466 |
housespec->grffile = _cur_grffile; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1467 |
housespec->random_colour[0] = 0x04; // those 4 random colours are the base colour |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1468 |
housespec->random_colour[1] = 0x08; // for all new houses |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1469 |
housespec->random_colour[2] = 0x0C; // they stand for red, blue, orange and green |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1470 |
housespec->random_colour[3] = 0x06; |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1471 |
|
7431
cac40a9365f3
(svn r10836) -Fix [FS#1014]: Make sure the third cargo type accepted by houses is valid in
maedhros
parents:
7287
diff
changeset
|
1472 |
/* Make sure that the third cargo type is valid in this |
cac40a9365f3
(svn r10836) -Fix [FS#1014]: Make sure the third cargo type accepted by houses is valid in
maedhros
parents:
7287
diff
changeset
|
1473 |
* climate. This can cause problems when copying the properties |
cac40a9365f3
(svn r10836) -Fix [FS#1014]: Make sure the third cargo type accepted by houses is valid in
maedhros
parents:
7287
diff
changeset
|
1474 |
* of a house that accepts food, where the new house is valid |
cac40a9365f3
(svn r10836) -Fix [FS#1014]: Make sure the third cargo type accepted by houses is valid in
maedhros
parents:
7287
diff
changeset
|
1475 |
* in the temperate climate. */ |
cac40a9365f3
(svn r10836) -Fix [FS#1014]: Make sure the third cargo type accepted by houses is valid in
maedhros
parents:
7287
diff
changeset
|
1476 |
if (!GetCargo(housespec->accepts_cargo[2])->IsValid()) { |
cac40a9365f3
(svn r10836) -Fix [FS#1014]: Make sure the third cargo type accepted by houses is valid in
maedhros
parents:
7287
diff
changeset
|
1477 |
housespec->cargo_acceptance[2] = 0; |
cac40a9365f3
(svn r10836) -Fix [FS#1014]: Make sure the third cargo type accepted by houses is valid in
maedhros
parents:
7287
diff
changeset
|
1478 |
} |
cac40a9365f3
(svn r10836) -Fix [FS#1014]: Make sure the third cargo type accepted by houses is valid in
maedhros
parents:
7287
diff
changeset
|
1479 |
|
7162
6435ada4bc34
(svn r10436) -Cleanup: Doxygenise some comments, update others, and make a few statements more consistent with everything else.
maedhros
parents:
7161
diff
changeset
|
1480 |
/** |
6435ada4bc34
(svn r10436) -Cleanup: Doxygenise some comments, update others, and make a few statements more consistent with everything else.
maedhros
parents:
7161
diff
changeset
|
1481 |
* New houses do not (currently) expect to have a default start |
6435ada4bc34
(svn r10436) -Cleanup: Doxygenise some comments, update others, and make a few statements more consistent with everything else.
maedhros
parents:
7161
diff
changeset
|
1482 |
* date before 1930, as this breaks the build date stuff. |
6435ada4bc34
(svn r10436) -Cleanup: Doxygenise some comments, update others, and make a few statements more consistent with everything else.
maedhros
parents:
7161
diff
changeset
|
1483 |
* @see FinaliseHouseArray() for more details. |
6435ada4bc34
(svn r10436) -Cleanup: Doxygenise some comments, update others, and make a few statements more consistent with everything else.
maedhros
parents:
7161
diff
changeset
|
1484 |
*/ |
9450
9e7d05b0b1e5
(svn r13368) -Codechange: give house's min/max_date a better name, as it is really year, not date
belugas
parents:
9446
diff
changeset
|
1485 |
if (housespec->min_year < 1930) housespec->min_year = 1930; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1486 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1487 |
_loaded_newgrf_features.has_newhouses = true; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1488 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1489 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1490 |
case 0x09: // Building flags |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1491 |
housespec->building_flags = (BuildingFlags)grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1492 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1493 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1494 |
case 0x0A: { // Availability years |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1495 |
uint16 years = grf_load_word(&buf); |
9450
9e7d05b0b1e5
(svn r13368) -Codechange: give house's min/max_date a better name, as it is really year, not date
belugas
parents:
9446
diff
changeset
|
1496 |
housespec->min_year = GB(years, 0, 8) > 150 ? MAX_YEAR : ORIGINAL_BASE_YEAR + GB(years, 0, 8); |
9e7d05b0b1e5
(svn r13368) -Codechange: give house's min/max_date a better name, as it is really year, not date
belugas
parents:
9446
diff
changeset
|
1497 |
housespec->max_year = GB(years, 8, 8) > 150 ? MAX_YEAR : ORIGINAL_BASE_YEAR + GB(years, 8, 8); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1498 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1499 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1500 |
case 0x0B: // Population |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1501 |
housespec->population = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1502 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1503 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1504 |
case 0x0C: // Mail generation multiplier |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1505 |
housespec->mail_generation = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1506 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1507 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1508 |
case 0x0D: // Passenger acceptance |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1509 |
case 0x0E: // Mail acceptance |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1510 |
housespec->cargo_acceptance[prop - 0x0D] = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1511 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1512 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1513 |
case 0x0F: { // Goods/candy, food/fizzy drinks acceptance |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1514 |
int8 goods = grf_load_byte(&buf); |
6341
b670e4765225
(svn r9366) -Codechange: Unify the different houses acceptances attributes on their cargo counterpart, as well as specifying cargo slot.
belugas
parents:
6332
diff
changeset
|
1515 |
|
b670e4765225
(svn r9366) -Codechange: Unify the different houses acceptances attributes on their cargo counterpart, as well as specifying cargo slot.
belugas
parents:
6332
diff
changeset
|
1516 |
/* If value of goods is negative, it means in fact food or, if in toyland, fizzy_drink acceptance. |
b670e4765225
(svn r9366) -Codechange: Unify the different houses acceptances attributes on their cargo counterpart, as well as specifying cargo slot.
belugas
parents:
6332
diff
changeset
|
1517 |
* Else, we have "standard" 3rd cargo type, goods or candy, for toyland once more */ |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
1518 |
CargoID cid = (goods >= 0) ? ((_settings_game.game_creation.landscape == LT_TOYLAND) ? CT_CANDY : CT_GOODS) : |
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
1519 |
((_settings_game.game_creation.landscape == LT_TOYLAND) ? CT_FIZZY_DRINKS : CT_FOOD); |
6341
b670e4765225
(svn r9366) -Codechange: Unify the different houses acceptances attributes on their cargo counterpart, as well as specifying cargo slot.
belugas
parents:
6332
diff
changeset
|
1520 |
|
7431
cac40a9365f3
(svn r10836) -Fix [FS#1014]: Make sure the third cargo type accepted by houses is valid in
maedhros
parents:
7287
diff
changeset
|
1521 |
/* Make sure the cargo type is valid in this climate. */ |
cac40a9365f3
(svn r10836) -Fix [FS#1014]: Make sure the third cargo type accepted by houses is valid in
maedhros
parents:
7287
diff
changeset
|
1522 |
if (!GetCargo(cid)->IsValid()) goods = 0; |
cac40a9365f3
(svn r10836) -Fix [FS#1014]: Make sure the third cargo type accepted by houses is valid in
maedhros
parents:
7287
diff
changeset
|
1523 |
|
cac40a9365f3
(svn r10836) -Fix [FS#1014]: Make sure the third cargo type accepted by houses is valid in
maedhros
parents:
7287
diff
changeset
|
1524 |
housespec->accepts_cargo[2] = cid; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1525 |
housespec->cargo_acceptance[2] = abs(goods); // but we do need positive value here |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1526 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1527 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1528 |
case 0x10: // Local authority rating decrease on removal |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1529 |
housespec->remove_rating_decrease = grf_load_word(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1530 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1531 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1532 |
case 0x11: // Removal cost multiplier |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1533 |
housespec->removal_cost = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1534 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1535 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1536 |
case 0x12: // Building name ID |
8959
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
1537 |
housespec->building_name = grf_load_word(&buf); |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
1538 |
_string_to_grf_mapping[&housespec->building_name] = _cur_grffile->grfid; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1539 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1540 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1541 |
case 0x13: // Building availability mask |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1542 |
housespec->building_availability = (HouseZones)grf_load_word(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1543 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1544 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1545 |
case 0x14: // House callback flags |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1546 |
housespec->callback_mask = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1547 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1548 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1549 |
case 0x15: { // House override byte |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1550 |
byte override = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1551 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1552 |
/* The house being overridden must be an original house. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1553 |
if (override >= NEW_HOUSE_OFFSET) { |
7160
131be0f3e0ef
(svn r10434) -Fix (r9315): When setting multiple house overrides in one Action 0, don't override them all with the first ID.
maedhros
parents:
7159
diff
changeset
|
1554 |
grfmsg(2, "TownHouseChangeInfo: Attempt to override new house %u with house id %u. Ignoring.", override, hid + i); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1555 |
continue; |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1556 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1557 |
|
7873
9bb5874c81df
(svn r11423) -Codechange: store grfid when adding an override
glx
parents:
7831
diff
changeset
|
1558 |
_house_mngr.Add(hid + i, _cur_grffile->grfid, override); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1559 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1560 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1561 |
case 0x16: // Periodic refresh multiplier |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1562 |
housespec->processing_time = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1563 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1564 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1565 |
case 0x17: // Four random colours to use |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1566 |
for (uint j = 0; j < 4; j++) housespec->random_colour[j] = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1567 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1568 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1569 |
case 0x18: // Relative probability of appearing |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1570 |
housespec->probability = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1571 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1572 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1573 |
case 0x19: // Extra flags |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1574 |
housespec->extra_flags = (HouseExtraFlags)grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1575 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1576 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1577 |
case 0x1A: // Animation frames |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1578 |
housespec->animation_frames = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1579 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1580 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1581 |
case 0x1B: // Animation speed |
7922
a7e266f966d9
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents:
7902
diff
changeset
|
1582 |
housespec->animation_speed = Clamp(grf_load_byte(&buf), 2, 16); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1583 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1584 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1585 |
case 0x1C: // Class of the building type |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1586 |
housespec->class_id = AllocateHouseClassID(grf_load_byte(&buf), _cur_grffile->grfid); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1587 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1588 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1589 |
case 0x1D: // Callback flags 2 |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1590 |
housespec->callback_mask |= (grf_load_byte(&buf) << 8); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1591 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1592 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1593 |
case 0x1E: { // Accepted cargo types |
6461
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1594 |
uint32 cargotypes = grf_load_dword(&buf); |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1595 |
|
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1596 |
/* Check if the cargo types should not be changed */ |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1597 |
if (cargotypes == 0xFFFFFFFF) break; |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1598 |
|
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1599 |
for (uint j = 0; j < 3; j++) { |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1600 |
/* Get the cargo number from the 'list' */ |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1601 |
uint8 cargo_part = GB(cargotypes, 8 * j, 8); |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1602 |
CargoID cargo = GetCargoTranslation(cargo_part, _cur_grffile); |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1603 |
|
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1604 |
if (cargo == CT_INVALID) { |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1605 |
/* Disable acceptance of invalid cargo type */ |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1606 |
housespec->cargo_acceptance[j] = 0; |
6461
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1607 |
} else { |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1608 |
housespec->accepts_cargo[j] = cargo; |
6461
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1609 |
} |
1cfd2363a072
(svn r9621) -Codechange: implement newgrf house property 1E (cargo types)
peter1138
parents:
6451
diff
changeset
|
1610 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1611 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1612 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1613 |
case 0x1F: // Minimum life span |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1614 |
housespec->minimum_life = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1615 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1616 |
|
7791
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
1617 |
case 0x20: { // @todo Cargo acceptance watch list |
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
1618 |
byte count = grf_load_byte(&buf); |
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
1619 |
for (byte j = 0; j < count; j++) grf_load_byte(&buf); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1620 |
ret = CIR_UNHANDLED; |
7791
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
1621 |
} break; |
6d0d9804ef67
(svn r11341) -Codechange: add missing callback ID enums, add stub for house property 20 and reorder unimplemented action 0 properties
glx
parents:
7780
diff
changeset
|
1622 |
|
9483
cdefc44b5f60
(svn r13437) -Feature[newGRF]: Add long format introduction and maximum construction year for house.
belugas
parents:
9470
diff
changeset
|
1623 |
case 0x21: // long introduction year |
cdefc44b5f60
(svn r13437) -Feature[newGRF]: Add long format introduction and maximum construction year for house.
belugas
parents:
9470
diff
changeset
|
1624 |
housespec->min_year = grf_load_word(&buf); |
cdefc44b5f60
(svn r13437) -Feature[newGRF]: Add long format introduction and maximum construction year for house.
belugas
parents:
9470
diff
changeset
|
1625 |
break; |
cdefc44b5f60
(svn r13437) -Feature[newGRF]: Add long format introduction and maximum construction year for house.
belugas
parents:
9470
diff
changeset
|
1626 |
|
cdefc44b5f60
(svn r13437) -Feature[newGRF]: Add long format introduction and maximum construction year for house.
belugas
parents:
9470
diff
changeset
|
1627 |
case 0x22: // long maximum year |
cdefc44b5f60
(svn r13437) -Feature[newGRF]: Add long format introduction and maximum construction year for house.
belugas
parents:
9470
diff
changeset
|
1628 |
housespec->max_year = grf_load_word(&buf); |
cdefc44b5f60
(svn r13437) -Feature[newGRF]: Add long format introduction and maximum construction year for house.
belugas
parents:
9470
diff
changeset
|
1629 |
break; |
cdefc44b5f60
(svn r13437) -Feature[newGRF]: Add long format introduction and maximum construction year for house.
belugas
parents:
9470
diff
changeset
|
1630 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1631 |
default: |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1632 |
ret = CIR_UNKNOWN; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1633 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1634 |
} |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1635 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1636 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1637 |
*bufp = buf; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1638 |
return ret; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1639 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
1640 |
|
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1641 |
static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, int len) |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1642 |
{ |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1643 |
byte *buf = *bufp; |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1644 |
ChangeInfoResult ret = CIR_SUCCESS; |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1645 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1646 |
for (int i = 0; i < numinfo; i++) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1647 |
switch (prop) { |
7162
6435ada4bc34
(svn r10436) -Cleanup: Doxygenise some comments, update others, and make a few statements more consistent with everything else.
maedhros
parents:
7161
diff
changeset
|
1648 |
case 0x08: { // Cost base factor |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1649 |
byte factor = grf_load_byte(&buf); |
2508
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1650 |
uint price = gvid + i; |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1651 |
|
2508
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1652 |
if (price < NUM_PRICES) { |
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1653 |
SetPriceBaseMultiplier(price, factor); |
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1654 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1655 |
grfmsg(1, "GlobalVarChangeInfo: Price %d out of range, ignoring", price); |
2508
1926793f2977
(svn r3034) -NewGRF: Improve error checking of setting price bases.
peter1138
parents:
2506
diff
changeset
|
1656 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1657 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1658 |
|
8478
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
1659 |
case 0x09: // Cargo translation table |
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
1660 |
/* This is loaded during the reservation stage, so just skip it here. */ |
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
1661 |
/* Each entry is 4 bytes. */ |
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
1662 |
buf += 4; |
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
1663 |
break; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1664 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1665 |
case 0x0A: { // Currency display names |
4625
f365b341a330
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1666 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
f365b341a330
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1667 |
StringID newone = GetGRFStringID(_cur_grffile->grfid, grf_load_word(&buf)); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1668 |
|
4504
1c238774d1b0
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
1669 |
if ((newone != STR_UNDEFINED) && (curidx < NUM_CURRENCY)) { |
1c238774d1b0
(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.
belugas
parents:
4434
diff
changeset
|
1670 |
_currency_specs[curidx].name = newone; |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1671 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1672 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1673 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1674 |
case 0x0B: { // Currency multipliers |
4625
f365b341a330
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1675 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1676 |
uint32 rate = grf_load_dword(&buf); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1677 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1678 |
if (curidx < NUM_CURRENCY) { |
4602
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1679 |
/* TTDPatch uses a multiple of 1000 for its conversion calculations, |
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1680 |
* which OTTD does not. For this reason, divide grf value by 1000, |
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1681 |
* to be compatible */ |
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1682 |
_currency_specs[curidx].rate = rate / 1000; |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1683 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1684 |
grfmsg(1, "GlobalVarChangeInfo: Currency multipliers %d out of range, ignoring", curidx); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1685 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1686 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1687 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1688 |
case 0x0C: { // Currency options |
4625
f365b341a330
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1689 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1690 |
uint16 options = grf_load_word(&buf); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1691 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1692 |
if (curidx < NUM_CURRENCY) { |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1693 |
_currency_specs[curidx].separator = GB(options, 0, 8); |
4602
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1694 |
/* By specifying only one bit, we prevent errors, |
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1695 |
* since newgrf specs said that only 0 and 1 can be set for symbol_pos */ |
43c44f7df615
(svn r6454) -Fix(r6108) : Allow custom currency to display both prefix and suffix
belugas
parents:
4504
diff
changeset
|
1696 |
_currency_specs[curidx].symbol_pos = GB(options, 8, 1); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1697 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1698 |
grfmsg(1, "GlobalVarChangeInfo: Currency option %d out of range, ignoring", curidx); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1699 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1700 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1701 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1702 |
case 0x0D: { // Currency prefix symbol |
4625
f365b341a330
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1703 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1704 |
uint32 tempfix = grf_load_dword(&buf); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1705 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1706 |
if (curidx < NUM_CURRENCY) { |
7162
6435ada4bc34
(svn r10436) -Cleanup: Doxygenise some comments, update others, and make a few statements more consistent with everything else.
maedhros
parents:
7161
diff
changeset
|
1707 |
memcpy(_currency_specs[curidx].prefix, &tempfix, 4); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1708 |
_currency_specs[curidx].prefix[4] = 0; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1709 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1710 |
grfmsg(1, "GlobalVarChangeInfo: Currency symbol %d out of range, ignoring", curidx); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1711 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1712 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1713 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1714 |
case 0x0E: { // Currency suffix symbol |
4625
f365b341a330
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1715 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1716 |
uint32 tempfix = grf_load_dword(&buf); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1717 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1718 |
if (curidx < NUM_CURRENCY) { |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6481
diff
changeset
|
1719 |
memcpy(&_currency_specs[curidx].suffix, &tempfix, 4); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1720 |
_currency_specs[curidx].suffix[4] = 0; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1721 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1722 |
grfmsg(1, "GlobalVarChangeInfo: Currency symbol %d out of range, ignoring", curidx); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1723 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1724 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1725 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1726 |
case 0x0F: { // Euro introduction dates |
4625
f365b341a330
(svn r6485) -NewGRF Feature: Match the order of TTDPatch's currencies with those used in OTTD.
belugas
parents:
4602
diff
changeset
|
1727 |
uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1728 |
Year year_euro = grf_load_word(&buf); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1729 |
|
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1730 |
if (curidx < NUM_CURRENCY) { |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1731 |
_currency_specs[curidx].to_euro = year_euro; |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1732 |
} else { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1733 |
grfmsg(1, "GlobalVarChangeInfo: Euro intro date %d out of range, ignoring", curidx); |
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
1734 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1735 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1736 |
|
7162
6435ada4bc34
(svn r10436) -Cleanup: Doxygenise some comments, update others, and make a few statements more consistent with everything else.
maedhros
parents:
7161
diff
changeset
|
1737 |
case 0x10: // Snow line height table |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1738 |
if (numinfo > 1 || IsSnowLineSet()) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1739 |
grfmsg(1, "GlobalVarChangeInfo: The snowline can only be set once (%d)", numinfo); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1740 |
} else if (len < SNOW_LINE_MONTHS * SNOW_LINE_DAYS) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1741 |
grfmsg(1, "GlobalVarChangeInfo: Not enough entries set in the snowline table (%d)", len); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1742 |
} else { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1743 |
byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1744 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1745 |
for (uint i = 0; i < SNOW_LINE_MONTHS; i++) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1746 |
for (uint j = 0; j < SNOW_LINE_DAYS; j++) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1747 |
table[i][j] = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1748 |
} |
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1749 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1750 |
SetSnowLine(table); |
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
1751 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1752 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1753 |
|
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
1754 |
case 0x11: // GRF match for engine allocation |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
1755 |
/* This is loaded during the reservation stage, so just skip it here. */ |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
1756 |
/* Each entry is 8 bytes. */ |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
1757 |
buf += 8; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
1758 |
break; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
1759 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1760 |
default: |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1761 |
ret = CIR_UNKNOWN; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1762 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1763 |
} |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1764 |
} |
3504
bb52064dbe8a
(svn r4355) - NewGRF: Minor clean up; use the correct return type and remove extraneous brackets.
peter1138
parents:
3501
diff
changeset
|
1765 |
|
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1766 |
*bufp = buf; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1767 |
return ret; |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1768 |
} |
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
1769 |
|
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1770 |
static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, byte **bufp, int len) |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1771 |
{ |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1772 |
byte *buf = *bufp; |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1773 |
ChangeInfoResult ret = CIR_SUCCESS; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1774 |
|
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1775 |
if (cid + numinfo > NUM_CARGO) { |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1776 |
grfmsg(2, "CargoChangeInfo: Cargo type %d out of range (max %d)", cid + numinfo, NUM_CARGO - 1); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1777 |
return CIR_INVALID_ID; |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1778 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1779 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1780 |
for (int i = 0; i < numinfo; i++) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1781 |
CargoSpec *cs = &_cargo[cid + i]; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1782 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1783 |
switch (prop) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1784 |
case 0x08: /* Bit number of cargo */ |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1785 |
cs->bitnum = grf_load_byte(&buf); |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1786 |
if (cs->IsValid()) { |
9750
7114408dd1fa
(svn r13885) -Fix [FS#2168]: Var 0x7F is not feature-specific.
frosch
parents:
9746
diff
changeset
|
1787 |
cs->grffile = _cur_grffile; |
7931
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7929
diff
changeset
|
1788 |
SetBit(_cargo_mask, cid + i); |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1789 |
} else { |
7929
6c9b25842b0f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
7928
diff
changeset
|
1790 |
ClrBit(_cargo_mask, cid + i); |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1791 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1792 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1793 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1794 |
case 0x09: /* String ID for cargo type name */ |
8959
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
1795 |
cs->name = grf_load_word(&buf); |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
1796 |
_string_to_grf_mapping[&cs->name] = _cur_grffile->grfid; |
7276
16061f14665c
(svn r10606) -Fix (r8826): plural and single cargo names were mixed up.
peter1138
parents:
7240
diff
changeset
|
1797 |
break; |
16061f14665c
(svn r10606) -Fix (r8826): plural and single cargo names were mixed up.
peter1138
parents:
7240
diff
changeset
|
1798 |
|
16061f14665c
(svn r10606) -Fix (r8826): plural and single cargo names were mixed up.
peter1138
parents:
7240
diff
changeset
|
1799 |
case 0x0A: /* String for 1 unit of cargo */ |
8959
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
1800 |
cs->name_single = grf_load_word(&buf); |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
1801 |
_string_to_grf_mapping[&cs->name_single] = _cur_grffile->grfid; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1802 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1803 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1804 |
case 0x0B: |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1805 |
/* String for units of cargo. This is different in OpenTTD to TTDPatch |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1806 |
* (e.g. 10 tonnes of coal) */ |
8959
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
1807 |
cs->units_volume = grf_load_word(&buf); |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
1808 |
_string_to_grf_mapping[&cs->units_volume] = _cur_grffile->grfid; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1809 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1810 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1811 |
case 0x0C: /* String for quantity of cargo (e.g. 10 tonnes of coal) */ |
8959
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
1812 |
cs->quantifier = grf_load_word(&buf); |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
1813 |
_string_to_grf_mapping[&cs->quantifier] = _cur_grffile->grfid; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1814 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1815 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1816 |
case 0x0D: /* String for two letter cargo abbreviation */ |
8959
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
1817 |
cs->abbrev = grf_load_word(&buf); |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
1818 |
_string_to_grf_mapping[&cs->abbrev] = _cur_grffile->grfid; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1819 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1820 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1821 |
case 0x0E: /* Sprite ID for cargo icon */ |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1822 |
cs->sprite = grf_load_word(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1823 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1824 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1825 |
case 0x0F: /* Weight of one unit of cargo */ |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1826 |
cs->weight = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1827 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1828 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1829 |
case 0x10: /* Used for payment calculation */ |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1830 |
cs->transit_days[0] = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1831 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1832 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1833 |
case 0x11: /* Used for payment calculation */ |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1834 |
cs->transit_days[1] = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1835 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1836 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1837 |
case 0x12: /* Base cargo price */ |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1838 |
cs->initial_payment = grf_load_dword(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1839 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1840 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1841 |
case 0x13: /* Colour for station rating bars */ |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1842 |
cs->rating_colour = MapDOSColour(grf_load_byte(&buf)); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1843 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1844 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1845 |
case 0x14: /* Colour for cargo graph */ |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1846 |
cs->legend_colour = MapDOSColour(grf_load_byte(&buf)); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1847 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1848 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1849 |
case 0x15: /* Freight status */ |
7162
6435ada4bc34
(svn r10436) -Cleanup: Doxygenise some comments, update others, and make a few statements more consistent with everything else.
maedhros
parents:
7161
diff
changeset
|
1850 |
cs->is_freight = (grf_load_byte(&buf) != 0); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1851 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1852 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1853 |
case 0x16: /* Cargo classes */ |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1854 |
cs->classes = grf_load_word(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1855 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1856 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1857 |
case 0x17: /* Cargo label */ |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1858 |
cs->label = grf_load_dword(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1859 |
cs->label = BSWAP32(cs->label); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1860 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1861 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1862 |
case 0x18: { /* Town growth substitute type */ |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1863 |
uint8 substitute_type = grf_load_byte(&buf); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1864 |
|
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1865 |
switch (substitute_type) { |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1866 |
case 0x00: cs->town_effect = TE_PASSENGERS; break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1867 |
case 0x02: cs->town_effect = TE_MAIL; break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1868 |
case 0x05: cs->town_effect = TE_GOODS; break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1869 |
case 0x09: cs->town_effect = TE_WATER; break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1870 |
case 0x0B: cs->town_effect = TE_FOOD; break; |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1871 |
default: |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1872 |
grfmsg(1, "CargoChangeInfo: Unknown town growth substitute value %d, setting to none.", substitute_type); |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1873 |
case 0xFF: cs->town_effect = TE_NONE; break; |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1874 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1875 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1876 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1877 |
case 0x19: /* Town growth coefficient */ |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1878 |
cs->multipliertowngrowth = grf_load_word(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1879 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1880 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1881 |
case 0x1A: /* Bitmask of callbacks to use */ |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1882 |
cs->callback_mask = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1883 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1884 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1885 |
default: |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1886 |
ret = CIR_UNKNOWN; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1887 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1888 |
} |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1889 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1890 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1891 |
*bufp = buf; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1892 |
return ret; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1893 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1894 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
1895 |
|
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1896 |
static ChangeInfoResult SoundEffectChangeInfo(uint sid, int numinfo, int prop, byte **bufp, int len) |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1897 |
{ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1898 |
byte *buf = *bufp; |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1899 |
ChangeInfoResult ret = CIR_SUCCESS; |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1900 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1901 |
if (_cur_grffile->sound_offset == 0) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
1902 |
grfmsg(1, "SoundEffectChangeInfo: No effects defined, skipping"); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1903 |
return CIR_INVALID_ID; |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1904 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1905 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1906 |
for (int i = 0; i < numinfo; i++) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1907 |
uint sound = sid + i + _cur_grffile->sound_offset - GetNumOriginalSounds(); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1908 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1909 |
if (sound >= GetNumSounds()) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1910 |
grfmsg(1, "SoundEffectChangeInfo: Sound %d not defined (max %d)", sound, GetNumSounds()); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1911 |
return CIR_INVALID_ID; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1912 |
} |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1913 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1914 |
switch (prop) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1915 |
case 0x08: // Relative volume |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1916 |
GetSound(sound)->volume = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1917 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1918 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1919 |
case 0x09: // Priority |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1920 |
GetSound(sound)->priority = grf_load_byte(&buf); |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1921 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1922 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1923 |
case 0x0A: { // Override old sound |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1924 |
uint orig_sound = grf_load_byte(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1925 |
|
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1926 |
if (orig_sound >= GetNumSounds()) { |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1927 |
grfmsg(1, "SoundEffectChangeInfo: Original sound %d not defined (max %d)", orig_sound, GetNumSounds()); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1928 |
} else { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1929 |
FileEntry *newfe = GetSound(sound); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1930 |
FileEntry *oldfe = GetSound(orig_sound); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1931 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1932 |
/* Literally copy the data of the new sound over the original */ |
5024
5e98bf731469
(svn r7065) Use simple assignment instead of memcpy()
tron
parents:
5011
diff
changeset
|
1933 |
*oldfe = *newfe; |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1934 |
} |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1935 |
} break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1936 |
|
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1937 |
default: |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1938 |
ret = CIR_UNKNOWN; |
7159
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1939 |
break; |
9030d8ca51f8
(svn r10433) -Codechange: Remove FOR_EACH_OBJECT by moving the for loops in the Action 0
maedhros
parents:
7034
diff
changeset
|
1940 |
} |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1941 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1942 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1943 |
*bufp = buf; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1944 |
return ret; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1945 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
1946 |
|
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1947 |
static ChangeInfoResult IndustrytilesChangeInfo(uint indtid, int numinfo, int prop, byte **bufp, int len) |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1948 |
{ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1949 |
byte *buf = *bufp; |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1950 |
ChangeInfoResult ret = CIR_SUCCESS; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1951 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1952 |
if (indtid + numinfo > NUM_INDUSTRYTILES) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1953 |
grfmsg(1, "IndustryTilesChangeInfo: Too many industry tiles loaded (%u), max (%u). Ignoring.", indtid + numinfo, NUM_INDUSTRYTILES); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1954 |
return CIR_INVALID_ID; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1955 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1956 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1957 |
/* Allocate industry tile specs if they haven't been allocated already. */ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1958 |
if (_cur_grffile->indtspec == NULL) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1959 |
_cur_grffile->indtspec = CallocT<IndustryTileSpec*>(NUM_INDUSTRYTILES); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1960 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1961 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1962 |
for (int i = 0; i < numinfo; i++) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1963 |
IndustryTileSpec *tsp = _cur_grffile->indtspec[indtid + i]; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1964 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1965 |
if (prop != 0x08 && tsp == NULL) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1966 |
grfmsg(2, "IndustryTilesChangeInfo: Attempt to modify undefined industry tile %u. Ignoring.", indtid + i); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
1967 |
return CIR_INVALID_ID; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1968 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1969 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1970 |
switch (prop) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1971 |
case 0x08: { // Substitute industry tile type |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1972 |
IndustryTileSpec **tilespec = &_cur_grffile->indtspec[indtid + i]; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1973 |
byte subs_id = grf_load_byte(&buf); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1974 |
|
7459
1b30a380ce60
(svn r10955) -Fix: The substitute prop (0x08) of industry tiles does not behave as prop 0x08 of industry. Therefore, do not disable the old industry with value of 0xFF. Not a bug fix, just a spec compliance correction...
belugas
parents:
7431
diff
changeset
|
1975 |
if (subs_id >= NEW_INDUSTRYTILEOFFSET) { |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1976 |
/* The substitute id must be one of the original industry tile. */ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1977 |
grfmsg(2, "IndustryTilesChangeInfo: Attempt to use new industry tile %u as substitute industry tile for %u. Ignoring.", subs_id, indtid + i); |
10041
9b8ed66c3cf4
(svn r14201) -Codechange: [NewGRF] Don't continue processing an Action 0 if we didn't read the data for a property -- the data will be wrong for subsequent reads.
peter1138
parents:
10039
diff
changeset
|
1978 |
continue; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1979 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1980 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1981 |
/* Allocate space for this industry. */ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1982 |
if (*tilespec == NULL) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1983 |
int tempid; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1984 |
*tilespec = CallocT<IndustryTileSpec>(1); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1985 |
tsp = *tilespec; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1986 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1987 |
memcpy(tsp, &_industry_tile_specs[subs_id], sizeof(_industry_tile_specs[subs_id])); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1988 |
tsp->enabled = true; |
8104
cb18bacacde0
(svn r11665) -Fix: Animation informations should not be copied from original industry tile spec, while doing an action 00, industry tile, prop 08.
belugas
parents:
8103
diff
changeset
|
1989 |
|
cb18bacacde0
(svn r11665) -Fix: Animation informations should not be copied from original industry tile spec, while doing an action 00, industry tile, prop 08.
belugas
parents:
8103
diff
changeset
|
1990 |
/* A copied tile should not have the animation infos copied too. |
cb18bacacde0
(svn r11665) -Fix: Animation informations should not be copied from original industry tile spec, while doing an action 00, industry tile, prop 08.
belugas
parents:
8103
diff
changeset
|
1991 |
* The anim_state should be left untouched, though |
cb18bacacde0
(svn r11665) -Fix: Animation informations should not be copied from original industry tile spec, while doing an action 00, industry tile, prop 08.
belugas
parents:
8103
diff
changeset
|
1992 |
* It is up to the author to animate them himself */ |
cb18bacacde0
(svn r11665) -Fix: Animation informations should not be copied from original industry tile spec, while doing an action 00, industry tile, prop 08.
belugas
parents:
8103
diff
changeset
|
1993 |
tsp->anim_production = INDUSTRYTILE_NOANIM; |
cb18bacacde0
(svn r11665) -Fix: Animation informations should not be copied from original industry tile spec, while doing an action 00, industry tile, prop 08.
belugas
parents:
8103
diff
changeset
|
1994 |
tsp->anim_next = INDUSTRYTILE_NOANIM; |
cb18bacacde0
(svn r11665) -Fix: Animation informations should not be copied from original industry tile spec, while doing an action 00, industry tile, prop 08.
belugas
parents:
8103
diff
changeset
|
1995 |
|
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1996 |
tsp->grf_prop.local_id = indtid + i; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1997 |
tsp->grf_prop.subst_id = subs_id; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1998 |
tsp->grf_prop.grffile = _cur_grffile; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
1999 |
tempid = _industile_mngr.AddEntityID(indtid + i, _cur_grffile->grfid, subs_id); // pre-reserve the tile slot |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2000 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2001 |
} break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2002 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2003 |
case 0x09: { // Industry tile override |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2004 |
byte ovrid = grf_load_byte(&buf); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2005 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2006 |
/* The industry being overridden must be an original industry. */ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2007 |
if (ovrid >= NEW_INDUSTRYTILEOFFSET) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2008 |
grfmsg(2, "IndustryTilesChangeInfo: Attempt to override new industry tile %u with industry tile id %u. Ignoring.", ovrid, indtid + i); |
10041
9b8ed66c3cf4
(svn r14201) -Codechange: [NewGRF] Don't continue processing an Action 0 if we didn't read the data for a property -- the data will be wrong for subsequent reads.
peter1138
parents:
10039
diff
changeset
|
2009 |
continue; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2010 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2011 |
|
7873
9bb5874c81df
(svn r11423) -Codechange: store grfid when adding an override
glx
parents:
7831
diff
changeset
|
2012 |
_industile_mngr.Add(indtid + i, _cur_grffile->grfid, ovrid); |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2013 |
} break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2014 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2015 |
case 0x0A: // Tile acceptance |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2016 |
case 0x0B: |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2017 |
case 0x0C: { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2018 |
uint16 acctp = grf_load_word(&buf); |
7988
fa2cce262aa9
(svn r11544) -Fix [FS#1501]: revert r11453 as it translated cargo when it should not
glx
parents:
7978
diff
changeset
|
2019 |
tsp->accepts_cargo[prop - 0x0A] = GetCargoTranslation(GB(acctp, 0, 8), _cur_grffile); |
7631
7fc3e541dad6
(svn r11162) -Fix: Acceptance is not a cargo, but rather a level of... acceptance :) So don't need to get cargo name out of it (glx)
belugas
parents:
7630
diff
changeset
|
2020 |
tsp->acceptance[prop - 0x0A] = GB(acctp, 8, 8); |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2021 |
} break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2022 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2023 |
case 0x0D: // Land shape flags |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2024 |
tsp->slopes_refused = (Slope)grf_load_byte(&buf); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2025 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2026 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2027 |
case 0x0E: // Callback flags |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2028 |
tsp->callback_flags = grf_load_byte(&buf); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2029 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2030 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2031 |
case 0x0F: // Animation information |
7229
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7217
diff
changeset
|
2032 |
tsp->animation_info = grf_load_word(&buf); |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2033 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2034 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2035 |
case 0x10: // Animation speed |
7229
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7217
diff
changeset
|
2036 |
tsp->animation_speed = grf_load_byte(&buf); |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2037 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2038 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2039 |
case 0x11: // Triggers for callback 25 |
7229
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7217
diff
changeset
|
2040 |
tsp->animation_triggers = grf_load_byte(&buf); |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2041 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2042 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2043 |
case 0x12: // Special flags |
7229
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7217
diff
changeset
|
2044 |
tsp->animation_special_flags = grf_load_byte(&buf); |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2045 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2046 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2047 |
default: |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2048 |
ret = CIR_UNKNOWN; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2049 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2050 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2051 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2052 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2053 |
*bufp = buf; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2054 |
return ret; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2055 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2056 |
|
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2057 |
static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, byte **bufp, int len) |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2058 |
{ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2059 |
byte *buf = *bufp; |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2060 |
ChangeInfoResult ret = CIR_SUCCESS; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2061 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2062 |
if (indid + numinfo > NUM_INDUSTRYTYPES) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2063 |
grfmsg(1, "IndustriesChangeInfo: Too many industries loaded (%u), max (%u). Ignoring.", indid + numinfo, NUM_INDUSTRYTYPES); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2064 |
return CIR_INVALID_ID; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2065 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2066 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2067 |
grfmsg(1, "IndustriesChangeInfo: newid %u", indid); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2068 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2069 |
/* Allocate industry specs if they haven't been allocated already. */ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2070 |
if (_cur_grffile->industryspec == NULL) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2071 |
_cur_grffile->industryspec = CallocT<IndustrySpec*>(NUM_INDUSTRYTYPES); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2072 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2073 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2074 |
for (int i = 0; i < numinfo; i++) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2075 |
IndustrySpec *indsp = _cur_grffile->industryspec[indid + i]; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2076 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2077 |
if (prop != 0x08 && indsp == NULL) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2078 |
grfmsg(2, "IndustriesChangeInfo: Attempt to modify undefined industry %u. Ignoring.", indid + i); |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2079 |
return CIR_INVALID_ID; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2080 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2081 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2082 |
switch (prop) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2083 |
case 0x08: { // Substitute industry type |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2084 |
IndustrySpec **indspec = &_cur_grffile->industryspec[indid + i]; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2085 |
byte subs_id = grf_load_byte(&buf); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2086 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2087 |
if (subs_id == 0xFF) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2088 |
/* Instead of defining a new industry, a substitute industry id |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2089 |
* of 0xFF disables the old industry with the current id. */ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2090 |
_industry_specs[indid + i].enabled = false; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2091 |
continue; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2092 |
} else if (subs_id >= NEW_INDUSTRYOFFSET) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2093 |
/* The substitute id must be one of the original industry. */ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2094 |
grfmsg(2, "_industry_specs: Attempt to use new industry %u as substitute industry for %u. Ignoring.", subs_id, indid + i); |
10041
9b8ed66c3cf4
(svn r14201) -Codechange: [NewGRF] Don't continue processing an Action 0 if we didn't read the data for a property -- the data will be wrong for subsequent reads.
peter1138
parents:
10039
diff
changeset
|
2095 |
continue; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2096 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2097 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2098 |
/* Allocate space for this industry. |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2099 |
* Only need to do it once. If ever it is called again, it should not |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2100 |
* do anything */ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2101 |
if (*indspec == NULL) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2102 |
*indspec = CallocT<IndustrySpec>(1); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2103 |
indsp = *indspec; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2104 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2105 |
memcpy(indsp, &_origin_industry_specs[subs_id], sizeof(_industry_specs[subs_id])); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2106 |
indsp->enabled = true; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2107 |
indsp->grf_prop.local_id = indid + i; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2108 |
indsp->grf_prop.subst_id = subs_id; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2109 |
indsp->grf_prop.grffile = _cur_grffile; |
7716
2d526433aa95
(svn r11251) -Fix[FS#1318]: Newindustries must not rely on the old check placement functions. It is the the job of callbacks. Therefor, upon substitution, disable the said check.
belugas
parents:
7705
diff
changeset
|
2110 |
/* If the grf industry needs to check its surounding upon creation, it should |
2d526433aa95
(svn r11251) -Fix[FS#1318]: Newindustries must not rely on the old check placement functions. It is the the job of callbacks. Therefor, upon substitution, disable the said check.
belugas
parents:
7705
diff
changeset
|
2111 |
* rely on callbacks, not on the original placement functions */ |
2d526433aa95
(svn r11251) -Fix[FS#1318]: Newindustries must not rely on the old check placement functions. It is the the job of callbacks. Therefor, upon substitution, disable the said check.
belugas
parents:
7705
diff
changeset
|
2112 |
indsp->check_proc = CHECK_NOTHING; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2113 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2114 |
} break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2115 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2116 |
case 0x09: { // Industry type override |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2117 |
byte ovrid = grf_load_byte(&buf); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2118 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2119 |
/* The industry being overridden must be an original industry. */ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2120 |
if (ovrid >= NEW_INDUSTRYOFFSET) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2121 |
grfmsg(2, "IndustriesChangeInfo: Attempt to override new industry %u with industry id %u. Ignoring.", ovrid, indid + i); |
10041
9b8ed66c3cf4
(svn r14201) -Codechange: [NewGRF] Don't continue processing an Action 0 if we didn't read the data for a property -- the data will be wrong for subsequent reads.
peter1138
parents:
10039
diff
changeset
|
2122 |
continue; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2123 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2124 |
indsp->grf_prop.override = ovrid; |
7873
9bb5874c81df
(svn r11423) -Codechange: store grfid when adding an override
glx
parents:
7831
diff
changeset
|
2125 |
_industry_mngr.Add(indid + i, _cur_grffile->grfid, ovrid); |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2126 |
} break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2127 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2128 |
case 0x0A: { // Set industry layout(s) |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2129 |
indsp->num_table = grf_load_byte(&buf); // Number of layaouts |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2130 |
uint32 defsize = grf_load_dword(&buf); // Total size of the definition |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2131 |
IndustryTileTable **tile_table = CallocT<IndustryTileTable*>(indsp->num_table); // Table with tiles to compose an industry |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2132 |
IndustryTileTable *itt = CallocT<IndustryTileTable>(defsize); // Temporary array to read the tile layouts from the GRF |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2133 |
int size; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2134 |
IndustryTileTable *copy_from; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2135 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2136 |
for (byte j = 0; j < indsp->num_table; j++) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2137 |
for (int k = 0;; k++) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2138 |
itt[k].ti.x = grf_load_byte(&buf); // Offsets from northermost tile |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2139 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2140 |
if (itt[k].ti.x == 0xFE && k == 0) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2141 |
/* This means we have to borrow the layout from an old industry */ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2142 |
IndustryType type = grf_load_byte(&buf); //industry holding required layout |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2143 |
byte laynbr = grf_load_byte(&buf); //layout number to borrow |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2144 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2145 |
copy_from = (IndustryTileTable*)_origin_industry_specs[type].table[laynbr]; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2146 |
for (size = 1;; size++) { |
7746 | 2147 |
if (copy_from[size - 1].ti.x == -0x80 && copy_from[size - 1].ti.y == 0) break; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2148 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2149 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2150 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2151 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2152 |
itt[k].ti.y = grf_load_byte(&buf); // Or table definition finalisation |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2153 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2154 |
if (itt[k].ti.x == 0 && itt[k].ti.y == 0x80) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2155 |
/* Not the same terminator. The one we are using is rather |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2156 |
x= -80, y = x . So, adjust it. */ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2157 |
itt[k].ti.x = -0x80; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2158 |
itt[k].ti.y = 0; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2159 |
itt[k].gfx = 0; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2160 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2161 |
size = k + 1; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2162 |
copy_from = itt; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2163 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2164 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2165 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2166 |
itt[k].gfx = grf_load_byte(&buf); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2167 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2168 |
if (itt[k].gfx == 0xFE) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2169 |
/* Use a new tile from this GRF */ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2170 |
int local_tile_id = grf_load_word(&buf); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2171 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2172 |
/* Read the ID from the _industile_mngr. */ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2173 |
int tempid = _industile_mngr.GetID(local_tile_id, _cur_grffile->grfid); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2174 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2175 |
if (tempid == INVALID_INDUSTRYTILE) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2176 |
grfmsg(2, "IndustriesChangeInfo: Attempt to use industry tile %u with industry id %u, not yet defined. Ignoring.", local_tile_id, indid); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2177 |
} else { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2178 |
/* Declared as been valid, can be used */ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2179 |
itt[k].gfx = tempid; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2180 |
size = k + 1; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2181 |
copy_from = itt; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2182 |
} |
7630
e6f5a3dbd443
(svn r11161) -Fix: Allow to transform coordinates in negative ones when gfx of 0xFF allows it
belugas
parents:
7620
diff
changeset
|
2183 |
} else if (itt[k].gfx == 0xFF) { |
e6f5a3dbd443
(svn r11161) -Fix: Allow to transform coordinates in negative ones when gfx of 0xFF allows it
belugas
parents:
7620
diff
changeset
|
2184 |
itt[k].ti.x = (int8)GB(itt[k].ti.x, 0, 8); |
e6f5a3dbd443
(svn r11161) -Fix: Allow to transform coordinates in negative ones when gfx of 0xFF allows it
belugas
parents:
7620
diff
changeset
|
2185 |
itt[k].ti.y = (int8)GB(itt[k].ti.y, 0, 8); |
7633
9a6d9c982348
(svn r11164) -Fix(r11161): a rogue space roaming in the night... removed
belugas
parents:
7631
diff
changeset
|
2186 |
} |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2187 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2188 |
tile_table[j] = CallocT<IndustryTileTable>(size); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2189 |
memcpy(tile_table[j], copy_from, sizeof(*copy_from) * size); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2190 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2191 |
/* Install final layout construction in the industry spec */ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2192 |
indsp->table = tile_table; |
7931
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7929
diff
changeset
|
2193 |
SetBit(indsp->cleanup_flag, 1); |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2194 |
free(itt); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2195 |
} break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2196 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2197 |
case 0x0B: // Industry production flags |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2198 |
indsp->life_type = (IndustryLifeType)grf_load_byte(&buf); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2199 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2200 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2201 |
case 0x0C: // Industry closure message |
8959
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
2202 |
indsp->closure_text = grf_load_word(&buf); |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
2203 |
_string_to_grf_mapping[&indsp->closure_text] = _cur_grffile->grfid; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2204 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2205 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2206 |
case 0x0D: // Production increase message |
8959
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
2207 |
indsp->production_up_text = grf_load_word(&buf); |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
2208 |
_string_to_grf_mapping[&indsp->production_up_text] = _cur_grffile->grfid; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2209 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2210 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2211 |
case 0x0E: // Production decrease message |
8959
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
2212 |
indsp->production_down_text = grf_load_word(&buf); |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
2213 |
_string_to_grf_mapping[&indsp->production_down_text] = _cur_grffile->grfid; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2214 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2215 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2216 |
case 0x0F: // Fund cost multiplier |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2217 |
indsp->cost_multiplier = grf_load_byte(&buf); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2218 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2219 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2220 |
case 0x10: // Production cargo types |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2221 |
for (byte j = 0; j < 2; j++) { |
7988
fa2cce262aa9
(svn r11544) -Fix [FS#1501]: revert r11453 as it translated cargo when it should not
glx
parents:
7978
diff
changeset
|
2222 |
indsp->produced_cargo[j] = GetCargoTranslation(grf_load_byte(&buf), _cur_grffile); |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2223 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2224 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2225 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2226 |
case 0x11: // Acceptance cargo types |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2227 |
for (byte j = 0; j < 3; j++) { |
7988
fa2cce262aa9
(svn r11544) -Fix [FS#1501]: revert r11453 as it translated cargo when it should not
glx
parents:
7978
diff
changeset
|
2228 |
indsp->accepts_cargo[j] = GetCargoTranslation(grf_load_byte(&buf), _cur_grffile); |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2229 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2230 |
grf_load_byte(&buf); // Unnused, eat it up |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2231 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2232 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2233 |
case 0x12: // Production multipliers |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2234 |
case 0x13: |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2235 |
indsp->production_rate[prop - 0x12] = grf_load_byte(&buf); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2236 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2237 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2238 |
case 0x14: // Minimal amount of cargo distributed |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2239 |
indsp->minimal_cargo = grf_load_byte(&buf); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2240 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2241 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2242 |
case 0x15: { // Random sound effects |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2243 |
indsp->number_of_sounds = grf_load_byte(&buf); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2244 |
uint8 *sounds = MallocT<uint8>(indsp->number_of_sounds); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2245 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2246 |
for (uint8 j = 0; j < indsp->number_of_sounds; j++) sounds[j] = grf_load_byte(&buf); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2247 |
indsp->random_sounds = sounds; |
7931
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7929
diff
changeset
|
2248 |
SetBit(indsp->cleanup_flag, 0); |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2249 |
} break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2250 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2251 |
case 0x16: // Conflicting industry types |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2252 |
for (byte j = 0; j < 3; j++) indsp->conflicting[j] = grf_load_byte(&buf); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2253 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2254 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2255 |
case 0x17: // Probability in random game |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
2256 |
indsp->appear_creation[_settings_game.game_creation.landscape] = grf_load_byte(&buf); |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2257 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2258 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2259 |
case 0x18: // Probability during gameplay |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
2260 |
indsp->appear_ingame[_settings_game.game_creation.landscape] = grf_load_byte(&buf); |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2261 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2262 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2263 |
case 0x19: // Map color |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2264 |
indsp->map_colour = MapDOSColour(grf_load_byte(&buf)); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2265 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2266 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2267 |
case 0x1A: // Special industry flags to define special behavior |
7757 | 2268 |
indsp->behaviour = (IndustryBehaviour)grf_load_dword(&buf); |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2269 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2270 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2271 |
case 0x1B: // New industry text ID |
8959
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
2272 |
indsp->new_industry_text = grf_load_word(&buf); |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
2273 |
_string_to_grf_mapping[&indsp->new_industry_text] = _cur_grffile->grfid; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2274 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2275 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2276 |
case 0x1C: // Input cargo multipliers for the three input cargo types |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2277 |
case 0x1D: |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2278 |
case 0x1E: { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2279 |
uint32 multiples = grf_load_dword(&buf); |
8969
6d1c74e0e2cd
(svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents:
8959
diff
changeset
|
2280 |
indsp->input_cargo_multiplier[prop - 0x1C][0] = GB(multiples, 0, 15); |
6d1c74e0e2cd
(svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents:
8959
diff
changeset
|
2281 |
indsp->input_cargo_multiplier[prop - 0x1C][1] = GB(multiples, 15, 15); |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2282 |
} break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2283 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2284 |
case 0x1F: // Industry name |
8959
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
2285 |
indsp->name = grf_load_word(&buf); |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
2286 |
_string_to_grf_mapping[&indsp->name] = _cur_grffile->grfid; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2287 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2288 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2289 |
case 0x20: // Prospecting success chance |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2290 |
indsp->prospecting_chance = grf_load_dword(&buf); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2291 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2292 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2293 |
case 0x21: // Callback flags |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2294 |
case 0x22: { // Callback additional flags |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2295 |
byte aflag = grf_load_byte(&buf); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2296 |
SB(indsp->callback_flags, (prop - 0x21) * 8, 8, aflag); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2297 |
} break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2298 |
|
7978
c74fc8173339
(svn r11534) -Feature(newgrf): Implement property 23h for Industries.
belugas
parents:
7954
diff
changeset
|
2299 |
case 0x23: // removal cost multiplier |
c74fc8173339
(svn r11534) -Feature(newgrf): Implement property 23h for Industries.
belugas
parents:
7954
diff
changeset
|
2300 |
indsp->removal_cost_multiplier = grf_load_dword(&buf); |
c74fc8173339
(svn r11534) -Feature(newgrf): Implement property 23h for Industries.
belugas
parents:
7954
diff
changeset
|
2301 |
break; |
c74fc8173339
(svn r11534) -Feature(newgrf): Implement property 23h for Industries.
belugas
parents:
7954
diff
changeset
|
2302 |
|
8470
ea11349a25ed
(svn r12041) -Codechange: Add the loader and the property for action 00 industries, prop 24, nearby station name.
belugas
parents:
8449
diff
changeset
|
2303 |
case 0x24: // name for nearby station |
8959
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
2304 |
indsp->station_name = grf_load_word(&buf); |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
2305 |
_string_to_grf_mapping[&indsp->station_name] = _cur_grffile->grfid; |
8470
ea11349a25ed
(svn r12041) -Codechange: Add the loader and the property for action 00 industries, prop 24, nearby station name.
belugas
parents:
8449
diff
changeset
|
2306 |
break; |
ea11349a25ed
(svn r12041) -Codechange: Add the loader and the property for action 00 industries, prop 24, nearby station name.
belugas
parents:
8449
diff
changeset
|
2307 |
|
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2308 |
default: |
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2309 |
ret = CIR_UNKNOWN; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2310 |
break; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2311 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2312 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2313 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2314 |
*bufp = buf; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2315 |
return ret; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2316 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2317 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2318 |
/* Action 0x00 */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
2319 |
static void FeatureChangeInfo(byte *buf, size_t len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2320 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2321 |
byte *bufend = buf + len; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2322 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2323 |
/* <00> <feature> <num-props> <num-info> <id> (<property <new-info>)... |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2324 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2325 |
* B feature 0, 1, 2 or 3 for trains, road vehicles, ships or planes |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2326 |
* 4 for defining new train station sets |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2327 |
* B num-props how many properties to change per vehicle/station |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2328 |
* B num-info how many vehicles/stations to change |
7892
3e3e1c093a56
(svn r11443) -Fix: [NewGRF] Action 0 <id> is an extended byte
glx
parents:
7882
diff
changeset
|
2329 |
* E id ID of first vehicle/station to change, if num-info is |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2330 |
* greater than one, this one and the following |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2331 |
* vehicles/stations will be changed |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2332 |
* B property what property to change, depends on the feature |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2333 |
* V new-info new bytes of info (variable size; depends on properties) */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2334 |
/* TODO: Bridges, town houses. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2335 |
|
2438
f0bf4adbd620
(svn r2964) Fix: newgrf: Include missing grf feature canal.
peter1138
parents:
2421
diff
changeset
|
2336 |
static const VCI_Handler handler[] = { |
3825 | 2337 |
/* GSF_TRAIN */ RailVehicleChangeInfo, |
2338 |
/* GSF_ROAD */ RoadVehicleChangeInfo, |
|
2339 |
/* GSF_SHIP */ ShipVehicleChangeInfo, |
|
2340 |
/* GSF_AIRCRAFT */ AircraftVehicleChangeInfo, |
|
2341 |
/* GSF_STATION */ StationChangeInfo, |
|
8372
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
2342 |
/* GSF_CANAL */ CanalChangeInfo, |
3825 | 2343 |
/* GSF_BRIDGE */ BridgeChangeInfo, |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2344 |
/* GSF_TOWNHOUSE */ TownHouseChangeInfo, |
8478
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2345 |
/* GSF_GLOBALVAR */ GlobalVarChangeInfo, |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2346 |
/* GSF_INDUSTRYTILES */IndustrytilesChangeInfo, |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
2347 |
/* GSF_INDUSTRIES */ IndustriesChangeInfo, |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2348 |
/* GSF_CARGOS */ NULL, /* Cargo is handled during reservation */ |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
2349 |
/* GSF_SOUNDFX */ SoundEffectChangeInfo, |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2350 |
}; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2351 |
|
5590
6a0c2739e124
(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:
5587
diff
changeset
|
2352 |
if (!check_length(len, 6, "FeatureChangeInfo")) return; |
3714
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
2353 |
buf++; |
6281 | 2354 |
uint8 feature = grf_load_byte(&buf); |
2355 |
uint8 numprops = grf_load_byte(&buf); |
|
6288
f8103e0d58ba
(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:
6284
diff
changeset
|
2356 |
uint numinfo = grf_load_byte(&buf); |
7892
3e3e1c093a56
(svn r11443) -Fix: [NewGRF] Action 0 <id> is an extended byte
glx
parents:
7882
diff
changeset
|
2357 |
uint engine = grf_load_extended(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2358 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2359 |
grfmsg(6, "FeatureChangeInfo: feature %d, %d properties, to apply to %d+%d", |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2360 |
feature, numprops, engine, numinfo); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2361 |
|
2440
d0c69700c72e
(svn r2966) Fix: newgrf: Replace special case with a check for the existence of a handler in VehicleChangeInfo.
peter1138
parents:
2439
diff
changeset
|
2362 |
if (feature >= lengthof(handler) || handler[feature] == NULL) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2363 |
grfmsg(1, "FeatureChangeInfo: Unsupported feature %d, skipping", feature); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2364 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2365 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2366 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2367 |
while (numprops-- && buf < bufend) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2368 |
uint8 prop = grf_load_byte(&buf); |
10038
bff6d78e3b37
(svn r14198) -Codechange: [NewGRF] Simplify handling of common vehicle properties.
peter1138
parents:
10032
diff
changeset
|
2369 |
|
10043
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2370 |
ChangeInfoResult cir = handler[feature](engine, numinfo, prop, &buf, bufend - buf); |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2371 |
switch (cir) { |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2372 |
case CIR_SUCCESS: |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2373 |
break; |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2374 |
|
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2375 |
case CIR_UNHANDLED: |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2376 |
grfmsg(1, "FeatureChangeInfo: Ignoring property 0x%02X of feature 0x%02X (not implemented)", prop, feature); |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2377 |
break; |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2378 |
|
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2379 |
case CIR_UNKNOWN: |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2380 |
grfmsg(0, "FeatureChangeInfo: Unknown property 0x%02X of feature 0x%02X, disabling", prop, feature); |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2381 |
/* Fall through */ |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2382 |
|
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2383 |
case CIR_INVALID_ID: |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2384 |
/* No debug message for an invalid ID, as it has already been output */ |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2385 |
_skip_sprites = -1; |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2386 |
_cur_grfconfig->status = GCS_DISABLED; |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2387 |
_cur_grfconfig->error = CallocT<GRFError>(1); |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2388 |
_cur_grfconfig->error->severity = STR_NEWGRF_ERROR_MSG_FATAL; |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2389 |
_cur_grfconfig->error->message = (cir == CIR_INVALID_ID) ? STR_NEWGRF_ERROR_INVALID_ID : STR_NEWGRF_ERROR_UNKNOWN_PROPERTY; |
7f8f7df729d3
(svn r14203) -Codechange: [NewGRF] Disable a GRF if it contains an unknown property, or tries to assign an invalid ID.
peter1138
parents:
10042
diff
changeset
|
2390 |
return; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2391 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2392 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2393 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2394 |
|
5525
c4aadd23c749
(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:
5502
diff
changeset
|
2395 |
/* Action 0x00 (GLS_SAFETYSCAN) */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
2396 |
static void SafeChangeInfo(byte *buf, size_t len) |
5525
c4aadd23c749
(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:
5502
diff
changeset
|
2397 |
{ |
5590
6a0c2739e124
(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:
5587
diff
changeset
|
2398 |
if (!check_length(len, 6, "SafeChangeInfo")) return; |
5525
c4aadd23c749
(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:
5502
diff
changeset
|
2399 |
buf++; |
6281 | 2400 |
uint8 feature = grf_load_byte(&buf); |
2401 |
uint8 numprops = grf_load_byte(&buf); |
|
7892
3e3e1c093a56
(svn r11443) -Fix: [NewGRF] Action 0 <id> is an extended byte
glx
parents:
7882
diff
changeset
|
2402 |
grf_load_byte(&buf); // num-info |
3e3e1c093a56
(svn r11443) -Fix: [NewGRF] Action 0 <id> is an extended byte
glx
parents:
7882
diff
changeset
|
2403 |
grf_load_extended(&buf); // id |
5525
c4aadd23c749
(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:
5502
diff
changeset
|
2404 |
|
c4aadd23c749
(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:
5502
diff
changeset
|
2405 |
if (feature == GSF_BRIDGE && numprops == 1) { |
c4aadd23c749
(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:
5502
diff
changeset
|
2406 |
uint8 prop = grf_load_byte(&buf); |
c4aadd23c749
(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:
5502
diff
changeset
|
2407 |
/* Bridge property 0x0D is redefinition of sprite layout tables, which |
c4aadd23c749
(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:
5502
diff
changeset
|
2408 |
* is considered safe. */ |
c4aadd23c749
(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:
5502
diff
changeset
|
2409 |
if (prop == 0x0D) return; |
c4aadd23c749
(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:
5502
diff
changeset
|
2410 |
} |
c4aadd23c749
(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:
5502
diff
changeset
|
2411 |
|
7931
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7929
diff
changeset
|
2412 |
SetBit(_cur_grfconfig->flags, GCF_UNSAFE); |
5525
c4aadd23c749
(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:
5502
diff
changeset
|
2413 |
|
c4aadd23c749
(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:
5502
diff
changeset
|
2414 |
/* Skip remainder of GRF */ |
c4aadd23c749
(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:
5502
diff
changeset
|
2415 |
_skip_sprites = -1; |
c4aadd23c749
(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:
5502
diff
changeset
|
2416 |
} |
c4aadd23c749
(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:
5502
diff
changeset
|
2417 |
|
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2418 |
/* Action 0x00 (GLS_RESERVE) */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
2419 |
static void ReserveChangeInfo(byte *buf, size_t len) |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2420 |
{ |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2421 |
byte *bufend = buf + len; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2422 |
|
8478
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2423 |
if (!check_length(len, 6, "ReserveChangeInfo")) return; |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2424 |
buf++; |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2425 |
uint8 feature = grf_load_byte(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2426 |
|
7941
2cb6dd3c46ee
(svn r11494) -Fix [FS#1461] (r11450): cargo translation table was now loaded too late ;)
glx
parents:
7931
diff
changeset
|
2427 |
if (feature != GSF_CARGOS && feature != GSF_GLOBALVAR) return; |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2428 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2429 |
uint8 numprops = grf_load_byte(&buf); |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2430 |
uint8 numinfo = grf_load_byte(&buf); |
7892
3e3e1c093a56
(svn r11443) -Fix: [NewGRF] Action 0 <id> is an extended byte
glx
parents:
7882
diff
changeset
|
2431 |
uint8 index = grf_load_extended(&buf); |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2432 |
|
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2433 |
while (numprops-- && buf < bufend) { |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2434 |
uint8 prop = grf_load_byte(&buf); |
7941
2cb6dd3c46ee
(svn r11494) -Fix [FS#1461] (r11450): cargo translation table was now loaded too late ;)
glx
parents:
7931
diff
changeset
|
2435 |
bool ignoring = false; |
2cb6dd3c46ee
(svn r11494) -Fix [FS#1461] (r11450): cargo translation table was now loaded too late ;)
glx
parents:
7931
diff
changeset
|
2436 |
|
2cb6dd3c46ee
(svn r11494) -Fix [FS#1461] (r11450): cargo translation table was now loaded too late ;)
glx
parents:
7931
diff
changeset
|
2437 |
switch (feature) { |
2cb6dd3c46ee
(svn r11494) -Fix [FS#1461] (r11450): cargo translation table was now loaded too late ;)
glx
parents:
7931
diff
changeset
|
2438 |
default: NOT_REACHED(); |
2cb6dd3c46ee
(svn r11494) -Fix [FS#1461] (r11450): cargo translation table was now loaded too late ;)
glx
parents:
7931
diff
changeset
|
2439 |
case GSF_CARGOS: |
2cb6dd3c46ee
(svn r11494) -Fix [FS#1461] (r11450): cargo translation table was now loaded too late ;)
glx
parents:
7931
diff
changeset
|
2440 |
ignoring = CargoChangeInfo(index, numinfo, prop, &buf, bufend - buf); |
2cb6dd3c46ee
(svn r11494) -Fix [FS#1461] (r11450): cargo translation table was now loaded too late ;)
glx
parents:
7931
diff
changeset
|
2441 |
break; |
2cb6dd3c46ee
(svn r11494) -Fix [FS#1461] (r11450): cargo translation table was now loaded too late ;)
glx
parents:
7931
diff
changeset
|
2442 |
case GSF_GLOBALVAR: |
8478
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2443 |
switch (prop) { |
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2444 |
case 0x09: // Cargo Translation Table |
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2445 |
if (index != 0) { |
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2446 |
grfmsg(1, "ReserveChangeInfo: Cargo translation table must start at zero"); |
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2447 |
return; |
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2448 |
} |
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2449 |
|
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2450 |
free(_cur_grffile->cargo_list); |
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2451 |
_cur_grffile->cargo_max = numinfo; |
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2452 |
_cur_grffile->cargo_list = MallocT<CargoLabel>(numinfo); |
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2453 |
|
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2454 |
for (uint i = 0; i < numinfo; i++) { |
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2455 |
CargoLabel cl = grf_load_dword(&buf); |
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2456 |
_cur_grffile->cargo_list[i] = BSWAP32(cl); |
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2457 |
} |
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2458 |
break; |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
2459 |
|
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
2460 |
case 0x11: // GRF match for engine allocation |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
2461 |
for (uint i = 0; i < numinfo; i++) { |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
2462 |
uint32 s = grf_load_dword(&buf); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
2463 |
uint32 t = grf_load_dword(&buf); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
2464 |
SetNewGRFOverride(s, t); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
2465 |
} |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
2466 |
break; |
8478
e6ccfefffc6d
(svn r12052) -Fix [FS#1737] (r11494): The cargo translation table was loaded at the right time, but all the other global variables were now loaded too early. ;)
maedhros
parents:
8470
diff
changeset
|
2467 |
} |
7941
2cb6dd3c46ee
(svn r11494) -Fix [FS#1461] (r11450): cargo translation table was now loaded too late ;)
glx
parents:
7931
diff
changeset
|
2468 |
break; |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2469 |
} |
7941
2cb6dd3c46ee
(svn r11494) -Fix [FS#1461] (r11450): cargo translation table was now loaded too late ;)
glx
parents:
7931
diff
changeset
|
2470 |
|
2cb6dd3c46ee
(svn r11494) -Fix [FS#1461] (r11450): cargo translation table was now loaded too late ;)
glx
parents:
7931
diff
changeset
|
2471 |
if (ignoring) grfmsg(2, "ReserveChangeInfo: Ignoring property 0x%02X (not implemented)", prop); |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2472 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2473 |
} |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
2474 |
|
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2475 |
/** |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2476 |
* Creates a spritegroup representing a callback result |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2477 |
* @param value The value that was used to represent this callback result |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2478 |
* @return A spritegroup representing that callback result |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2479 |
*/ |
4893
000692659d8c
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
2480 |
static const SpriteGroup* NewCallBackResultSpriteGroup(uint16 value) |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2481 |
{ |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
2482 |
SpriteGroup *group = AllocateSpriteGroup(); |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2483 |
|
2488
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
2484 |
group->type = SGT_CALLBACK; |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2485 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2486 |
/* Old style callback results have the highest byte 0xFF so signify it is a callback result |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2487 |
* New style ones only have the highest bit set (allows 15-bit results, instead of just 8) */ |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2488 |
if ((value >> 8) == 0xFF) { |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2489 |
value &= ~0xFF00; |
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2490 |
} else { |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2491 |
value &= ~0x8000; |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
2492 |
} |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2493 |
|
2488
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
2494 |
group->g.callback.result = value; |
1883
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2495 |
|
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2496 |
return group; |
ad68cd0a0a25
(svn r2389) - Feature: [newgrf] Implement the mechanism for handling newgrf callbacks.
hackykid
parents:
1873
diff
changeset
|
2497 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2498 |
|
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2499 |
/** |
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2500 |
* Creates a spritegroup representing a sprite number result. |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6479
diff
changeset
|
2501 |
* @param sprite The sprite number. |
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6479
diff
changeset
|
2502 |
* @param num_sprites The number of sprites per set. |
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2503 |
* @return A spritegroup representing the sprite number result. |
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2504 |
*/ |
4893
000692659d8c
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
2505 |
static const SpriteGroup* NewResultSpriteGroup(SpriteID sprite, byte num_sprites) |
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2506 |
{ |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
2507 |
SpriteGroup *group = AllocateSpriteGroup(); |
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2508 |
group->type = SGT_RESULT; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2509 |
group->g.result.sprite = sprite; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2510 |
group->g.result.num_sprites = num_sprites; |
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2511 |
return group; |
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2512 |
} |
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2513 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2514 |
/* Action 0x01 */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
2515 |
static void NewSpriteSet(byte *buf, size_t len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2516 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2517 |
/* <01> <feature> <num-sets> <num-ent> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2518 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2519 |
* B feature feature to define sprites for |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2520 |
* 0, 1, 2, 3: veh-type, 4: train stations |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2521 |
* B num-sets number of sprite sets |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2522 |
* E num-ent how many entries per sprite set |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2523 |
* For vehicles, this is the number of different |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2524 |
* vehicle directions in each sprite set |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2525 |
* Set num-dirs=8, unless your sprites are symmetric. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2526 |
* In that case, use num-dirs=4. |
6281 | 2527 |
*/ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2528 |
|
5590
6a0c2739e124
(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:
5587
diff
changeset
|
2529 |
if (!check_length(len, 4, "NewSpriteSet")) return; |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
2530 |
buf++; |
6281 | 2531 |
uint8 feature = grf_load_byte(&buf); |
2532 |
uint8 num_sets = grf_load_byte(&buf); |
|
2533 |
uint16 num_ents = grf_load_extended(&buf); |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2534 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2535 |
_cur_grffile->spriteset_start = _cur_spriteid; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2536 |
_cur_grffile->spriteset_feature = feature; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2537 |
_cur_grffile->spriteset_numsets = num_sets; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2538 |
_cur_grffile->spriteset_numents = num_ents; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2539 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2540 |
grfmsg(7, "New sprite set at %d of type %d, consisting of %d sets with %d views each (total %d)", |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2541 |
_cur_spriteid, feature, num_sets, num_ents, num_sets * num_ents |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2542 |
); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2543 |
|
8282
d9f5096a5d54
(svn r11846) -Fix [FS#1651]: implicit conversion from unsigned to signed int caused compilation failure with MSVC.
peter1138
parents:
8270
diff
changeset
|
2544 |
for (int i = 0; i < num_sets * num_ents; i++) { |
7953
db4cd9ef0efc
(svn r11509) -Fix: off-by-one error in some sprite numbers; increase sprite number counter before loading the next sprite instead of after doing so.
rubidium
parents:
7941
diff
changeset
|
2545 |
_nfo_line++; |
6908
6b1324d7a2c9
(svn r10157) -Fix: use as indentified for PNGs, the place of the image as it was in the grf, not the internal SpriteID
truelight
parents:
6894
diff
changeset
|
2546 |
LoadNextSprite(_cur_spriteid++, _file_index, _nfo_line); |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
2547 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2548 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2549 |
|
6576
3a7cc737dec8
(svn r9790) -Codechange: [NewGRF] Skip action 1 sprites in all stages except activation. This also cleans up some special-case handling of the sprites. Actions 1 and 2 are now not considered unsafe, as an Action 3 (which is unsafe) is required for them.
peter1138
parents:
6570
diff
changeset
|
2550 |
/* Action 0x01 (SKIP) */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
2551 |
static void SkipAct1(byte *buf, size_t len) |
6576
3a7cc737dec8
(svn r9790) -Codechange: [NewGRF] Skip action 1 sprites in all stages except activation. This also cleans up some special-case handling of the sprites. Actions 1 and 2 are now not considered unsafe, as an Action 3 (which is unsafe) is required for them.
peter1138
parents:
6570
diff
changeset
|
2552 |
{ |
3a7cc737dec8
(svn r9790) -Codechange: [NewGRF] Skip action 1 sprites in all stages except activation. This also cleans up some special-case handling of the sprites. Actions 1 and 2 are now not considered unsafe, as an Action 3 (which is unsafe) is required for them.
peter1138
parents:
6570
diff
changeset
|
2553 |
if (!check_length(len, 4, "SkipAct1")) return; |
3a7cc737dec8
(svn r9790) -Codechange: [NewGRF] Skip action 1 sprites in all stages except activation. This also cleans up some special-case handling of the sprites. Actions 1 and 2 are now not considered unsafe, as an Action 3 (which is unsafe) is required for them.
peter1138
parents:
6570
diff
changeset
|
2554 |
buf++; |
3a7cc737dec8
(svn r9790) -Codechange: [NewGRF] Skip action 1 sprites in all stages except activation. This also cleans up some special-case handling of the sprites. Actions 1 and 2 are now not considered unsafe, as an Action 3 (which is unsafe) is required for them.
peter1138
parents:
6570
diff
changeset
|
2555 |
grf_load_byte(&buf); |
3a7cc737dec8
(svn r9790) -Codechange: [NewGRF] Skip action 1 sprites in all stages except activation. This also cleans up some special-case handling of the sprites. Actions 1 and 2 are now not considered unsafe, as an Action 3 (which is unsafe) is required for them.
peter1138
parents:
6570
diff
changeset
|
2556 |
uint8 num_sets = grf_load_byte(&buf); |
3a7cc737dec8
(svn r9790) -Codechange: [NewGRF] Skip action 1 sprites in all stages except activation. This also cleans up some special-case handling of the sprites. Actions 1 and 2 are now not considered unsafe, as an Action 3 (which is unsafe) is required for them.
peter1138
parents:
6570
diff
changeset
|
2557 |
uint16 num_ents = grf_load_extended(&buf); |
3a7cc737dec8
(svn r9790) -Codechange: [NewGRF] Skip action 1 sprites in all stages except activation. This also cleans up some special-case handling of the sprites. Actions 1 and 2 are now not considered unsafe, as an Action 3 (which is unsafe) is required for them.
peter1138
parents:
6570
diff
changeset
|
2558 |
|
3a7cc737dec8
(svn r9790) -Codechange: [NewGRF] Skip action 1 sprites in all stages except activation. This also cleans up some special-case handling of the sprites. Actions 1 and 2 are now not considered unsafe, as an Action 3 (which is unsafe) is required for them.
peter1138
parents:
6570
diff
changeset
|
2559 |
_skip_sprites = num_sets * num_ents; |
3a7cc737dec8
(svn r9790) -Codechange: [NewGRF] Skip action 1 sprites in all stages except activation. This also cleans up some special-case handling of the sprites. Actions 1 and 2 are now not considered unsafe, as an Action 3 (which is unsafe) is required for them.
peter1138
parents:
6570
diff
changeset
|
2560 |
|
3a7cc737dec8
(svn r9790) -Codechange: [NewGRF] Skip action 1 sprites in all stages except activation. This also cleans up some special-case handling of the sprites. Actions 1 and 2 are now not considered unsafe, as an Action 3 (which is unsafe) is required for them.
peter1138
parents:
6570
diff
changeset
|
2561 |
grfmsg(3, "SkipAct1: Skipping %d sprites", _skip_sprites); |
3a7cc737dec8
(svn r9790) -Codechange: [NewGRF] Skip action 1 sprites in all stages except activation. This also cleans up some special-case handling of the sprites. Actions 1 and 2 are now not considered unsafe, as an Action 3 (which is unsafe) is required for them.
peter1138
parents:
6570
diff
changeset
|
2562 |
} |
3a7cc737dec8
(svn r9790) -Codechange: [NewGRF] Skip action 1 sprites in all stages except activation. This also cleans up some special-case handling of the sprites. Actions 1 and 2 are now not considered unsafe, as an Action 3 (which is unsafe) is required for them.
peter1138
parents:
6570
diff
changeset
|
2563 |
|
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2564 |
/* Helper function to either create a callback or link to a previously |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2565 |
* defined spritegroup. */ |
4893
000692659d8c
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
2566 |
static const SpriteGroup* GetGroupFromGroupID(byte setid, byte type, uint16 groupid) |
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2567 |
{ |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
2568 |
if (HasBit(groupid, 15)) return NewCallBackResultSpriteGroup(groupid); |
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2569 |
|
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2570 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2571 |
grfmsg(1, "GetGroupFromGroupID(0x%02X:0x%02X): Groupid 0x%04X does not exist, leaving empty", setid, type, groupid); |
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2572 |
return NULL; |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2573 |
} |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2574 |
|
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2575 |
return _cur_grffile->spritegroups[groupid]; |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2576 |
} |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2577 |
|
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2578 |
/* Helper function to either create a callback or a result sprite group. */ |
4893
000692659d8c
(svn r6837) - Codechange: More const SpriteGroups missed in r6836
peter1138
parents:
4869
diff
changeset
|
2579 |
static const SpriteGroup* CreateGroupFromGroupID(byte feature, byte setid, byte type, uint16 spriteid, uint16 num_sprites) |
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2580 |
{ |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
2581 |
if (HasBit(spriteid, 15)) return NewCallBackResultSpriteGroup(spriteid); |
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2582 |
|
3667
67cf868114ac
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
2583 |
if (spriteid >= _cur_grffile->spriteset_numsets) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2584 |
grfmsg(1, "CreateGroupFromGroupID(0x%02X:0x%02X): Sprite set %u invalid, max %u", setid, type, spriteid, _cur_grffile->spriteset_numsets); |
3667
67cf868114ac
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
2585 |
return NULL; |
67cf868114ac
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
2586 |
} |
67cf868114ac
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
peter1138
parents:
3666
diff
changeset
|
2587 |
|
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2588 |
/* Check if the sprite is within range. This can fail if the Action 0x01 |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2589 |
* is skipped, as TTDPatch mandates that Action 0x02s must be processed. |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2590 |
* We don't have that rule, but must live by the Patch... */ |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2591 |
if (_cur_grffile->spriteset_start + spriteid * num_sprites + num_sprites > _cur_spriteid) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2592 |
grfmsg(1, "CreateGroupFromGroupID(0x%02X:0x%02X): Real Sprite IDs 0x%04X - 0x%04X do not (all) exist (max 0x%04X), leaving empty", |
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2593 |
setid, type, |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2594 |
_cur_grffile->spriteset_start + spriteid * num_sprites, |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2595 |
_cur_grffile->spriteset_start + spriteid * num_sprites + num_sprites - 1, _cur_spriteid - 1); |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2596 |
return NULL; |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2597 |
} |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2598 |
|
3803
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2599 |
if (feature != _cur_grffile->spriteset_feature) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2600 |
grfmsg(1, "CreateGroupFromGroupID(0x%02X:0x%02X): Sprite set feature 0x%02X does not match action feature 0x%02X, skipping", |
6885
12cc0502992a
(svn r10128) -Fix (r4811): missing printf parameters in newgrf debug message
peter1138
parents:
6873
diff
changeset
|
2601 |
setid, type, |
3803
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2602 |
_cur_grffile->spriteset_feature, feature); |
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2603 |
return NULL; |
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2604 |
} |
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2605 |
|
3666
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2606 |
return NewResultSpriteGroup(_cur_grffile->spriteset_start + spriteid * num_sprites, num_sprites); |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2607 |
} |
d37f272cc136
(svn r4581) - NewGRF: replace replicated action 2 code with two functions to simplify code somewhat. Also check that a sprite id is
peter1138
parents:
3648
diff
changeset
|
2608 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2609 |
/* Action 0x02 */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
2610 |
static void NewSpriteGroup(byte *buf, size_t len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2611 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2612 |
/* <02> <feature> <set-id> <type/num-entries> <feature-specific-data...> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2613 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2614 |
* B feature see action 1 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2615 |
* B set-id ID of this particular definition |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2616 |
* B type/num-entries |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2617 |
* if 80 or greater, this is a randomized or variational |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2618 |
* list definition, see below |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2619 |
* otherwise it specifies a number of entries, the exact |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2620 |
* meaning depends on the feature |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2621 |
* V feature-specific-data (huge mess, don't even look it up --pasky) */ |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2622 |
SpriteGroup *group = NULL; |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2623 |
byte *bufend = buf + len; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2624 |
|
5590
6a0c2739e124
(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:
5587
diff
changeset
|
2625 |
if (!check_length(len, 5, "NewSpriteGroup")) return; |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2626 |
buf++; |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2627 |
|
6281 | 2628 |
uint8 feature = grf_load_byte(&buf); |
2629 |
uint8 setid = grf_load_byte(&buf); |
|
2630 |
uint8 type = grf_load_byte(&buf); |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2631 |
|
2444
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
2632 |
if (setid >= _cur_grffile->spritegroups_count) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2633 |
/* Allocate memory for new sprite group references. */ |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
2634 |
_cur_grffile->spritegroups = ReallocT(_cur_grffile->spritegroups, setid + 1); |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
2635 |
/* Initialise new space to NULL */ |
2488
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
2636 |
for (; _cur_grffile->spritegroups_count < (setid + 1); _cur_grffile->spritegroups_count++) |
1e98c71e5f6a
(svn r3014) -NewGRF, Codechange: Make all sprite group references be pointers instead of copying the data around.
peter1138
parents:
2480
diff
changeset
|
2637 |
_cur_grffile->spritegroups[_cur_grffile->spritegroups_count] = NULL; |
2444
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
2638 |
} |
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
2639 |
|
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2640 |
switch (type) { |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2641 |
/* Deterministic Sprite Group */ |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2642 |
case 0x81: // Self scope, byte |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2643 |
case 0x82: // Parent scope, byte |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2644 |
case 0x85: // Self scope, word |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2645 |
case 0x86: // Parent scope, word |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2646 |
case 0x89: // Self scope, dword |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2647 |
case 0x8A: // Parent scope, dword |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2648 |
{ |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2649 |
byte varadjust; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2650 |
byte varsize; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2651 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2652 |
/* Check we can load the var size parameter */ |
5590
6a0c2739e124
(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:
5587
diff
changeset
|
2653 |
if (!check_length(bufend - buf, 1, "NewSpriteGroup (Deterministic) (1)")) return; |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2654 |
|
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2655 |
group = AllocateSpriteGroup(); |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2656 |
group->type = SGT_DETERMINISTIC; |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
2657 |
group->g.determ.var_scope = HasBit(type, 1) ? VSG_SCOPE_PARENT : VSG_SCOPE_SELF; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2658 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2659 |
switch (GB(type, 2, 2)) { |
3672
f626ea3c9994
(svn r4588) - NewGRF: silence a false compiler warning
peter1138
parents:
3668
diff
changeset
|
2660 |
default: NOT_REACHED(); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2661 |
case 0: group->g.determ.size = DSG_SIZE_BYTE; varsize = 1; break; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2662 |
case 1: group->g.determ.size = DSG_SIZE_WORD; varsize = 2; break; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2663 |
case 2: group->g.determ.size = DSG_SIZE_DWORD; varsize = 4; break; |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2664 |
} |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2665 |
|
5590
6a0c2739e124
(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:
5587
diff
changeset
|
2666 |
if (!check_length(bufend - buf, 5 + varsize, "NewSpriteGroup (Deterministic) (2)")) return; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2667 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2668 |
/* Loop through the var adjusts. Unfortunately we don't know how many we have |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2669 |
* from the outset, so we shall have to keep reallocing. */ |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2670 |
do { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2671 |
DeterministicSpriteGroupAdjust *adjust; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2672 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2673 |
if (group->g.determ.num_adjusts > 0) { |
5590
6a0c2739e124
(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:
5587
diff
changeset
|
2674 |
if (!check_length(bufend - buf, 2 + varsize + 3, "NewSpriteGroup (Deterministic) (3)")) return; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2675 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2676 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2677 |
group->g.determ.num_adjusts++; |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
2678 |
group->g.determ.adjusts = ReallocT(group->g.determ.adjusts, group->g.determ.num_adjusts); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2679 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2680 |
adjust = &group->g.determ.adjusts[group->g.determ.num_adjusts - 1]; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2681 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2682 |
/* The first var adjust doesn't have an operation specified, so we set it to add. */ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
2683 |
adjust->operation = group->g.determ.num_adjusts == 1 ? DSGA_OP_ADD : (DeterministicSpriteGroupAdjustOperation)grf_load_byte(&buf); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2684 |
adjust->variable = grf_load_byte(&buf); |
5617
07de31c05f46
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5609
diff
changeset
|
2685 |
if (adjust->variable == 0x7E) { |
07de31c05f46
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5609
diff
changeset
|
2686 |
/* Link subroutine group */ |
07de31c05f46
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5609
diff
changeset
|
2687 |
adjust->subroutine = GetGroupFromGroupID(setid, type, grf_load_byte(&buf)); |
07de31c05f46
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5609
diff
changeset
|
2688 |
} else { |
7954
57b51c69c072
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents:
7953
diff
changeset
|
2689 |
adjust->parameter = IsInsideMM(adjust->variable, 0x60, 0x80) ? grf_load_byte(&buf) : 0; |
5617
07de31c05f46
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
maedhros
parents:
5609
diff
changeset
|
2690 |
} |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2691 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2692 |
varadjust = grf_load_byte(&buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2693 |
adjust->shift_num = GB(varadjust, 0, 5); |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
2694 |
adjust->type = (DeterministicSpriteGroupAdjustType)GB(varadjust, 6, 2); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2695 |
adjust->and_mask = grf_load_var(varsize, &buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2696 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2697 |
if (adjust->type != DSGA_TYPE_NONE) { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2698 |
adjust->add_val = grf_load_var(varsize, &buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2699 |
adjust->divmod_val = grf_load_var(varsize, &buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2700 |
} else { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2701 |
adjust->add_val = 0; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2702 |
adjust->divmod_val = 0; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2703 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2704 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2705 |
/* Continue reading var adjusts while bit 5 is set. */ |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
2706 |
} while (HasBit(varadjust, 5)); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2707 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2708 |
group->g.determ.num_ranges = grf_load_byte(&buf); |
6659
dc6f5b564096
(svn r9890) -Codechange: Don't allocate space for 0 spriteset ranges
peter1138
parents:
6652
diff
changeset
|
2709 |
if (group->g.determ.num_ranges > 0) group->g.determ.ranges = CallocT<DeterministicSpriteGroupRange>(group->g.determ.num_ranges); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2710 |
|
5590
6a0c2739e124
(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:
5587
diff
changeset
|
2711 |
if (!check_length(bufend - buf, 2 + (2 + 2 * varsize) * group->g.determ.num_ranges, "NewSpriteGroup (Deterministic)")) return; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2712 |
|
6281 | 2713 |
for (uint i = 0; i < group->g.determ.num_ranges; i++) { |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2714 |
group->g.determ.ranges[i].group = GetGroupFromGroupID(setid, type, grf_load_word(&buf)); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2715 |
group->g.determ.ranges[i].low = grf_load_var(varsize, &buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2716 |
group->g.determ.ranges[i].high = grf_load_var(varsize, &buf); |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2717 |
} |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2718 |
|
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2719 |
group->g.determ.default_group = GetGroupFromGroupID(setid, type, grf_load_word(&buf)); |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2720 |
break; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2721 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2722 |
|
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2723 |
/* Randomized Sprite Group */ |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2724 |
case 0x80: // Self scope |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2725 |
case 0x83: // Parent scope |
8756
b6f8dc6a246f
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
8754
diff
changeset
|
2726 |
case 0x84: // Relative scope |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2727 |
{ |
8756
b6f8dc6a246f
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
8754
diff
changeset
|
2728 |
if (!check_length(bufend - buf, HasBit(type, 2) ? 8 : 7, "NewSpriteGroup (Randomized) (1)")) return; |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2729 |
|
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2730 |
group = AllocateSpriteGroup(); |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2731 |
group->type = SGT_RANDOMIZED; |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
2732 |
group->g.random.var_scope = HasBit(type, 1) ? VSG_SCOPE_PARENT : VSG_SCOPE_SELF; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2733 |
|
8758
d2655b49862b
(svn r12454) -Fix (r12452): incorrect calculation for 'first vehicle in this chain of vehicles with the same ID' (thx DaleStan)
glx
parents:
8756
diff
changeset
|
2734 |
if (HasBit(type, 2)) { |
d2655b49862b
(svn r12454) -Fix (r12452): incorrect calculation for 'first vehicle in this chain of vehicles with the same ID' (thx DaleStan)
glx
parents:
8756
diff
changeset
|
2735 |
if (feature <= GSF_AIRCRAFT) group->g.random.var_scope = VSG_SCOPE_RELATIVE; |
8756
b6f8dc6a246f
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
8754
diff
changeset
|
2736 |
group->g.random.count = grf_load_byte(&buf); |
b6f8dc6a246f
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
8754
diff
changeset
|
2737 |
} |
b6f8dc6a246f
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx
parents:
8754
diff
changeset
|
2738 |
|
6281 | 2739 |
uint8 triggers = grf_load_byte(&buf); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2740 |
group->g.random.triggers = GB(triggers, 0, 7); |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
2741 |
group->g.random.cmp_mode = HasBit(triggers, 7) ? RSG_CMP_ALL : RSG_CMP_ANY; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2742 |
group->g.random.lowest_randbit = grf_load_byte(&buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2743 |
group->g.random.num_groups = grf_load_byte(&buf); |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
2744 |
group->g.random.groups = CallocT<const SpriteGroup*>(group->g.random.num_groups); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2745 |
|
5590
6a0c2739e124
(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:
5587
diff
changeset
|
2746 |
if (!check_length(bufend - buf, 2 * group->g.random.num_groups, "NewSpriteGroup (Randomized) (2)")) return; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2747 |
|
6281 | 2748 |
for (uint i = 0; i < group->g.random.num_groups; i++) { |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2749 |
group->g.random.groups[i] = GetGroupFromGroupID(setid, type, grf_load_word(&buf)); |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2750 |
} |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2751 |
|
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2752 |
break; |
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2753 |
} |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2754 |
|
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2755 |
/* Neither a variable or randomized sprite group... must be a real group */ |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2756 |
default: |
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2757 |
{ |
3803
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2758 |
|
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2759 |
|
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2760 |
switch (feature) { |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2761 |
case GSF_TRAIN: |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2762 |
case GSF_ROAD: |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2763 |
case GSF_SHIP: |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2764 |
case GSF_AIRCRAFT: |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2765 |
case GSF_STATION: |
6583
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
2766 |
case GSF_CANAL: |
6365
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
2767 |
case GSF_CARGOS: |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2768 |
{ |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2769 |
byte sprites = _cur_grffile->spriteset_numents; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2770 |
byte num_loaded = type; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2771 |
byte num_loading = grf_load_byte(&buf); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2772 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2773 |
if (_cur_grffile->spriteset_start == 0) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2774 |
grfmsg(0, "NewSpriteGroup: No sprite set to work on! Skipping"); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2775 |
return; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2776 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2777 |
|
5590
6a0c2739e124
(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:
5587
diff
changeset
|
2778 |
if (!check_length(bufend - buf, 2 * num_loaded + 2 * num_loading, "NewSpriteGroup (Real) (1)")) return; |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2779 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2780 |
group = AllocateSpriteGroup(); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2781 |
group->type = SGT_REAL; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2782 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2783 |
group->g.real.num_loaded = num_loaded; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2784 |
group->g.real.num_loading = num_loading; |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
2785 |
if (num_loaded > 0) group->g.real.loaded = CallocT<const SpriteGroup*>(num_loaded); |
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
2786 |
if (num_loading > 0) group->g.real.loading = CallocT<const SpriteGroup*>(num_loading); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2787 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2788 |
grfmsg(6, "NewSpriteGroup: New SpriteGroup 0x%02X, %u views, %u loaded, %u loading", |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2789 |
setid, sprites, num_loaded, num_loading); |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2790 |
|
6281 | 2791 |
for (uint i = 0; i < num_loaded; i++) { |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2792 |
uint16 spriteid = grf_load_word(&buf); |
3803
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2793 |
group->g.real.loaded[i] = CreateGroupFromGroupID(feature, setid, type, spriteid, sprites); |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2794 |
grfmsg(8, "NewSpriteGroup: + rg->loaded[%i] = subset %u", i, spriteid); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2795 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2796 |
|
6281 | 2797 |
for (uint i = 0; i < num_loading; i++) { |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2798 |
uint16 spriteid = grf_load_word(&buf); |
3803
87ff6c6f7d96
(svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group.
peter1138
parents:
3785
diff
changeset
|
2799 |
group->g.real.loading[i] = CreateGroupFromGroupID(feature, setid, type, spriteid, sprites); |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2800 |
grfmsg(8, "NewSpriteGroup: + rg->loading[%i] = subset %u", i, spriteid); |
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2801 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2802 |
|
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2803 |
break; |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2804 |
} |
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2805 |
|
7174
688c4e8b5d73
(svn r10448) -Codechange: Industry Tiles and Houses share almost the same spritegroup format.
belugas
parents:
7168
diff
changeset
|
2806 |
case GSF_TOWNHOUSE: |
688c4e8b5d73
(svn r10448) -Codechange: Industry Tiles and Houses share almost the same spritegroup format.
belugas
parents:
7168
diff
changeset
|
2807 |
case GSF_INDUSTRYTILES: { |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2808 |
byte sprites = _cur_grffile->spriteset_numents; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2809 |
byte num_sprites = max((uint8)1, type); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2810 |
uint i; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2811 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2812 |
group = AllocateSpriteGroup(); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2813 |
group->type = SGT_TILELAYOUT; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2814 |
group->g.layout.num_sprites = sprites; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2815 |
group->g.layout.dts = CallocT<DrawTileSprites>(1); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2816 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2817 |
/* Groundsprite */ |
8571
53c94d717e99
(svn r12149) -Codechange: Merge 'ground_sprite' and 'ground_pal' of DrawTileSprites into one PalSpriteID
frosch
parents:
8570
diff
changeset
|
2818 |
group->g.layout.dts->ground.sprite = grf_load_word(&buf); |
53c94d717e99
(svn r12149) -Codechange: Merge 'ground_sprite' and 'ground_pal' of DrawTileSprites into one PalSpriteID
frosch
parents:
8570
diff
changeset
|
2819 |
group->g.layout.dts->ground.pal = grf_load_word(&buf); |
8577
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
2820 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2821 |
/* Remap transparent/colour modifier bits */ |
8577
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
2822 |
MapSpriteMappingRecolour(&group->g.layout.dts->ground); |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
2823 |
|
8571
53c94d717e99
(svn r12149) -Codechange: Merge 'ground_sprite' and 'ground_pal' of DrawTileSprites into one PalSpriteID
frosch
parents:
8570
diff
changeset
|
2824 |
if (HasBit(group->g.layout.dts->ground.pal, 15)) { |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2825 |
/* Bit 31 set means this is a custom sprite, so rewrite it to the |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2826 |
* last spriteset defined. */ |
8571
53c94d717e99
(svn r12149) -Codechange: Merge 'ground_sprite' and 'ground_pal' of DrawTileSprites into one PalSpriteID
frosch
parents:
8570
diff
changeset
|
2827 |
SpriteID sprite = _cur_grffile->spriteset_start + GB(group->g.layout.dts->ground.sprite, 0, 14) * sprites; |
53c94d717e99
(svn r12149) -Codechange: Merge 'ground_sprite' and 'ground_pal' of DrawTileSprites into one PalSpriteID
frosch
parents:
8570
diff
changeset
|
2828 |
SB(group->g.layout.dts->ground.sprite, 0, SPRITE_WIDTH, sprite); |
53c94d717e99
(svn r12149) -Codechange: Merge 'ground_sprite' and 'ground_pal' of DrawTileSprites into one PalSpriteID
frosch
parents:
8570
diff
changeset
|
2829 |
ClrBit(group->g.layout.dts->ground.pal, 15); |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2830 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2831 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2832 |
group->g.layout.dts->seq = CallocT<DrawTileSeqStruct>(num_sprites + 1); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2833 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2834 |
for (i = 0; i < num_sprites; i++) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2835 |
DrawTileSeqStruct *seq = (DrawTileSeqStruct*)&group->g.layout.dts->seq[i]; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2836 |
|
8570
f50de4804ff1
(svn r12148) -Codechange: Merge 'image' and 'pal' of DrawTileSeqStruct into one PalSpriteID
frosch
parents:
8546
diff
changeset
|
2837 |
seq->image.sprite = grf_load_word(&buf); |
f50de4804ff1
(svn r12148) -Codechange: Merge 'image' and 'pal' of DrawTileSeqStruct into one PalSpriteID
frosch
parents:
8546
diff
changeset
|
2838 |
seq->image.pal = grf_load_word(&buf); |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2839 |
seq->delta_x = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2840 |
seq->delta_y = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2841 |
|
8577
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
2842 |
MapSpriteMappingRecolour(&seq->image); |
dbac636fa066
(svn r12158) -Codechange: merge all the sprite recolouring mapping under a single function
belugas
parents:
8571
diff
changeset
|
2843 |
|
8570
f50de4804ff1
(svn r12148) -Codechange: Merge 'image' and 'pal' of DrawTileSeqStruct into one PalSpriteID
frosch
parents:
8546
diff
changeset
|
2844 |
if (HasBit(seq->image.pal, 15)) { |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2845 |
/* Bit 31 set means this is a custom sprite, so rewrite it to the |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2846 |
* last spriteset defined. */ |
8570
f50de4804ff1
(svn r12148) -Codechange: Merge 'image' and 'pal' of DrawTileSeqStruct into one PalSpriteID
frosch
parents:
8546
diff
changeset
|
2847 |
SpriteID sprite = _cur_grffile->spriteset_start + GB(seq->image.sprite, 0, 14) * sprites; |
f50de4804ff1
(svn r12148) -Codechange: Merge 'image' and 'pal' of DrawTileSeqStruct into one PalSpriteID
frosch
parents:
8546
diff
changeset
|
2848 |
SB(seq->image.sprite, 0, SPRITE_WIDTH, sprite); |
f50de4804ff1
(svn r12148) -Codechange: Merge 'image' and 'pal' of DrawTileSeqStruct into one PalSpriteID
frosch
parents:
8546
diff
changeset
|
2849 |
ClrBit(seq->image.pal, 15); |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2850 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2851 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2852 |
if (type > 0) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2853 |
seq->delta_z = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2854 |
if ((byte)seq->delta_z == 0x80) continue; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2855 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2856 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2857 |
seq->size_x = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2858 |
seq->size_y = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2859 |
seq->size_z = grf_load_byte(&buf); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2860 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2861 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2862 |
/* Set the terminator value. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2863 |
((DrawTileSeqStruct*)group->g.layout.dts->seq)[i].delta_x = (byte)0x80; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2864 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2865 |
break; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2866 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
2867 |
|
7168
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2868 |
case GSF_INDUSTRIES: { |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2869 |
if (type > 1) { |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2870 |
grfmsg(1, "NewSpriteGroup: Unsupported industry production version %d, skipping", type); |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2871 |
break; |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2872 |
} |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2873 |
|
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2874 |
group = AllocateSpriteGroup(); |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2875 |
group->type = SGT_INDUSTRY_PRODUCTION; |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2876 |
group->g.indprod.version = type; |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2877 |
if (type == 0) { |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2878 |
for (uint i = 0; i < 3; i++) { |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2879 |
group->g.indprod.substract_input[i] = grf_load_word(&buf); |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2880 |
} |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2881 |
for (uint i = 0; i < 2; i++) { |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2882 |
group->g.indprod.add_output[i] = grf_load_word(&buf); |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2883 |
} |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2884 |
group->g.indprod.again = grf_load_byte(&buf); |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2885 |
} else { |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2886 |
for (uint i = 0; i < 3; i++) { |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2887 |
group->g.indprod.substract_input[i] = grf_load_byte(&buf); |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2888 |
} |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2889 |
for (uint i = 0; i < 2; i++) { |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2890 |
group->g.indprod.add_output[i] = grf_load_byte(&buf); |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2891 |
} |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2892 |
group->g.indprod.again = grf_load_byte(&buf); |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2893 |
} |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2894 |
break; |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2895 |
} |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7162
diff
changeset
|
2896 |
|
3668
42325f12e7d8
(svn r4583) - NewGRF: Revamp sprite group loading to support advanced varadjusts and variable size. These are not yet processed, however.
peter1138
parents:
3667
diff
changeset
|
2897 |
/* Loading of Tile Layout and Production Callback groups would happen here */ |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
2898 |
default: grfmsg(1, "NewSpriteGroup: Unsupported feature %d, skipping", feature); |
3633
fd7db14d4491
(svn r4537) - NewGRF: replace if cascade with a switch block in the sprite group loader
peter1138
parents:
3630
diff
changeset
|
2899 |
} |
2489
6fbb72b64e07
(svn r3015) -NewGRF: Add a new sprite group result type, and support loading of callbacks results within random and "real" groups. (Not fully supported yet.)
peter1138
parents:
2488
diff
changeset
|
2900 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2901 |
} |
2444
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
2902 |
|
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
2903 |
_cur_grffile->spritegroups[setid] = group; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2904 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2905 |
|
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2906 |
static CargoID TranslateCargo(uint8 feature, uint8 ctype) |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2907 |
{ |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2908 |
/* Special cargo types for purchase list and stations */ |
6148
5247b66aad19
(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:
6147
diff
changeset
|
2909 |
if (feature == GSF_STATION && ctype == 0xFE) return CT_DEFAULT_NA; |
5247b66aad19
(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:
6147
diff
changeset
|
2910 |
if (ctype == 0xFF) return CT_PURCHASE; |
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2911 |
|
6361
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2912 |
if (_cur_grffile->cargo_max == 0) { |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2913 |
/* No cargo table, so use bitnum values */ |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2914 |
if (ctype >= 32) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2915 |
grfmsg(1, "TranslateCargo: Cargo bitnum %d out of range (max 31), skipping.", ctype); |
6361
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2916 |
return CT_INVALID; |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2917 |
} |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2918 |
|
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2919 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2920 |
const CargoSpec *cs = GetCargo(c); |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2921 |
if (!cs->IsValid()) continue; |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2922 |
|
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2923 |
if (cs->bitnum == ctype) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2924 |
grfmsg(6, "TranslateCargo: Cargo bitnum %d mapped to cargo type %d.", ctype, c); |
6361
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2925 |
return c; |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2926 |
} |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2927 |
} |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2928 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2929 |
grfmsg(5, "TranslateCargo: Cargo bitnum %d not available in this climate, skipping.", ctype); |
6361
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2930 |
return CT_INVALID; |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2931 |
} |
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2932 |
|
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2933 |
/* Check if the cargo type is out of bounds of the cargo translation table */ |
6361
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2934 |
if (ctype >= _cur_grffile->cargo_max) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2935 |
grfmsg(1, "TranslateCargo: Cargo type %d out of range (max %d), skipping.", ctype, _cur_grffile->cargo_max - 1); |
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2936 |
return CT_INVALID; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2937 |
} |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2938 |
|
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2939 |
/* Look up the cargo label from the translation table */ |
6361
e3c29a0de66f
(svn r9413) -Codechange: Remove default cargo translation table and use bitnums directly if no table is provided. This lets pre-cargolabel cargo definitions work.
peter1138
parents:
6359
diff
changeset
|
2940 |
CargoLabel cl = _cur_grffile->cargo_list[ctype]; |
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2941 |
if (cl == 0) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2942 |
grfmsg(5, "TranslateCargo: Cargo type %d not available in this climate, skipping.", ctype); |
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2943 |
return CT_INVALID; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2944 |
} |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2945 |
|
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2946 |
ctype = GetCargoIDByLabel(cl); |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2947 |
if (ctype == CT_INVALID) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2948 |
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)); |
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2949 |
return CT_INVALID; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2950 |
} |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2951 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2952 |
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); |
6143
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2953 |
return ctype; |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2954 |
} |
dbca54e64e01
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
6142
diff
changeset
|
2955 |
|
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2956 |
|
9445
3f5fd80486c4
(svn r13363) -Codechange: Code duplication tidy up
peter1138
parents:
9413
diff
changeset
|
2957 |
static bool IsValidGroupID(uint16 groupid, const char *function) |
3f5fd80486c4
(svn r13363) -Codechange: Code duplication tidy up
peter1138
parents:
9413
diff
changeset
|
2958 |
{ |
3f5fd80486c4
(svn r13363) -Codechange: Code duplication tidy up
peter1138
parents:
9413
diff
changeset
|
2959 |
if (groupid >= _cur_grffile->spritegroups_count || _cur_grffile->spritegroups[groupid] == NULL) { |
3f5fd80486c4
(svn r13363) -Codechange: Code duplication tidy up
peter1138
parents:
9413
diff
changeset
|
2960 |
grfmsg(1, "%s: Spriteset 0x%04X out of range (maximum 0x%02X) or empty, skipping.", function, groupid, _cur_grffile->spritegroups_count - 1); |
3f5fd80486c4
(svn r13363) -Codechange: Code duplication tidy up
peter1138
parents:
9413
diff
changeset
|
2961 |
return false; |
3f5fd80486c4
(svn r13363) -Codechange: Code duplication tidy up
peter1138
parents:
9413
diff
changeset
|
2962 |
} |
3f5fd80486c4
(svn r13363) -Codechange: Code duplication tidy up
peter1138
parents:
9413
diff
changeset
|
2963 |
|
3f5fd80486c4
(svn r13363) -Codechange: Code duplication tidy up
peter1138
parents:
9413
diff
changeset
|
2964 |
return true; |
3f5fd80486c4
(svn r13363) -Codechange: Code duplication tidy up
peter1138
parents:
9413
diff
changeset
|
2965 |
} |
3f5fd80486c4
(svn r13363) -Codechange: Code duplication tidy up
peter1138
parents:
9413
diff
changeset
|
2966 |
|
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2967 |
static void VehicleMapSpriteGroup(byte *buf, byte feature, uint8 idcount) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2968 |
{ |
8198
a1d062c165b5
(svn r11761) -Codechange: Use appropriate variable types for NewGRF engine overrides, and adjust scope while there.
peter1138
parents:
8194
diff
changeset
|
2969 |
static EngineID *last_engines; |
a1d062c165b5
(svn r11761) -Codechange: Use appropriate variable types for NewGRF engine overrides, and adjust scope while there.
peter1138
parents:
8194
diff
changeset
|
2970 |
static uint last_engines_count; |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2971 |
bool wagover = false; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2972 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2973 |
/* Test for 'wagon override' flag */ |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2974 |
if (HasBit(idcount, 7)) { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2975 |
wagover = true; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2976 |
/* Strip off the flag */ |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2977 |
idcount = GB(idcount, 0, 7); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2978 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2979 |
if (last_engines_count == 0) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2980 |
grfmsg(0, "VehicleMapSpriteGroup: WagonOverride: No engine to do override with"); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2981 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2982 |
} |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
2983 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
2984 |
grfmsg(6, "VehicleMapSpriteGroup: WagonOverride: %u engines, %u wagons", |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2985 |
last_engines_count, idcount); |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2986 |
} else { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2987 |
if (last_engines_count != idcount) { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2988 |
last_engines = ReallocT(last_engines, idcount); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2989 |
last_engines_count = idcount; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2990 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2991 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
2992 |
|
9488
963e9e278125
(svn r13456) -Codechange: use AllocaM() macro instead of alloca() at most places
smatz
parents:
9483
diff
changeset
|
2993 |
EngineID *engines = AllocaM(EngineID, idcount); |
6281 | 2994 |
for (uint i = 0; i < idcount; i++) { |
9502
8c67bbeb7efd
(svn r13482) -Codechange: Use "extended bytes" in Actions 3 and 4 for vehicles
peter1138
parents:
9493
diff
changeset
|
2995 |
engines[i] = GetNewEngine(_cur_grffile, (VehicleType)feature, grf_load_extended(&buf))->index; |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2996 |
if (!wagover) last_engines[i] = engines[i]; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2997 |
} |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2998 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
2999 |
uint8 cidcount = grf_load_byte(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3000 |
for (uint c = 0; c < cidcount; c++) { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3001 |
uint8 ctype = grf_load_byte(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3002 |
uint16 groupid = grf_load_word(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3003 |
if (!IsValidGroupID(groupid, "VehicleMapSpriteGroup")) continue; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3004 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3005 |
grfmsg(8, "VehicleMapSpriteGroup: * [%d] Cargo type 0x%X, group id 0x%02X", c, ctype, groupid); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3006 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3007 |
ctype = TranslateCargo(feature, ctype); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3008 |
if (ctype == CT_INVALID) continue; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3009 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3010 |
for (uint i = 0; i < idcount; i++) { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3011 |
EngineID engine = engines[i]; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3012 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3013 |
grfmsg(7, "VehicleMapSpriteGroup: [%d] Engine %d...", i, engine); |
5338
a78592405640
(svn r7503) -Codechange: [NewGRF] Add bounds checking for spriteset cargo types. (NewCargo support will change this rule a bit...)
peter1138
parents:
5334
diff
changeset
|
3014 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3015 |
if (wagover) { |
4869
3a75d9b3b5ea
(svn r6795) - NewGRF: Add support for cargo-specific wagon overrides.
peter1138
parents:
4818
diff
changeset
|
3016 |
SetWagonOverrideSprites(engine, ctype, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3017 |
} else { |
2444
5998cd7b06e7
(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
peter1138
parents:
2442
diff
changeset
|
3018 |
SetCustomEngineSprites(engine, ctype, _cur_grffile->spritegroups[groupid]); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3019 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3020 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3021 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3022 |
|
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3023 |
uint16 groupid = grf_load_word(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3024 |
if (!IsValidGroupID(groupid, "VehicleMapSpriteGroup")) return; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3025 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3026 |
grfmsg(8, "-- Default group id 0x%04X", groupid); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3027 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3028 |
for (uint i = 0; i < idcount; i++) { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3029 |
EngineID engine = engines[i]; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3030 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3031 |
if (wagover) { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3032 |
SetWagonOverrideSprites(engine, CT_DEFAULT, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3033 |
} else { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3034 |
SetCustomEngineSprites(engine, CT_DEFAULT, _cur_grffile->spritegroups[groupid]); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3035 |
SetEngineGRF(engine, _cur_grffile); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3036 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3037 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3038 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3039 |
|
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3040 |
|
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3041 |
static void CanalMapSpriteGroup(byte *buf, uint8 idcount) |
6583
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
3042 |
{ |
9488
963e9e278125
(svn r13456) -Codechange: use AllocaM() macro instead of alloca() at most places
smatz
parents:
9483
diff
changeset
|
3043 |
CanalFeature *cfs = AllocaM(CanalFeature, idcount); |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3044 |
for (uint i = 0; i < idcount; i++) { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3045 |
cfs[i] = (CanalFeature)grf_load_byte(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3046 |
} |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3047 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3048 |
uint8 cidcount = grf_load_byte(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3049 |
buf += cidcount * 3; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3050 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3051 |
uint16 groupid = grf_load_word(&buf); |
9445
3f5fd80486c4
(svn r13363) -Codechange: Code duplication tidy up
peter1138
parents:
9413
diff
changeset
|
3052 |
if (!IsValidGroupID(groupid, "CanalMapSpriteGroup")) return; |
6583
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
3053 |
|
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
3054 |
for (uint i = 0; i < idcount; i++) { |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3055 |
CanalFeature cf = cfs[i]; |
6583
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
3056 |
|
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
3057 |
if (cf >= CF_END) { |
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
3058 |
grfmsg(1, "CanalMapSpriteGroup: Canal subset %d out of range, skipping", cf); |
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
3059 |
continue; |
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
3060 |
} |
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
3061 |
|
9750
7114408dd1fa
(svn r13885) -Fix [FS#2168]: Var 0x7F is not feature-specific.
frosch
parents:
9746
diff
changeset
|
3062 |
_water_feature[cf].grffile = _cur_grffile; |
8372
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
3063 |
_water_feature[cf].group = _cur_grffile->spritegroups[groupid]; |
6583
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
3064 |
} |
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
3065 |
} |
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
3066 |
|
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
3067 |
|
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3068 |
static void StationMapSpriteGroup(byte *buf, uint8 idcount) |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3069 |
{ |
9488
963e9e278125
(svn r13456) -Codechange: use AllocaM() macro instead of alloca() at most places
smatz
parents:
9483
diff
changeset
|
3070 |
uint8 *stations = AllocaM(uint8, idcount); |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3071 |
for (uint i = 0; i < idcount; i++) { |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3072 |
stations[i] = grf_load_byte(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3073 |
} |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3074 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3075 |
uint8 cidcount = grf_load_byte(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3076 |
for (uint c = 0; c < cidcount; c++) { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3077 |
uint8 ctype = grf_load_byte(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3078 |
uint16 groupid = grf_load_word(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3079 |
if (!IsValidGroupID(groupid, "StationMapSpriteGroup")) continue; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3080 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3081 |
ctype = TranslateCargo(GSF_STATION, ctype); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3082 |
if (ctype == CT_INVALID) continue; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3083 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3084 |
for (uint i = 0; i < idcount; i++) { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3085 |
StationSpec *statspec = _cur_grffile->stations[stations[i]]; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3086 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3087 |
if (statspec == NULL) { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3088 |
grfmsg(1, "StationMapSpriteGroup: Station with ID 0x%02X does not exist, skipping", stations[i]); |
10042
b77001494a91
(svn r14202) -Codechange: [NewGRF] Give more meaningful output if a house/industry/industrytile is undefined in action 3, and continue processing remaining IDs.
peter1138
parents:
10041
diff
changeset
|
3089 |
continue; |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3090 |
} |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3091 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3092 |
statspec->spritegroup[ctype] = _cur_grffile->spritegroups[groupid]; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3093 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3094 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3095 |
|
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3096 |
uint16 groupid = grf_load_word(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3097 |
if (!IsValidGroupID(groupid, "StationMapSpriteGroup")) return; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3098 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3099 |
for (uint i = 0; i < idcount; i++) { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3100 |
StationSpec *statspec = _cur_grffile->stations[stations[i]]; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3101 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3102 |
if (statspec == NULL) { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3103 |
grfmsg(1, "StationMapSpriteGroup: Station with ID 0x%02X does not exist, skipping", stations[i]); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3104 |
continue; |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3105 |
} |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3106 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3107 |
statspec->spritegroup[CT_DEFAULT] = _cur_grffile->spritegroups[groupid]; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3108 |
statspec->grffile = _cur_grffile; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3109 |
statspec->localidx = stations[i]; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3110 |
SetCustomStationSpec(statspec); |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3111 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3112 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3113 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3114 |
|
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3115 |
static void TownHouseMapSpriteGroup(byte *buf, uint8 idcount) |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3116 |
{ |
9488
963e9e278125
(svn r13456) -Codechange: use AllocaM() macro instead of alloca() at most places
smatz
parents:
9483
diff
changeset
|
3117 |
uint8 *houses = AllocaM(uint8, idcount); |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3118 |
for (uint i = 0; i < idcount; i++) { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3119 |
houses[i] = grf_load_byte(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3120 |
} |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3121 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3122 |
/* Skip the cargo type section, we only care about the default group */ |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3123 |
uint8 cidcount = grf_load_byte(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3124 |
buf += cidcount * 3; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3125 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3126 |
uint16 groupid = grf_load_word(&buf); |
9445
3f5fd80486c4
(svn r13363) -Codechange: Code duplication tidy up
peter1138
parents:
9413
diff
changeset
|
3127 |
if (!IsValidGroupID(groupid, "TownHouseMapSpriteGroup")) return; |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3128 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3129 |
for (uint i = 0; i < idcount; i++) { |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3130 |
HouseSpec *hs = _cur_grffile->housespec[houses[i]]; |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3131 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3132 |
if (hs == NULL) { |
10042
b77001494a91
(svn r14202) -Codechange: [NewGRF] Give more meaningful output if a house/industry/industrytile is undefined in action 3, and continue processing remaining IDs.
peter1138
parents:
10041
diff
changeset
|
3133 |
grfmsg(1, "TownHouseMapSpriteGroup: House %d undefined, skipping.", houses[i]); |
b77001494a91
(svn r14202) -Codechange: [NewGRF] Give more meaningful output if a house/industry/industrytile is undefined in action 3, and continue processing remaining IDs.
peter1138
parents:
10041
diff
changeset
|
3134 |
continue; |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3135 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3136 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3137 |
hs->spritegroup = _cur_grffile->spritegroups[groupid]; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3138 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3139 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3140 |
|
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3141 |
static void IndustryMapSpriteGroup(byte *buf, uint8 idcount) |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3142 |
{ |
9488
963e9e278125
(svn r13456) -Codechange: use AllocaM() macro instead of alloca() at most places
smatz
parents:
9483
diff
changeset
|
3143 |
uint8 *industries = AllocaM(uint8, idcount); |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3144 |
for (uint i = 0; i < idcount; i++) { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3145 |
industries[i] = grf_load_byte(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3146 |
} |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3147 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3148 |
/* Skip the cargo type section, we only care about the default group */ |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3149 |
uint8 cidcount = grf_load_byte(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3150 |
buf += cidcount * 3; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3151 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3152 |
uint16 groupid = grf_load_word(&buf); |
9445
3f5fd80486c4
(svn r13363) -Codechange: Code duplication tidy up
peter1138
parents:
9413
diff
changeset
|
3153 |
if (!IsValidGroupID(groupid, "IndustryMapSpriteGroup")) return; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3154 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3155 |
for (uint i = 0; i < idcount; i++) { |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3156 |
IndustrySpec *indsp = _cur_grffile->industryspec[industries[i]]; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3157 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3158 |
if (indsp == NULL) { |
10042
b77001494a91
(svn r14202) -Codechange: [NewGRF] Give more meaningful output if a house/industry/industrytile is undefined in action 3, and continue processing remaining IDs.
peter1138
parents:
10041
diff
changeset
|
3159 |
grfmsg(1, "IndustryMapSpriteGroup: Industry %d undefined, skipping", industries[i]); |
b77001494a91
(svn r14202) -Codechange: [NewGRF] Give more meaningful output if a house/industry/industrytile is undefined in action 3, and continue processing remaining IDs.
peter1138
parents:
10041
diff
changeset
|
3160 |
continue; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3161 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3162 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3163 |
indsp->grf_prop.spritegroup = _cur_grffile->spritegroups[groupid]; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3164 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3165 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3166 |
|
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3167 |
static void IndustrytileMapSpriteGroup(byte *buf, uint8 idcount) |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3168 |
{ |
9488
963e9e278125
(svn r13456) -Codechange: use AllocaM() macro instead of alloca() at most places
smatz
parents:
9483
diff
changeset
|
3169 |
uint8 *indtiles = AllocaM(uint8, idcount); |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3170 |
for (uint i = 0; i < idcount; i++) { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3171 |
indtiles[i] = grf_load_byte(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3172 |
} |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3173 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3174 |
/* Skip the cargo type section, we only care about the default group */ |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3175 |
uint8 cidcount = grf_load_byte(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3176 |
buf += cidcount * 3; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3177 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3178 |
uint16 groupid = grf_load_word(&buf); |
9445
3f5fd80486c4
(svn r13363) -Codechange: Code duplication tidy up
peter1138
parents:
9413
diff
changeset
|
3179 |
if (!IsValidGroupID(groupid, "IndustrytileMapSpriteGroup")) return; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3180 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3181 |
for (uint i = 0; i < idcount; i++) { |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3182 |
IndustryTileSpec *indtsp = _cur_grffile->indtspec[indtiles[i]]; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3183 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3184 |
if (indtsp == NULL) { |
10042
b77001494a91
(svn r14202) -Codechange: [NewGRF] Give more meaningful output if a house/industry/industrytile is undefined in action 3, and continue processing remaining IDs.
peter1138
parents:
10041
diff
changeset
|
3185 |
grfmsg(1, "IndustrytileMapSpriteGroup: Industry tile %d undefined, skipping", indtiles[i]); |
b77001494a91
(svn r14202) -Codechange: [NewGRF] Give more meaningful output if a house/industry/industrytile is undefined in action 3, and continue processing remaining IDs.
peter1138
parents:
10041
diff
changeset
|
3186 |
continue; |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3187 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3188 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3189 |
indtsp->grf_prop.spritegroup = _cur_grffile->spritegroups[groupid]; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3190 |
} |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3191 |
} |
6365
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3192 |
|
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3193 |
static void CargoMapSpriteGroup(byte *buf, uint8 idcount) |
6365
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3194 |
{ |
9488
963e9e278125
(svn r13456) -Codechange: use AllocaM() macro instead of alloca() at most places
smatz
parents:
9483
diff
changeset
|
3195 |
CargoID *cargos = AllocaM(CargoID, idcount); |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3196 |
for (uint i = 0; i < idcount; i++) { |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3197 |
cargos[i] = grf_load_byte(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3198 |
} |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3199 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3200 |
/* Skip the cargo type section, we only care about the default group */ |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3201 |
uint8 cidcount = grf_load_byte(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3202 |
buf += cidcount * 3; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3203 |
|
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3204 |
uint16 groupid = grf_load_word(&buf); |
9445
3f5fd80486c4
(svn r13363) -Codechange: Code duplication tidy up
peter1138
parents:
9413
diff
changeset
|
3205 |
if (!IsValidGroupID(groupid, "CargoMapSpriteGroup")) return; |
6365
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3206 |
|
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3207 |
for (uint i = 0; i < idcount; i++) { |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3208 |
CargoID cid = cargos[i]; |
6365
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3209 |
|
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3210 |
if (cid >= NUM_CARGO) { |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3211 |
grfmsg(1, "CargoMapSpriteGroup: Cargo ID %d out of range, skipping", cid); |
6365
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3212 |
continue; |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3213 |
} |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3214 |
|
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3215 |
CargoSpec *cs = &_cargo[cid]; |
9750
7114408dd1fa
(svn r13885) -Fix [FS#2168]: Var 0x7F is not feature-specific.
frosch
parents:
9746
diff
changeset
|
3216 |
cs->grffile = _cur_grffile; |
6365
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3217 |
cs->group = _cur_grffile->spritegroups[groupid]; |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3218 |
} |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3219 |
} |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3220 |
|
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3221 |
|
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3222 |
/* Action 0x03 */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
3223 |
static void FeatureMapSpriteGroup(byte *buf, size_t len) |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3224 |
{ |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3225 |
/* <03> <feature> <n-id> <ids>... <num-cid> [<cargo-type> <cid>]... <def-cid> |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3226 |
* id-list := [<id>] [id-list] |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3227 |
* cargo-list := <cargo-type> <cid> [cargo-list] |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3228 |
* |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3229 |
* B feature see action 0 |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3230 |
* B n-id bits 0-6: how many IDs this definition applies to |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3231 |
* bit 7: if set, this is a wagon override definition (see below) |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3232 |
* B ids the IDs for which this definition applies |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3233 |
* B num-cid number of cargo IDs (sprite group IDs) in this definition |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3234 |
* can be zero, in that case the def-cid is used always |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3235 |
* B cargo-type type of this cargo type (e.g. mail=2, wood=7, see below) |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3236 |
* W cid cargo ID (sprite group ID) for this type of cargo |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3237 |
* W def-cid default cargo ID (sprite group ID) */ |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3238 |
|
8544
47b99dc2da26
(svn r12122) -Codechange: Add framework for generic feature callbacks, along with some parts for AI use.
peter1138
parents:
8541
diff
changeset
|
3239 |
if (_cur_grffile->spritegroups == 0) { |
47b99dc2da26
(svn r12122) -Codechange: Add framework for generic feature callbacks, along with some parts for AI use.
peter1138
parents:
8541
diff
changeset
|
3240 |
grfmsg(1, "FeatureMapSpriteGroup: No sprite groups to work on! Skipping"); |
47b99dc2da26
(svn r12122) -Codechange: Add framework for generic feature callbacks, along with some parts for AI use.
peter1138
parents:
8541
diff
changeset
|
3241 |
return; |
47b99dc2da26
(svn r12122) -Codechange: Add framework for generic feature callbacks, along with some parts for AI use.
peter1138
parents:
8541
diff
changeset
|
3242 |
} |
47b99dc2da26
(svn r12122) -Codechange: Add framework for generic feature callbacks, along with some parts for AI use.
peter1138
parents:
8541
diff
changeset
|
3243 |
|
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3244 |
if (!check_length(len, 6, "FeatureMapSpriteGroup")) return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3245 |
|
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3246 |
buf++; |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3247 |
uint8 feature = grf_load_byte(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3248 |
uint8 idcount = grf_load_byte(&buf); |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3249 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3250 |
/* If idcount is zero, this is a feature callback */ |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3251 |
if (idcount == 0) { |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3252 |
/* Skip number of cargo ids? */ |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3253 |
grf_load_byte(&buf); |
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3254 |
uint16 groupid = grf_load_word(&buf); |
8544
47b99dc2da26
(svn r12122) -Codechange: Add framework for generic feature callbacks, along with some parts for AI use.
peter1138
parents:
8541
diff
changeset
|
3255 |
|
47b99dc2da26
(svn r12122) -Codechange: Add framework for generic feature callbacks, along with some parts for AI use.
peter1138
parents:
8541
diff
changeset
|
3256 |
grfmsg(6, "FeatureMapSpriteGroup: Adding generic feature callback for feature %d", feature); |
47b99dc2da26
(svn r12122) -Codechange: Add framework for generic feature callbacks, along with some parts for AI use.
peter1138
parents:
8541
diff
changeset
|
3257 |
|
47b99dc2da26
(svn r12122) -Codechange: Add framework for generic feature callbacks, along with some parts for AI use.
peter1138
parents:
8541
diff
changeset
|
3258 |
AddGenericCallback(feature, _cur_grffile, _cur_grffile->spritegroups[groupid]); |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3259 |
return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3260 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3261 |
|
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3262 |
grfmsg(6, "FeatureMapSpriteGroup: Feature %d, %d ids", feature, idcount); |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3263 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3264 |
switch (feature) { |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3265 |
case GSF_TRAIN: |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3266 |
case GSF_ROAD: |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3267 |
case GSF_SHIP: |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3268 |
case GSF_AIRCRAFT: |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3269 |
VehicleMapSpriteGroup(buf, feature, idcount); |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3270 |
return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3271 |
|
6583
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
3272 |
case GSF_CANAL: |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3273 |
CanalMapSpriteGroup(buf, idcount); |
6583
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
3274 |
return; |
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
3275 |
|
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3276 |
case GSF_STATION: |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3277 |
StationMapSpriteGroup(buf, idcount); |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3278 |
return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3279 |
|
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3280 |
case GSF_TOWNHOUSE: |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3281 |
TownHouseMapSpriteGroup(buf, idcount); |
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3282 |
return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3283 |
|
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3284 |
case GSF_INDUSTRIES: |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3285 |
IndustryMapSpriteGroup(buf, idcount); |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3286 |
return; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3287 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3288 |
case GSF_INDUSTRYTILES: |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3289 |
IndustrytileMapSpriteGroup(buf, idcount); |
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3290 |
return; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
3291 |
|
6365
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3292 |
case GSF_CARGOS: |
9446
9a619a3e5c2d
(svn r13364) -Codechange: Refactor action 3 mapping to use grf_load_*() instead of direct byte array access.
peter1138
parents:
9445
diff
changeset
|
3293 |
CargoMapSpriteGroup(buf, idcount); |
6365
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3294 |
return; |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6363
diff
changeset
|
3295 |
|
6363
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3296 |
default: |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3297 |
grfmsg(1, "FeatureMapSpriteGroup: Unsupported feature %d, skipping", feature); |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3298 |
return; |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3299 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3300 |
} |
bddccbf3420d
(svn r9416) -Codechange: Split NewGRF Action 3 handler into separate functions for each feature (vehicles are common, though)
peter1138
parents:
6361
diff
changeset
|
3301 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3302 |
/* Action 0x04 */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
3303 |
static void FeatureNewName(byte *buf, size_t len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3304 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3305 |
/* <04> <veh-type> <language-id> <num-veh> <offset> <data...> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3306 |
* |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3307 |
* B veh-type see action 0 (as 00..07, + 0A |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3308 |
* But IF veh-type = 48, then generic text |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3309 |
* B language-id If bit 6 is set, This is the extended language scheme, |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3310 |
with up to 64 language. |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3311 |
Otherwise, it is a mapping where set bits have meaning |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3312 |
0 = american, 1 = english, 2 = german, 3 = french, 4 = spanish |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3313 |
Bit 7 set means this is a generic text, not a vehicle one (or else) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3314 |
* B num-veh number of vehicles which are getting a new name |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
3315 |
* B/W offset number of the first vehicle that gets a new name |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3316 |
* Byte : ID of vehicle to change |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3317 |
* Word : ID of string to change/add |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3318 |
* S data new texts, each of them zero-terminated, after |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3319 |
* which the next name begins. */ |
6281 | 3320 |
|
3643
c04228043cb0
(svn r4552) - NewGRF: fix braino... in r4550, new_scheme should true when the version is 7 or higher, not less than 7...
peter1138
parents:
3642
diff
changeset
|
3321 |
bool new_scheme = _cur_grffile->grf_version >= 7; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3322 |
|
5590
6a0c2739e124
(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:
5587
diff
changeset
|
3323 |
if (!check_length(len, 6, "FeatureNewName")) return; |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
3324 |
buf++; |
6281 | 3325 |
uint8 feature = grf_load_byte(&buf); |
3326 |
uint8 lang = grf_load_byte(&buf); |
|
3327 |
uint8 num = grf_load_byte(&buf); |
|
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
3328 |
bool generic = HasBit(lang, 7); |
9502
8c67bbeb7efd
(svn r13482) -Codechange: Use "extended bytes" in Actions 3 and 4 for vehicles
peter1138
parents:
9493
diff
changeset
|
3329 |
uint16 id; |
8c67bbeb7efd
(svn r13482) -Codechange: Use "extended bytes" in Actions 3 and 4 for vehicles
peter1138
parents:
9493
diff
changeset
|
3330 |
if (generic) { |
8c67bbeb7efd
(svn r13482) -Codechange: Use "extended bytes" in Actions 3 and 4 for vehicles
peter1138
parents:
9493
diff
changeset
|
3331 |
id = grf_load_word(&buf); |
8c67bbeb7efd
(svn r13482) -Codechange: Use "extended bytes" in Actions 3 and 4 for vehicles
peter1138
parents:
9493
diff
changeset
|
3332 |
} else if (feature <= GSF_AIRCRAFT) { |
8c67bbeb7efd
(svn r13482) -Codechange: Use "extended bytes" in Actions 3 and 4 for vehicles
peter1138
parents:
9493
diff
changeset
|
3333 |
id = grf_load_extended(&buf); |
8c67bbeb7efd
(svn r13482) -Codechange: Use "extended bytes" in Actions 3 and 4 for vehicles
peter1138
parents:
9493
diff
changeset
|
3334 |
} else { |
8c67bbeb7efd
(svn r13482) -Codechange: Use "extended bytes" in Actions 3 and 4 for vehicles
peter1138
parents:
9493
diff
changeset
|
3335 |
id = grf_load_byte(&buf); |
8c67bbeb7efd
(svn r13482) -Codechange: Use "extended bytes" in Actions 3 and 4 for vehicles
peter1138
parents:
9493
diff
changeset
|
3336 |
} |
4992
bd2716c79584
(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
|
3337 |
|
7929
6c9b25842b0f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
7928
diff
changeset
|
3338 |
ClrBit(lang, 7); |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
3339 |
|
6281 | 3340 |
uint16 endid = id + num; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3341 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3342 |
grfmsg(6, "FeatureNewName: About to rename engines %d..%d (feature %d) in language 0x%02X", |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3343 |
id, endid, feature, lang); |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3344 |
|
4992
bd2716c79584
(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
|
3345 |
len -= generic ? 6 : 5; |
bd2716c79584
(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
|
3346 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3347 |
for (; id < endid && len > 0; id++) { |
6090
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
3348 |
const char *name = grf_load_string(&buf, len); |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
3349 |
size_t name_length = strlen(name) + 1; |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
3350 |
|
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
3351 |
len -= (int)name_length; |
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
3352 |
|
6607
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3353 |
grfmsg(8, "FeatureNewName: 0x%04X <- %s", id, name); |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3354 |
|
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3355 |
switch (feature) { |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3356 |
case GSF_TRAIN: |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3357 |
case GSF_ROAD: |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3358 |
case GSF_SHIP: |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3359 |
case GSF_AIRCRAFT: |
9453
0d9a6bee8bf3
(svn r13371) -Fix (r4510 ... r12924): Engine array size is not related to the ID used when setting a vehicle's name (it is vehicle type specific). Instead just test for a generic string.
peter1138
parents:
9450
diff
changeset
|
3360 |
if (!generic) { |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
3361 |
Engine *e = GetNewEngine(_cur_grffile, (VehicleType)feature, id); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
3362 |
StringID string = AddGRFString(_cur_grffile->grfid, e->index, lang, new_scheme, name, e->info.string_id); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
3363 |
e->info.string_id = string; |
6607
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3364 |
} else { |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3365 |
AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, id); |
3614 | 3366 |
} |
6607
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3367 |
break; |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3368 |
|
7182
3cce857179f9
(svn r10456) -Codechange: Enable loading newgrf strings for Industries
belugas
parents:
7174
diff
changeset
|
3369 |
case GSF_INDUSTRIES: { |
3cce857179f9
(svn r10456) -Codechange: Enable loading newgrf strings for Industries
belugas
parents:
7174
diff
changeset
|
3370 |
AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
3cce857179f9
(svn r10456) -Codechange: Enable loading newgrf strings for Industries
belugas
parents:
7174
diff
changeset
|
3371 |
break; |
3cce857179f9
(svn r10456) -Codechange: Enable loading newgrf strings for Industries
belugas
parents:
7174
diff
changeset
|
3372 |
} |
3cce857179f9
(svn r10456) -Codechange: Enable loading newgrf strings for Industries
belugas
parents:
7174
diff
changeset
|
3373 |
|
6607
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3374 |
case GSF_TOWNHOUSE: |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3375 |
default: |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3376 |
switch (GB(id, 8, 8)) { |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3377 |
case 0xC4: // Station class name |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3378 |
if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3379 |
grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8)); |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3380 |
} else { |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3381 |
StationClassID sclass = _cur_grffile->stations[GB(id, 0, 8)]->sclass; |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3382 |
SetStationClassName(sclass, AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED)); |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
3383 |
} |
6607
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3384 |
break; |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3385 |
|
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3386 |
case 0xC5: // Station name |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3387 |
if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3388 |
grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8)); |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3389 |
} else { |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3390 |
_cur_grffile->stations[GB(id, 0, 8)]->name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3391 |
} |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3392 |
break; |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3393 |
|
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3394 |
case 0xC9: // House name |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3395 |
if (_cur_grffile->housespec == NULL || _cur_grffile->housespec[GB(id, 0, 8)] == NULL) { |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3396 |
grfmsg(1, "FeatureNewName: Attempt to name undefined house 0x%X, ignoring.", GB(id, 0, 8)); |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3397 |
} else { |
8959
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
3398 |
_cur_grffile->housespec[GB(id, 0, 8)]->building_name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
6607
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3399 |
} |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3400 |
break; |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3401 |
|
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3402 |
case 0xD0: |
8655
091434f42207
(svn r12316) -Codechange: Support loading full range of 0xD0xx NewGRF strings which
peter1138
parents:
8649
diff
changeset
|
3403 |
case 0xD1: |
091434f42207
(svn r12316) -Codechange: Support loading full range of 0xD0xx NewGRF strings which
peter1138
parents:
8649
diff
changeset
|
3404 |
case 0xD2: |
091434f42207
(svn r12316) -Codechange: Support loading full range of 0xD0xx NewGRF strings which
peter1138
parents:
8649
diff
changeset
|
3405 |
case 0xD3: |
6607
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3406 |
case 0xDC: |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3407 |
AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3408 |
break; |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3409 |
|
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3410 |
default: |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3411 |
grfmsg(7, "FeatureNewName: Unsupported ID (0x%04X)", id); |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3412 |
break; |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3413 |
} |
ef92dcaaa49c
(svn r9827) -Codechange/Fix: [NewGRF] Text strings of 1 character are perfectly valid... (fixes dbsetxl refits again...)
peter1138
parents:
6606
diff
changeset
|
3414 |
break; |
3642
8da309b5fd2b
(svn r4551) - NewGRF: add string handling for newstations.
peter1138
parents:
3641
diff
changeset
|
3415 |
|
8da309b5fd2b
(svn r4551) - NewGRF: add string handling for newstations.
peter1138
parents:
3641
diff
changeset
|
3416 |
#if 0 |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3417 |
case GSF_CANAL : |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3418 |
case GSF_BRIDGE : |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3419 |
AddGRFString(_cur_spriteid, id, lang, name); |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6481
diff
changeset
|
3420 |
switch (GB(id, 8, 8)) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3421 |
case 0xC9: // House name |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3422 |
default: |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3423 |
grfmsg(7, "FeatureNewName: Unsupported ID (0x%04X)", id); |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3424 |
} |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3425 |
break; |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3426 |
|
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3427 |
default : |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3428 |
grfmsg(7, "FeatureNewName: Unsupported feature (0x%02X)", feature); |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3429 |
break; |
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
3430 |
#endif |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3431 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3432 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3433 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3434 |
|
7882
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3435 |
/** |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3436 |
* Sanitize incoming sprite offsets for Action 5 graphics replacements. |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3437 |
* @param num the number of sprites to load. |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3438 |
* @param offset offset from the base. |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3439 |
* @param max_sprites the maximum number of sprites that can be loaded in this action 5. |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3440 |
* @param name used for error warnings. |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3441 |
* @return the number of sprites that is going to be skipped |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3442 |
*/ |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3443 |
static uint16 SanitizeSpriteOffset(uint16& num, uint16 offset, int max_sprites, const char *name) |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3444 |
{ |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3445 |
|
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3446 |
if (offset >= max_sprites) { |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3447 |
grfmsg(1, "GraphicsNew: %s sprite offset must be less than %i, skipping", name, max_sprites); |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3448 |
uint orig_num = num; |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3449 |
num = 0; |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3450 |
return orig_num; |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3451 |
} |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3452 |
|
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3453 |
if (offset + num > max_sprites) { |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3454 |
grfmsg(4, "GraphicsNew: %s sprite overflow, truncating...", name); |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3455 |
uint orig_num = num; |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3456 |
num = max(max_sprites - offset, 0); |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3457 |
return orig_num - num; |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3458 |
} |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3459 |
|
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3460 |
return 0; |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3461 |
} |
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3462 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3463 |
/* Action 0x05 */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
3464 |
static void GraphicsNew(byte *buf, size_t len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3465 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3466 |
/* <05> <graphics-type> <num-sprites> <other data...> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3467 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3468 |
* B graphics-type What set of graphics the sprites define. |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
3469 |
* E num-sprites How many sprites are in this set? |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3470 |
* V other data Graphics type specific data. Currently unused. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3471 |
/* TODO */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3472 |
|
8243
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3473 |
enum Action5BlockType { |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3474 |
A5BLOCK_FIXED, ///< Only allow replacing a whole block of sprites. (TTDP compatible) |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3475 |
A5BLOCK_ALLOW_OFFSET, ///< Allow replacing any subset by specifiing an offset. |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3476 |
A5BLOCK_INVALID, ///< unknown/not-implemented type |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3477 |
}; |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3478 |
struct Action5Type { |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3479 |
Action5BlockType block_type; ///< How is this Action5 type processed? |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3480 |
SpriteID sprite_base; ///< Load the sprites starting from this sprite. |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3481 |
uint16 min_sprites; ///< If the Action5 contains less sprites, the whole block will be ignored. |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3482 |
uint16 max_sprites; ///< If the Action5 contains more sprites, only the first max_sprites sprites will be used. |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3483 |
const char *name; ///< Name for error messages. |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3484 |
}; |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3485 |
|
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3486 |
static const Action5Type action5_types[] = { |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3487 |
/* Note: min_sprites should not be changed. Therefore these constants are directly here and not in sprites.h */ |
9493
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3488 |
/* 0x00 */ { A5BLOCK_INVALID, 0, 0, 0, "Type 0x00" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3489 |
/* 0x01 */ { A5BLOCK_INVALID, 0, 0, 0, "Type 0x01" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3490 |
/* 0x02 */ { A5BLOCK_INVALID, 0, 0, 0, "Type 0x02" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3491 |
/* 0x03 */ { A5BLOCK_INVALID, 0, 0, 0, "Type 0x03" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3492 |
/* 0x04 */ { A5BLOCK_FIXED, SPR_SIGNALS_BASE, 48, PRESIGNAL_SEMAPHORE_AND_PBS_SPRITE_COUNT, "Signal graphics" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3493 |
/* 0x05 */ { A5BLOCK_FIXED, SPR_ELRAIL_BASE, 48, ELRAIL_SPRITE_COUNT, "Catenary graphics" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3494 |
/* 0x06 */ { A5BLOCK_FIXED, SPR_SLOPES_BASE, 74, NORMAL_AND_HALFTILE_FOUNDATION_SPRITE_COUNT, "Foundation graphics" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3495 |
/* 0x07 */ { A5BLOCK_INVALID, 0, 75, 0, "TTDP GUI graphics" }, // Not used by OTTD. |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3496 |
/* 0x08 */ { A5BLOCK_FIXED, SPR_CANALS_BASE, 65, CANALS_SPRITE_COUNT, "Canal graphics" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3497 |
/* 0x09 */ { A5BLOCK_FIXED, SPR_ONEWAY_BASE, 6, ONEWAY_SPRITE_COUNT, "One way road graphics" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3498 |
/* 0x0A */ { A5BLOCK_FIXED, SPR_2CCMAP_BASE, 256, TWOCCMAP_SPRITE_COUNT, "2CC colour maps" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3499 |
/* 0x0B */ { A5BLOCK_FIXED, SPR_TRAMWAY_BASE, 113, TRAMWAY_SPRITE_COUNT, "Tramway graphics" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3500 |
/* 0x0C */ { A5BLOCK_INVALID, 0, 133, 0, "Snowy temperate tree" }, // Not yet used by OTTD. |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3501 |
/* 0x0D */ { A5BLOCK_FIXED, SPR_SHORE_BASE, 16, SPR_SHORE_SPRITE_COUNT, "Shore graphics" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3502 |
/* 0x0E */ { A5BLOCK_INVALID, 0, 0, 0, "New Signals graphics" }, // Not yet used by OTTD. |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3503 |
/* 0x0F */ { A5BLOCK_FIXED, SPR_TRACKS_FOR_SLOPES_BASE, 12, TRACKS_FOR_SLOPES_SPRITE_COUNT, "Sloped rail track" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3504 |
/* 0x10 */ { A5BLOCK_FIXED, SPR_AIRPORTX_BASE, 15, AIRPORTX_SPRITE_COUNT, "Airport graphics" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3505 |
/* 0x11 */ { A5BLOCK_FIXED, SPR_ROADSTOP_BASE, 8, ROADSTOP_SPRITE_COUNT, "Road stop graphics" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3506 |
/* 0x12 */ { A5BLOCK_FIXED, SPR_AQUEDUCT_BASE, 8, AQUEDUCT_SPRITE_COUNT, "Aqueduct graphics" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3507 |
/* 0x13 */ { A5BLOCK_FIXED, SPR_AUTORAIL_BASE, 55, AUTORAIL_SPRITE_COUNT, "Autorail graphics" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3508 |
/* 0x14 */ { A5BLOCK_ALLOW_OFFSET, SPR_FLAGS_BASE, 1, FLAGS_SPRITE_COUNT, "Flag graphics" }, |
030cfc495f31
(svn r13469) -Codechange: add support for loading Action 0x05, type 0F: "tracks for slopes". It's not useful right now, but it will be in the future.
rubidium
parents:
9490
diff
changeset
|
3509 |
/* 0x15 */ { A5BLOCK_ALLOW_OFFSET, SPR_OPENTTD_BASE, 1, OPENTTD_SPRITE_COUNT, "OpenTTD GUI graphics" }, |
8243
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3510 |
}; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3511 |
|
5590
6a0c2739e124
(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:
5587
diff
changeset
|
3512 |
if (!check_length(len, 2, "GraphicsNew")) return; |
2346
2a1d9f47f38c
(svn r2872) -Feature: [NewGRF] Add support for "extended bytes"
tron
parents:
2345
diff
changeset
|
3513 |
buf++; |
6281 | 3514 |
uint8 type = grf_load_byte(&buf); |
3515 |
uint16 num = grf_load_extended(&buf); |
|
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
3516 |
uint16 offset = HasBit(type, 7) ? grf_load_extended(&buf) : 0; |
7929
6c9b25842b0f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
7928
diff
changeset
|
3517 |
ClrBit(type, 7); // Clear the high bit as that only indicates whether there is an offset. |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3518 |
|
8243
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3519 |
if ((type == 0x0D) && (num == 10) && _cur_grffile->is_ottdfile) { |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3520 |
/* Special not-TTDP-compatible case used in openttd(d/w).grf |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3521 |
* Missing shore sprites and initialisation of SPR_SHORE_BASE */ |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3522 |
grfmsg(2, "GraphicsNew: Loading 10 missing shore sprites from openttd(d/w).grf."); |
9454 | 3523 |
LoadNextSprite(SPR_SHORE_BASE + 0, _file_index, _nfo_line++); // SLOPE_STEEP_S |
3524 |
LoadNextSprite(SPR_SHORE_BASE + 5, _file_index, _nfo_line++); // SLOPE_STEEP_W |
|
3525 |
LoadNextSprite(SPR_SHORE_BASE + 7, _file_index, _nfo_line++); // SLOPE_WSE |
|
3526 |
LoadNextSprite(SPR_SHORE_BASE + 10, _file_index, _nfo_line++); // SLOPE_STEEP_N |
|
3527 |
LoadNextSprite(SPR_SHORE_BASE + 11, _file_index, _nfo_line++); // SLOPE_NWS |
|
3528 |
LoadNextSprite(SPR_SHORE_BASE + 13, _file_index, _nfo_line++); // SLOPE_ENW |
|
3529 |
LoadNextSprite(SPR_SHORE_BASE + 14, _file_index, _nfo_line++); // SLOPE_SEN |
|
3530 |
LoadNextSprite(SPR_SHORE_BASE + 15, _file_index, _nfo_line++); // SLOPE_STEEP_E |
|
3531 |
LoadNextSprite(SPR_SHORE_BASE + 16, _file_index, _nfo_line++); // SLOPE_EW |
|
3532 |
LoadNextSprite(SPR_SHORE_BASE + 17, _file_index, _nfo_line++); // SLOPE_NS |
|
8403
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
3533 |
if (_loaded_newgrf_features.shore == SHORE_REPLACE_NONE) _loaded_newgrf_features.shore = SHORE_REPLACE_ONLY_NEW; |
8243
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3534 |
return; |
3638
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
3535 |
} |
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
3536 |
|
8243
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3537 |
/* Supported type? */ |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3538 |
if ((type >= lengthof(action5_types)) || (action5_types[type].block_type == A5BLOCK_INVALID)) { |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3539 |
grfmsg(2, "GraphicsNew: Custom graphics (type 0x%02X) sprite block of length %u (unimplemented, ignoring)", type, num); |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3540 |
_skip_sprites = num; |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3541 |
return; |
3708
a152a2d1d4d1
(svn r4651) - NewGRF: support loading of catenary sprites from NewGRF files. This actually works by replacing our hardcoded sprites.
peter1138
parents:
3707
diff
changeset
|
3542 |
} |
3638
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
3543 |
|
8243
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3544 |
const Action5Type *action5_type = &action5_types[type]; |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3545 |
|
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3546 |
/* Ignore offset if not allowed */ |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3547 |
if ((action5_type->block_type != A5BLOCK_ALLOW_OFFSET) && (offset != 0)) { |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3548 |
grfmsg(1, "GraphicsNew: %s (type 0x%02X) do not allow an <offset> field. Ignoring offset.", action5_type->name, type); |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3549 |
offset = 0; |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3550 |
} |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3551 |
|
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3552 |
/* Ignore action5 if too few sprites are specified. (for TTDP compatibility) |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3553 |
* This does not make sense, if <offset> is allowed */ |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3554 |
if ((action5_type->block_type == A5BLOCK_FIXED) && (num < action5_type->min_sprites)) { |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3555 |
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); |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3556 |
_skip_sprites = num; |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3557 |
return; |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3558 |
} |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3559 |
|
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3560 |
/* Load at most max_sprites sprites. Skip remaining sprites. (for compatibility with TTDP and future extentions) */ |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3561 |
uint16 skip_num = SanitizeSpriteOffset(num, offset, action5_type->max_sprites, action5_type->name); |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3562 |
SpriteID replace = action5_type->sprite_base + offset; |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3563 |
|
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3564 |
/* Load <num> sprites starting from <replace>, then skip <skip_num> sprites. */ |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3565 |
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); |
6f76ab9f5ac0
(svn r11807) -Codechange: Make Action5 handler more upwards- and TTDP-compatible by allowing specifiing more sprites than needed.
frosch
parents:
8239
diff
changeset
|
3566 |
|
3638
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
3567 |
for (; num > 0; num--) { |
7953
db4cd9ef0efc
(svn r11509) -Fix: off-by-one error in some sprite numbers; increase sprite number counter before loading the next sprite instead of after doing so.
rubidium
parents:
7941
diff
changeset
|
3568 |
_nfo_line++; |
6908
6b1324d7a2c9
(svn r10157) -Fix: use as indentified for PNGs, the place of the image as it was in the grf, not the internal SpriteID
truelight
parents:
6894
diff
changeset
|
3569 |
LoadNextSprite(replace == 0 ? _cur_spriteid++ : replace++, _file_index, _nfo_line); |
3638
3e655c6e0914
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3635
diff
changeset
|
3570 |
} |
7882
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3571 |
|
8403
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
3572 |
if (type == 0x0D) _loaded_newgrf_features.shore = SHORE_REPLACE_ACTION_5; |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
3573 |
|
7882
308cab08d2f3
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
7879
diff
changeset
|
3574 |
_skip_sprites = skip_num; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3575 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3576 |
|
6529
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
3577 |
/* Action 0x05 (SKIP) */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
3578 |
static void SkipAct5(byte *buf, size_t len) |
6529
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
3579 |
{ |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
3580 |
if (!check_length(len, 2, "SkipAct5")) return; |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
3581 |
buf++; |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
3582 |
|
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
3583 |
/* Ignore type byte */ |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
3584 |
grf_load_byte(&buf); |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
3585 |
|
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
3586 |
/* Skip the sprites of this action */ |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
3587 |
_skip_sprites = grf_load_extended(&buf); |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
3588 |
|
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
3589 |
grfmsg(3, "SkipAct5: Skipping %d sprites", _skip_sprites); |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
3590 |
} |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
3591 |
|
8546
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3592 |
/** |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3593 |
* Reads a variable common to VarAction2 and Action7/9/D. |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3594 |
* |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3595 |
* Returns VarAction2 variable 'param' resp. Action7/9/D variable '0x80 + param'. |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3596 |
* If a variable is not accessible from all four actions, it is handled in the action specific functions. |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3597 |
* |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3598 |
* @param param variable number (as for VarAction2, for Action7/9/D you have to subtract 0x80 first). |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3599 |
* @param value returns the value of the variable. |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3600 |
* @return true iff the variable is known and the value is returned in 'value'. |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3601 |
*/ |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3602 |
bool GetGlobalVariable(byte param, uint32 *value) |
3806 | 3603 |
{ |
3604 |
switch (param) { |
|
8546
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3605 |
case 0x00: // current date |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3606 |
*value = max(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0); |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3607 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3608 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3609 |
case 0x01: // current year |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3610 |
*value = Clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3611 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3612 |
|
9570
8b9c1cbb0077
(svn r13594) -Feature(ette)[FS#2093]: Supply newgrfs with 'day of month', 'leap year' and 'day of year'.
frosch
parents:
9556
diff
changeset
|
3613 |
case 0x02: { // detailed date information: month of year (bit 0-7), day of month (bit 8-12), leap year (bit 15), day of year (bit 16-24) |
8b9c1cbb0077
(svn r13594) -Feature(ette)[FS#2093]: Supply newgrfs with 'day of month', 'leap year' and 'day of year'.
frosch
parents:
9556
diff
changeset
|
3614 |
YearMonthDay ymd; |
8b9c1cbb0077
(svn r13594) -Feature(ette)[FS#2093]: Supply newgrfs with 'day of month', 'leap year' and 'day of year'.
frosch
parents:
9556
diff
changeset
|
3615 |
ConvertDateToYMD(_date, &ymd); |
8b9c1cbb0077
(svn r13594) -Feature(ette)[FS#2093]: Supply newgrfs with 'day of month', 'leap year' and 'day of year'.
frosch
parents:
9556
diff
changeset
|
3616 |
Date start_of_year = ConvertYMDToDate(ymd.year, 0, 1); |
8b9c1cbb0077
(svn r13594) -Feature(ette)[FS#2093]: Supply newgrfs with 'day of month', 'leap year' and 'day of year'.
frosch
parents:
9556
diff
changeset
|
3617 |
*value = ymd.month | (ymd.day - 1) << 8 | (IsLeapYear(ymd.year) ? 1 << 15 : 0) | (_date - start_of_year) << 16; |
8546
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3618 |
return true; |
9570
8b9c1cbb0077
(svn r13594) -Feature(ette)[FS#2093]: Supply newgrfs with 'day of month', 'leap year' and 'day of year'.
frosch
parents:
9556
diff
changeset
|
3619 |
} |
8546
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3620 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3621 |
case 0x03: // current climate, 0=temp, 1=arctic, 2=trop, 3=toyland |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
3622 |
*value = _settings_game.game_creation.landscape; |
8546
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3623 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3624 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3625 |
case 0x06: // road traffic side, bit 4 clear=left, set=right |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
3626 |
*value = _settings_game.vehicle.road_side << 4; |
8546
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3627 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3628 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3629 |
case 0x09: // date fraction |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3630 |
*value = _date_fract; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3631 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3632 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3633 |
case 0x0A: // animation counter |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3634 |
*value = _tick_counter; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3635 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3636 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3637 |
case 0x0B: { // TTDPatch version |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3638 |
uint major = 2; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3639 |
uint minor = 6; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3640 |
uint revision = 1; // special case: 2.0.1 is 2.0.10 |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3641 |
uint build = 1382; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3642 |
*value = (major << 24) | (minor << 20) | (revision << 16) | build; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3643 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3644 |
} |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3645 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3646 |
case 0x0D: // TTD Version, 00=DOS, 01=Windows |
10066
f18e97752eeb
(svn r14233) -Feature/Fix [FS#2172]: save the palette of the loaded NewGRFs in the savegame, so joining with a server using Windows palette will make a client with the DOS palette do palette conversion and (thus) not cause a desync due to the different palettes disabling different NewGRFs.
rubidium
parents:
10063
diff
changeset
|
3647 |
*value = _cur_grfconfig->windows_paletted; |
8546
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3648 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3649 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3650 |
case 0x0E: // Y-offset for train sprites |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3651 |
*value = _traininfo_vehicle_pitch; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3652 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3653 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3654 |
case 0x0F: // Rail track type cost factors |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3655 |
*value = 0; |
10002
87148ad75853
(svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents:
10001
diff
changeset
|
3656 |
SB(*value, 0, 8, GetRailTypeInfo(RAILTYPE_RAIL)->cost_multiplier); // normal rail |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
3657 |
if (_settings_game.vehicle.disable_elrails) { |
8546
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3658 |
/* skip elrail multiplier - disabled */ |
10002
87148ad75853
(svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents:
10001
diff
changeset
|
3659 |
SB(*value, 8, 8, GetRailTypeInfo(RAILTYPE_MONO)->cost_multiplier); // monorail |
8546
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3660 |
} else { |
10002
87148ad75853
(svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents:
10001
diff
changeset
|
3661 |
SB(*value, 8, 8, GetRailTypeInfo(RAILTYPE_ELECTRIC)->cost_multiplier); // electified railway |
8546
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3662 |
/* Skip monorail multiplier - no space in result */ |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3663 |
} |
10002
87148ad75853
(svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents:
10001
diff
changeset
|
3664 |
SB(*value, 16, 8, GetRailTypeInfo(RAILTYPE_MAGLEV)->cost_multiplier); // maglev |
8546
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3665 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3666 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3667 |
case 0x11: // current rail tool type |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3668 |
*value = 0; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3669 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3670 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3671 |
case 0x12: // Game mode |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3672 |
*value = _game_mode; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3673 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3674 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3675 |
/* case 0x13: // Tile refresh offset to left not implemented */ |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3676 |
/* case 0x14: // Tile refresh offset to right not implemented */ |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3677 |
/* case 0x15: // Tile refresh offset upwards not implemented */ |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3678 |
/* case 0x16: // Tile refresh offset downwards not implemented */ |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3679 |
/* case 0x17: // temperate snow line not implemented */ |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3680 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3681 |
case 0x1A: // Always -1 |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3682 |
*value = UINT_MAX; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3683 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3684 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3685 |
case 0x1B: // Display options |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3686 |
*value = GB(_display_opt, 0, 6); |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3687 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3688 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3689 |
case 0x1D: // TTD Platform, 00=TTDPatch, 01=OpenTTD |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3690 |
*value = 1; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3691 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3692 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3693 |
case 0x1E: // Miscellaneous GRF features |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3694 |
*value = _misc_grf_features; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3695 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3696 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3697 |
/* case 0x1F: // locale dependent settings not implemented */ |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3698 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3699 |
case 0x20: // snow line height |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
3700 |
*value = _settings_game.game_creation.landscape == LT_ARCTIC ? GetSnowLine() : 0xFF; |
8546
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3701 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3702 |
|
9085
8b3897a75aed
(svn r12944) -Codechange: use rev.h instead of externs at many places
smatz
parents:
9073
diff
changeset
|
3703 |
case 0x21: // OpenTTD version |
8546
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3704 |
*value = _openttd_newgrf_version; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3705 |
return true; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3706 |
|
8753
82cbcde494d8
(svn r12449) -Feature[newGRF]: Add support for var A2/22 for action 7/9/D: Diificulty level
belugas
parents:
8695
diff
changeset
|
3707 |
case 0x22: // difficulty level |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
3708 |
*value = _settings_game.difficulty.diff_level; |
8753
82cbcde494d8
(svn r12449) -Feature[newGRF]: Add support for var A2/22 for action 7/9/D: Diificulty level
belugas
parents:
8695
diff
changeset
|
3709 |
return true; |
82cbcde494d8
(svn r12449) -Feature[newGRF]: Add support for var A2/22 for action 7/9/D: Diificulty level
belugas
parents:
8695
diff
changeset
|
3710 |
|
9458
9b2af80a696f
(svn r13376) -Feature: Add access to current long year and date from Action 7/9/D and VarAction2 (23/24 or A3/A4)
belugas
parents:
9456
diff
changeset
|
3711 |
case 0x23: // long format date |
9b2af80a696f
(svn r13376) -Feature: Add access to current long year and date from Action 7/9/D and VarAction2 (23/24 or A3/A4)
belugas
parents:
9456
diff
changeset
|
3712 |
*value = _date; |
9b2af80a696f
(svn r13376) -Feature: Add access to current long year and date from Action 7/9/D and VarAction2 (23/24 or A3/A4)
belugas
parents:
9456
diff
changeset
|
3713 |
return true; |
9b2af80a696f
(svn r13376) -Feature: Add access to current long year and date from Action 7/9/D and VarAction2 (23/24 or A3/A4)
belugas
parents:
9456
diff
changeset
|
3714 |
|
9b2af80a696f
(svn r13376) -Feature: Add access to current long year and date from Action 7/9/D and VarAction2 (23/24 or A3/A4)
belugas
parents:
9456
diff
changeset
|
3715 |
case 0x24: // long format year |
9b2af80a696f
(svn r13376) -Feature: Add access to current long year and date from Action 7/9/D and VarAction2 (23/24 or A3/A4)
belugas
parents:
9456
diff
changeset
|
3716 |
*value = _cur_year; |
9b2af80a696f
(svn r13376) -Feature: Add access to current long year and date from Action 7/9/D and VarAction2 (23/24 or A3/A4)
belugas
parents:
9456
diff
changeset
|
3717 |
return true; |
9b2af80a696f
(svn r13376) -Feature: Add access to current long year and date from Action 7/9/D and VarAction2 (23/24 or A3/A4)
belugas
parents:
9456
diff
changeset
|
3718 |
|
8546
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3719 |
default: return false; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3720 |
} |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3721 |
} |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3722 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3723 |
static uint32 GetParamVal(byte param, uint32 *cond_val) |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3724 |
{ |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3725 |
/* First handle variable common with VarAction2 */ |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3726 |
uint32 value; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3727 |
if (GetGlobalVariable(param - 0x80, &value)) return value; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3728 |
|
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3729 |
/* Non-common variable */ |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3730 |
switch (param) { |
6813
4ad1ec93dd64
(svn r10052) -Codechange: Support reserve/activate stage bits of action 7/9 variable 84.
peter1138
parents:
6806
diff
changeset
|
3731 |
case 0x84: { // GRF loading stage |
4ad1ec93dd64
(svn r10052) -Codechange: Support reserve/activate stage bits of action 7/9 variable 84.
peter1138
parents:
6806
diff
changeset
|
3732 |
uint32 res = 0; |
4ad1ec93dd64
(svn r10052) -Codechange: Support reserve/activate stage bits of action 7/9 variable 84.
peter1138
parents:
6806
diff
changeset
|
3733 |
|
7931
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7929
diff
changeset
|
3734 |
if (_cur_stage > GLS_INIT) SetBit(res, 0); |
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7929
diff
changeset
|
3735 |
if (_cur_stage == GLS_RESERVE) SetBit(res, 8); |
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7929
diff
changeset
|
3736 |
if (_cur_stage == GLS_ACTIVATION) SetBit(res, 9); |
6813
4ad1ec93dd64
(svn r10052) -Codechange: Support reserve/activate stage bits of action 7/9 variable 84.
peter1138
parents:
6806
diff
changeset
|
3737 |
return res; |
4ad1ec93dd64
(svn r10052) -Codechange: Support reserve/activate stage bits of action 7/9 variable 84.
peter1138
parents:
6806
diff
changeset
|
3738 |
} |
3806 | 3739 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3740 |
case 0x85: // TTDPatch flags, only for bit tests |
3811
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3741 |
if (cond_val == NULL) { |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3742 |
/* Supported in Action 0x07 and 0x09, not 0x0D */ |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3743 |
return 0; |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3744 |
} else { |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3745 |
uint32 param_val = _ttdpatch_flags[*cond_val / 0x20]; |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3746 |
*cond_val %= 0x20; |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3747 |
return param_val; |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
3748 |
} |
3806 | 3749 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
3750 |
case 0x88: // GRF ID check |
3806 | 3751 |
return 0; |
3752 |
||
8546
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
3753 |
/* case 0x99: Global ID offest not implemented */ |
7780
12ef69de4e60
(svn r11330) -Add: OTTD version checking for NewGRFs. This allows NewGRFs to do something different for different versions of OpenTTD, like disabling it for too low versions or loading different graphics.
rubidium
parents:
7772
diff
changeset
|
3754 |
|
3806 | 3755 |
default: |
3756 |
/* GRF Parameter */ |
|
3757 |
if (param < 0x80) return _cur_grffile->param[param]; |
|
3758 |
||
3759 |
/* In-game variable. */ |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3760 |
grfmsg(1, "Unsupported in-game variable 0x%02X", param); |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
3761 |
return UINT_MAX; |
3806 | 3762 |
} |
3763 |
} |
|
3764 |
||
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3765 |
/* Action 0x06 */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
3766 |
static void CfgApply(byte *buf, size_t len) |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3767 |
{ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3768 |
/* <06> <param-num> <param-size> <offset> ... <FF> |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3769 |
* |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3770 |
* B param-num Number of parameter to substitute (First = "zero") |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3771 |
* Ignored if that parameter was not specified in newgrf.cfg |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3772 |
* B param-size How many bytes to replace. If larger than 4, the |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3773 |
* bytes of the following parameter are used. In that |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3774 |
* case, nothing is applied unless *all* parameters |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3775 |
* were specified. |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3776 |
* B offset Offset into data from beginning of next sprite |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3777 |
* to place where parameter is to be stored. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3778 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3779 |
/* Preload the next sprite */ |
9390
88d36f907e96
(svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium
parents:
9358
diff
changeset
|
3780 |
size_t pos = FioGetPos(); |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3781 |
uint16 num = FioReadWord(); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3782 |
uint8 type = FioReadByte(); |
9947
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
3783 |
byte *preload_sprite = NULL; |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3784 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3785 |
/* Check if the sprite is a pseudo sprite. We can't operate on real sprites. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3786 |
if (type == 0xFF) { |
9947
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
3787 |
preload_sprite = MallocT<byte>(num); |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
3788 |
FioReadBlock(preload_sprite, num); |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3789 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3790 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3791 |
/* Reset the file position to the start of the next sprite */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3792 |
FioSeekTo(pos, SEEK_SET); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3793 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3794 |
if (type != 0xFF) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3795 |
grfmsg(2, "CfgApply: Ignoring (next sprite is real, unsupported)"); |
9947
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
3796 |
free(preload_sprite); |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3797 |
return; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3798 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3799 |
|
9947
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
3800 |
GRFLocation location(_cur_grfconfig->grfid, _nfo_line + 1); |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
3801 |
GRFLineToSpriteOverride::iterator it = _grf_line_to_action6_sprite_override.find(location); |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
3802 |
if (it != _grf_line_to_action6_sprite_override.end()) { |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
3803 |
free(preload_sprite); |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
3804 |
preload_sprite = _grf_line_to_action6_sprite_override[location]; |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
3805 |
} else { |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
3806 |
_grf_line_to_action6_sprite_override[location] = preload_sprite; |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
3807 |
} |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
3808 |
|
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3809 |
/* Now perform the Action 0x06 on our data. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3810 |
buf++; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3811 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3812 |
for (;;) { |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3813 |
uint i; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3814 |
uint param_num; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3815 |
uint param_size; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3816 |
uint offset; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3817 |
bool add_value; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3818 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3819 |
/* Read the parameter to apply. 0xFF indicates no more data to change. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3820 |
param_num = grf_load_byte(&buf); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3821 |
if (param_num == 0xFF) break; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3822 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3823 |
/* Get the size of the parameter to use. If the size covers multiple |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3824 |
* double words, sequential parameter values are used. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3825 |
param_size = grf_load_byte(&buf); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3826 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3827 |
/* Bit 7 of param_size indicates we should add to the original value |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3828 |
* instead of replacing it. */ |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
3829 |
add_value = HasBit(param_size, 7); |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3830 |
param_size = GB(param_size, 0, 7); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3831 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3832 |
/* Where to apply the data to within the pseudo sprite data. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3833 |
offset = grf_load_extended(&buf); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3834 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3835 |
/* If the parameter is a GRF parameter (not an internal variable) check |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3836 |
* if it (and all further sequential parameters) has been defined. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3837 |
if (param_num < 0x80 && (param_num + (param_size - 1) / 4) >= _cur_grffile->param_end) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3838 |
grfmsg(2, "CfgApply: Ignoring (param %d not set)", (param_num + (param_size - 1) / 4)); |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3839 |
break; |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3840 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3841 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
3842 |
grfmsg(8, "CfgApply: Applying %u bytes from parameter 0x%02X at offset 0x%04X", param_size, param_num, offset); |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3843 |
|
6652
ab91aefc7c0f
(svn r9883) -Fix (r4965): [NewGRF] Check for overflow and carry over when adding to the existing value.
peter1138
parents:
6649
diff
changeset
|
3844 |
bool carry = false; |
10421
7791220faa40
(svn r14674) -Fix (r4965): Check sprite size when executing action 6.
frosch
parents:
10208
diff
changeset
|
3845 |
for (i = 0; i < param_size && offset + i < num; i++) { |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3846 |
uint32 value = GetParamVal(param_num + i / 4, NULL); |
6652
ab91aefc7c0f
(svn r9883) -Fix (r4965): [NewGRF] Check for overflow and carry over when adding to the existing value.
peter1138
parents:
6649
diff
changeset
|
3847 |
/* Reset carry flag for each iteration of the variable (only really |
ab91aefc7c0f
(svn r9883) -Fix (r4965): [NewGRF] Check for overflow and carry over when adding to the existing value.
peter1138
parents:
6649
diff
changeset
|
3848 |
* matters if param_size is greater than 4) */ |
ab91aefc7c0f
(svn r9883) -Fix (r4965): [NewGRF] Check for overflow and carry over when adding to the existing value.
peter1138
parents:
6649
diff
changeset
|
3849 |
if (i == 0) carry = false; |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3850 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3851 |
if (add_value) { |
9947
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
3852 |
uint new_value = preload_sprite[offset + i] + GB(value, (i % 4) * 8, 8) + (carry ? 1 : 0); |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
3853 |
preload_sprite[offset + i] = GB(new_value, 0, 8); |
6652
ab91aefc7c0f
(svn r9883) -Fix (r4965): [NewGRF] Check for overflow and carry over when adding to the existing value.
peter1138
parents:
6649
diff
changeset
|
3854 |
/* Check if the addition overflowed */ |
ab91aefc7c0f
(svn r9883) -Fix (r4965): [NewGRF] Check for overflow and carry over when adding to the existing value.
peter1138
parents:
6649
diff
changeset
|
3855 |
carry = new_value >= 256; |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3856 |
} else { |
9947
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
3857 |
preload_sprite[offset + i] = GB(value, (i % 4) * 8, 8); |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3858 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3859 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3860 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3861 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
3862 |
|
9556
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3863 |
/** |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3864 |
* Disable a static NewGRF when it is influencing another (non-static) |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3865 |
* NewGRF as this could cause desyncs. |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3866 |
* |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3867 |
* We could just tell the NewGRF querying that the file doesn't exist, |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3868 |
* but that might give unwanted results. Disabling the NewGRF gives the |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3869 |
* best result as no NewGRF author can complain about that. |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3870 |
* @param c the NewGRF to disable. |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3871 |
*/ |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3872 |
static void DisableStaticNewGRFInfluencingNonStaticNewGRFs(GRFConfig *c) |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3873 |
{ |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3874 |
if (c->error != NULL) { |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3875 |
free(c->error->custom_message); |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3876 |
free(c->error->data); |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3877 |
free(c->error); |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3878 |
} |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3879 |
c->status = GCS_DISABLED; |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3880 |
c->error = CallocT<GRFError>(1); |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3881 |
c->error->data = strdup(_cur_grfconfig->name); |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3882 |
c->error->severity = STR_NEWGRF_ERROR_MSG_FATAL; |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3883 |
c->error->message = STR_NEWGRF_ERROR_STATIC_GRF_CAUSES_DESYNC; |
9619
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
3884 |
|
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
3885 |
ClearTemporaryNewGRFData(); |
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
3886 |
_skip_sprites = -1; |
9556
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3887 |
} |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3888 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3889 |
/* Action 0x07 */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3890 |
/* Action 0x09 */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
3891 |
static void SkipIf(byte *buf, size_t len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3892 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3893 |
/* <07/09> <param-num> <param-size> <condition-type> <value> <num-sprites> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3894 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3895 |
* B param-num |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3896 |
* B param-size |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3897 |
* B condition-type |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3898 |
* V value |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3899 |
* B num-sprites */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3900 |
/* TODO: More params. More condition types. */ |
2336
be477602455a
(svn r2862) Return a proper version number, when testing the TTDPatch version in the SkipIf action. Pretend to be version 2.0.1 alpha 49 for now.
tron
parents:
2324
diff
changeset
|
3901 |
uint32 cond_val = 0; |
3806 | 3902 |
uint32 mask = 0; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3903 |
bool result; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3904 |
|
5590
6a0c2739e124
(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:
5587
diff
changeset
|
3905 |
if (!check_length(len, 6, "SkipIf")) return; |
3714
aa27d8962f6a
(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses
peter1138
parents:
3712
diff
changeset
|
3906 |
buf++; |
6281 | 3907 |
uint8 param = grf_load_byte(&buf); |
3908 |
uint8 paramsize = grf_load_byte(&buf); |
|
3909 |
uint8 condtype = grf_load_byte(&buf); |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3910 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3911 |
if (condtype < 2) { |
1611 | 3912 |
/* Always 1 for bit tests, the given value should be ignored. */ |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3913 |
paramsize = 1; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3914 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3915 |
|
1611 | 3916 |
switch (paramsize) { |
3806 | 3917 |
case 4: cond_val = grf_load_dword(&buf); mask = 0xFFFFFFFF; break; |
3918 |
case 2: cond_val = grf_load_word(&buf); mask = 0x0000FFFF; break; |
|
3919 |
case 1: cond_val = grf_load_byte(&buf); mask = 0x000000FF; break; |
|
1611 | 3920 |
default: break; |
3921 |
} |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3922 |
|
3806 | 3923 |
if (param < 0x80 && _cur_grffile->param_end <= param) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3924 |
grfmsg(7, "SkipIf: Param %d undefined, skipping test", param); |
3806 | 3925 |
return; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3926 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
3927 |
|
6281 | 3928 |
uint32 param_val = GetParamVal(param, &cond_val); |
3806 | 3929 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3930 |
grfmsg(7, "SkipIf: Test condtype %d, param 0x%08X, condval 0x%08X", condtype, param_val, cond_val); |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3931 |
|
7808
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3932 |
/* |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3933 |
* Parameter (variable in specs) 0x88 can only have GRF ID checking |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3934 |
* conditions, except conditions 0x0B and 0x0C (cargo availability) |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3935 |
* as those ignore the parameter. So, when the condition type is |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3936 |
* either of those, the specific variable 0x88 code is skipped, so |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3937 |
* the "general" code for the cargo availability conditions kicks in. |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3938 |
*/ |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3939 |
if (param == 0x88 && condtype != 0x0B && condtype != 0x0C) { |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3940 |
/* GRF ID checks */ |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3941 |
|
9556
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3942 |
GRFConfig *c = GetGRFConfig(cond_val); |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3943 |
|
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3944 |
if (c != NULL && HasBit(c->flags, GCF_STATIC) && !HasBit(_cur_grfconfig->flags, GCF_STATIC) && c->status != GCS_DISABLED && _networking) { |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3945 |
DisableStaticNewGRFInfluencingNonStaticNewGRFs(c); |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3946 |
c = NULL; |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
3947 |
} |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3948 |
|
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3949 |
if (condtype != 10 && c == NULL) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
3950 |
grfmsg(7, "SkipIf: GRFID 0x%08X unknown, skipping test", BSWAP32(cond_val)); |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3951 |
return; |
5234
980aa61260aa
(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
|
3952 |
} |
980aa61260aa
(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
|
3953 |
|
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3954 |
switch (condtype) { |
7808
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3955 |
/* Tests 0x06 to 0x0A are only for param 0x88, GRFID checks */ |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3956 |
case 0x06: // Is GRFID active? |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
3957 |
result = c->status == GCS_ACTIVATED; |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3958 |
break; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3959 |
|
7808
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3960 |
case 0x07: // Is GRFID non-active? |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
3961 |
result = c->status != GCS_ACTIVATED; |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3962 |
break; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3963 |
|
7808
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3964 |
case 0x08: // GRFID is not but will be active? |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
3965 |
result = c->status == GCS_INITIALISED; |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3966 |
break; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3967 |
|
7808
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3968 |
case 0x09: // GRFID is or will be active? |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
3969 |
result = c->status == GCS_ACTIVATED || c->status == GCS_INITIALISED; |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3970 |
break; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3971 |
|
7808
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3972 |
case 0x0A: // GRFID is not nor will be active |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3973 |
/* This is the only condtype that doesn't get ignored if the GRFID is not found */ |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
3974 |
result = c == NULL || c->flags == GCS_DISABLED || c->status == GCS_NOT_FOUND; |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3975 |
break; |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3976 |
|
7808
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3977 |
default: grfmsg(1, "SkipIf: Unsupported GRF condition type %02X. Ignoring", condtype); return; |
5234
980aa61260aa
(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
|
3978 |
} |
5452
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3979 |
} else { |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3980 |
/* Parameter or variable tests */ |
089bef783925
(svn r7711) -Fix (r7354): NewGRF Action 7, GRF check condition 10 didn't ignore unknown GRF IDs. Also separate GRF ID conditions
peter1138
parents:
5430
diff
changeset
|
3981 |
switch (condtype) { |
7808
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3982 |
case 0x00: result = !!(param_val & (1 << cond_val)); |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3983 |
break; |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3984 |
case 0x01: result = !(param_val & (1 << cond_val)); |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3985 |
break; |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3986 |
case 0x02: result = (param_val & mask) == cond_val; |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3987 |
break; |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3988 |
case 0x03: result = (param_val & mask) != cond_val; |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3989 |
break; |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3990 |
case 0x04: result = (param_val & mask) < cond_val; |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3991 |
break; |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3992 |
case 0x05: result = (param_val & mask) > cond_val; |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3993 |
break; |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3994 |
case 0x0B: result = GetCargoIDByLabel(BSWAP32(cond_val)) == CT_INVALID; |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3995 |
break; |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3996 |
case 0x0C: result = GetCargoIDByLabel(BSWAP32(cond_val)) != CT_INVALID; |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3997 |
break; |
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3998 |
|
07640f0ae961
(svn r11358) -Fix: condition types 0x0B and 0x0C are also valid for variable 0x88 in action 7/9.
rubidium
parents:
7805
diff
changeset
|
3999 |
default: grfmsg(1, "SkipIf: Unsupported condition type %02X. Ignoring", condtype); return; |
5234
980aa61260aa
(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
|
4000 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4001 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4002 |
|
1607
fd027776f222
(svn r2111) So, result is bool therefore no need for this horrible == 0 thing.
pasky
parents:
1606
diff
changeset
|
4003 |
if (!result) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
4004 |
grfmsg(2, "SkipIf: Not skipping sprites, test was false"); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4005 |
return; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4006 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4007 |
|
6281 | 4008 |
uint8 numsprites = grf_load_byte(&buf); |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4009 |
|
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4010 |
/* numsprites can be a GOTO label if it has been defined in the GRF |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4011 |
* file. The jump will always be the first matching label that follows |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4012 |
* the current nfo_line. If no matching label is found, the first matching |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4013 |
* label in the file is used. */ |
6281 | 4014 |
GRFLabel *choice = NULL; |
4015 |
for (GRFLabel *label = _cur_grffile->label; label != NULL; label = label->next) { |
|
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4016 |
if (label->label != numsprites) continue; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4017 |
|
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4018 |
/* Remember a goto before the current line */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4019 |
if (choice == NULL) choice = label; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4020 |
/* If we find a label here, this is definitely good */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4021 |
if (label->nfo_line > _nfo_line) { |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4022 |
choice = label; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4023 |
break; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4024 |
} |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4025 |
} |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4026 |
|
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4027 |
if (choice != NULL) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
4028 |
grfmsg(2, "SkipIf: Jumping to label 0x%0X at line %d, test was true", choice->label, choice->nfo_line); |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4029 |
FioSeekTo(choice->pos, SEEK_SET); |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4030 |
_nfo_line = choice->nfo_line; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4031 |
return; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4032 |
} |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4033 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
4034 |
grfmsg(2, "SkipIf: Skipping %d sprites, test was true", numsprites); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4035 |
_skip_sprites = numsprites; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4036 |
if (_skip_sprites == 0) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4037 |
/* Zero means there are no sprites to skip, so |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4038 |
* we use -1 to indicate that all further |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4039 |
* sprites should be skipped. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4040 |
_skip_sprites = -1; |
6096
aafc68ecee06
(svn r8831) -Feature: If an action 7/9 leads to skipping the rest of the file, disable the
maedhros
parents:
6095
diff
changeset
|
4041 |
|
aafc68ecee06
(svn r8831) -Feature: If an action 7/9 leads to skipping the rest of the file, disable the
maedhros
parents:
6095
diff
changeset
|
4042 |
/* If an action 8 hasn't been encountered yet, disable the grf. */ |
8089
35b1c3d3ec66
(svn r11650) -Fix: 'initialised' NewGRFs could still be deactivated in the later 'activation' pass.
rubidium
parents:
8084
diff
changeset
|
4043 |
if (_cur_grfconfig->status != GCS_ACTIVATED) { |
6925
f73d75a1f7da
(svn r10178) -Fix: Don't deactivate newgrf files when skipping the rest of the file during the initialisation stage.
maedhros
parents:
6914
diff
changeset
|
4044 |
_cur_grfconfig->status = GCS_DISABLED; |
9619
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
4045 |
ClearTemporaryNewGRFData(); |
6925
f73d75a1f7da
(svn r10178) -Fix: Don't deactivate newgrf files when skipping the rest of the file during the initialisation stage.
maedhros
parents:
6914
diff
changeset
|
4046 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4047 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4048 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4049 |
|
5317
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
4050 |
|
5502
003b36599ff8
(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:
5476
diff
changeset
|
4051 |
/* Action 0x08 (GLS_FILESCAN) */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
4052 |
static void ScanInfo(byte *buf, size_t len) |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
4053 |
{ |
6281 | 4054 |
if (!check_length(len, 8, "Info")) return; |
4055 |
buf++; |
|
4056 |
grf_load_byte(&buf); |
|
4057 |
uint32 grfid = grf_load_dword(&buf); |
|
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
4058 |
|
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
4059 |
_cur_grfconfig->grfid = grfid; |
5317
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
4060 |
|
5329
9c5e8061ea0f
(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
|
4061 |
/* GRF IDs starting with 0xFF are reserved for internal TTDPatch use */ |
7931
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7929
diff
changeset
|
4062 |
if (GB(grfid, 24, 8) == 0xFF) SetBit(_cur_grfconfig->flags, GCF_SYSTEM); |
5329
9c5e8061ea0f
(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
|
4063 |
|
5317
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
4064 |
len -= 6; |
6281 | 4065 |
const char *name = grf_load_string(&buf, len); |
8656
9731ddde8722
(svn r12317) -Fix [FS#1815]: Map string IDs that are embedded from other strings.
peter1138
parents:
8655
diff
changeset
|
4066 |
_cur_grfconfig->name = TranslateTTDPatchCodes(grfid, name); |
6186
fdb3705ca465
(svn r8964) -Codechange: use grf_load_string to read action 8 strings instead of trying to do the same manually.
rubidium
parents:
6148
diff
changeset
|
4067 |
|
fdb3705ca465
(svn r8964) -Codechange: use grf_load_string to read action 8 strings instead of trying to do the same manually.
rubidium
parents:
6148
diff
changeset
|
4068 |
len -= strlen(name) + 1; |
fdb3705ca465
(svn r8964) -Codechange: use grf_load_string to read action 8 strings instead of trying to do the same manually.
rubidium
parents:
6148
diff
changeset
|
4069 |
if (len > 0) { |
6281 | 4070 |
const char *info = grf_load_string(&buf, len); |
8656
9731ddde8722
(svn r12317) -Fix [FS#1815]: Map string IDs that are embedded from other strings.
peter1138
parents:
8655
diff
changeset
|
4071 |
_cur_grfconfig->info = TranslateTTDPatchCodes(grfid, info); |
5317
a41d1389c092
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
peter1138
parents:
5306
diff
changeset
|
4072 |
} |
5329
9c5e8061ea0f
(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
|
4073 |
|
9c5e8061ea0f
(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
|
4074 |
/* GLS_INFOSCAN only looks for the action 8, so we can skip the rest of the file */ |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
4075 |
_skip_sprites = -1; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
4076 |
} |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
4077 |
|
3640
afe6a5032f6a
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
4078 |
/* Action 0x08 */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
4079 |
static void GRFInfo(byte *buf, size_t len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4080 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4081 |
/* <08> <version> <grf-id> <name> <info> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4082 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4083 |
* B version newgrf version, currently 06 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4084 |
* 4*B grf-id globally unique ID of this .grf file |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4085 |
* S name name of this .grf set |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4086 |
* S info string describing the set, and e.g. author and copyright */ |
6281 | 4087 |
|
4088 |
if (!check_length(len, 8, "GRFInfo")) return; |
|
4089 |
buf++; |
|
4090 |
uint8 version = grf_load_byte(&buf); |
|
4091 |
uint32 grfid = grf_load_dword(&buf); |
|
4092 |
const char *name = grf_load_string(&buf, len - 6); |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4093 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4094 |
_cur_grffile->grfid = grfid; |
3640
afe6a5032f6a
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
4095 |
_cur_grffile->grf_version = version; |
6806
c0faecfdc59f
(svn r10045) -Codechange: Process Action 8 during GLS_RESERVATION to allow Action 7/Action 9s to work properly
peter1138
parents:
6805
diff
changeset
|
4096 |
_cur_grfconfig->status = _cur_stage < GLS_RESERVE ? GCS_INITIALISED : GCS_ACTIVATED; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4097 |
|
3711
431475cbb208
(svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents:
3709
diff
changeset
|
4098 |
/* Do swap the GRFID for displaying purposes since people expect that */ |
10066
f18e97752eeb
(svn r14233) -Feature/Fix [FS#2172]: save the palette of the loaded NewGRFs in the savegame, so joining with a server using Windows palette will make a client with the DOS palette do palette conversion and (thus) not cause a desync due to the different palettes disabling different NewGRFs.
rubidium
parents:
10063
diff
changeset
|
4099 |
DEBUG(grf, 1, "GRFInfo: Loaded GRFv%d set %08lX - %s (palette: %s)", version, BSWAP32(grfid), name, _cur_grfconfig->windows_paletted ? "Windows" : "DOS"); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4100 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4101 |
|
3640
afe6a5032f6a
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
4102 |
/* Action 0x0A */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
4103 |
static void SpriteReplace(byte *buf, size_t len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4104 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4105 |
/* <0A> <num-sets> <set1> [<set2> ...] |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4106 |
* <set>: <num-sprites> <first-sprite> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4107 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4108 |
* B num-sets How many sets of sprites to replace. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4109 |
* Each set: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4110 |
* B num-sprites How many sprites are in this set |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4111 |
* W first-sprite First sprite number to replace */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4112 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4113 |
buf++; // skip action byte |
6281 | 4114 |
uint8 num_sets = grf_load_byte(&buf); |
4115 |
||
4116 |
for (uint i = 0; i < num_sets; i++) { |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4117 |
uint8 num_sprites = grf_load_byte(&buf); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4118 |
uint16 first_sprite = grf_load_word(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4119 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
4120 |
grfmsg(2, "SpriteReplace: [Set %d] Changing %d sprites, beginning with %d", |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4121 |
i, num_sprites, first_sprite |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
4122 |
); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4123 |
|
6281 | 4124 |
for (uint j = 0; j < num_sprites; j++) { |
8183
2340115d8a6b
(svn r11746) -Fix(r11727): Make sure that action 0A does follow the same new ordering of shore sprites. It was not considered in the missing shore patch
belugas
parents:
8165
diff
changeset
|
4125 |
int load_index = first_sprite + j; |
7953
db4cd9ef0efc
(svn r11509) -Fix: off-by-one error in some sprite numbers; increase sprite number counter before loading the next sprite instead of after doing so.
rubidium
parents:
7941
diff
changeset
|
4126 |
_nfo_line++; |
8183
2340115d8a6b
(svn r11746) -Fix(r11727): Make sure that action 0A does follow the same new ordering of shore sprites. It was not considered in the missing shore patch
belugas
parents:
8165
diff
changeset
|
4127 |
LoadNextSprite(load_index, _file_index, _nfo_line); // XXX |
2340115d8a6b
(svn r11746) -Fix(r11727): Make sure that action 0A does follow the same new ordering of shore sprites. It was not considered in the missing shore patch
belugas
parents:
8165
diff
changeset
|
4128 |
|
8403
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
4129 |
/* Shore sprites now located at different addresses. |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
4130 |
* So detect when the old ones get replaced. */ |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
4131 |
if (IsInsideMM(load_index, SPR_ORIGINALSHORE_START, SPR_ORIGINALSHORE_END + 1)) { |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
4132 |
if (_loaded_newgrf_features.shore != SHORE_REPLACE_ACTION_5) _loaded_newgrf_features.shore = SHORE_REPLACE_ACTION_A; |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
4133 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4134 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4135 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4136 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4137 |
|
6529
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
4138 |
/* Action 0x0A (SKIP) */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
4139 |
static void SkipActA(byte *buf, size_t len) |
6529
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
4140 |
{ |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
4141 |
buf++; |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
4142 |
uint8 num_sets = grf_load_byte(&buf); |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
4143 |
|
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
4144 |
for (uint i = 0; i < num_sets; i++) { |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
4145 |
/* Skip the sprites this replaces */ |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
4146 |
_skip_sprites += grf_load_byte(&buf); |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
4147 |
/* But ignore where they go */ |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
4148 |
grf_load_word(&buf); |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
4149 |
} |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
4150 |
|
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
4151 |
grfmsg(3, "SkipActA: Skipping %d sprites", _skip_sprites); |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
4152 |
} |
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
4153 |
|
3715
b696b84baf30
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
4154 |
/* Action 0x0B */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
4155 |
static void GRFLoadError(byte *buf, size_t len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4156 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4157 |
/* <0B> <severity> <language-id> <message-id> [<message...> 00] [<data...>] 00 [<parnum>] |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4158 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4159 |
* B severity 00: notice, contine loading grf file |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4160 |
* 01: warning, continue loading grf file |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4161 |
* 02: error, but continue loading grf file, and attempt |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4162 |
* loading grf again when loading or starting next game |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4163 |
* 03: error, abort loading and prevent loading again in |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4164 |
* the future (only when restarting the patch) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4165 |
* B language-id see action 4, use 1F for built-in error messages |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4166 |
* B message-id message to show, see below |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4167 |
* S message for custom messages (message-id FF), text of the message |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4168 |
* not present for built-in messages. |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4169 |
* V data additional data for built-in (or custom) messages |
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4170 |
* B parnum parameter numbers to be shown in the message (maximum of 2) */ |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4171 |
|
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4172 |
static const StringID msgstr[] = { |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4173 |
STR_NEWGRF_ERROR_VERSION_NUMBER, |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4174 |
STR_NEWGRF_ERROR_DOS_OR_WINDOWS, |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4175 |
STR_NEWGRF_ERROR_UNSET_SWITCH, |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4176 |
STR_NEWGRF_ERROR_INVALID_PARAMETER, |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4177 |
STR_NEWGRF_ERROR_LOAD_BEFORE, |
7780
12ef69de4e60
(svn r11330) -Add: OTTD version checking for NewGRFs. This allows NewGRFs to do something different for different versions of OpenTTD, like disabling it for too low versions or loading different graphics.
rubidium
parents:
7772
diff
changeset
|
4178 |
STR_NEWGRF_ERROR_LOAD_AFTER, |
12ef69de4e60
(svn r11330) -Add: OTTD version checking for NewGRFs. This allows NewGRFs to do something different for different versions of OpenTTD, like disabling it for too low versions or loading different graphics.
rubidium
parents:
7772
diff
changeset
|
4179 |
STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER, |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4180 |
}; |
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
4181 |
|
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4182 |
static const StringID sevstr[] = { |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4183 |
STR_NEWGRF_ERROR_MSG_INFO, |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4184 |
STR_NEWGRF_ERROR_MSG_WARNING, |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4185 |
STR_NEWGRF_ERROR_MSG_ERROR, |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4186 |
STR_NEWGRF_ERROR_MSG_FATAL |
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
4187 |
}; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4188 |
|
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4189 |
if (!check_length(len, 6, "GRFLoadError")) return; |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4190 |
|
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4191 |
/* For now we can only show one message per newgrf file. */ |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4192 |
if (_cur_grfconfig->error != NULL) return; |
6090
dd413a1ccb6b
(svn r8825) -Fix: Make sure strings read from newgrf files are 0 terminated and 0
maedhros
parents:
6062
diff
changeset
|
4193 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4194 |
buf++; // Skip the action byte. |
6095
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4195 |
byte severity = grf_load_byte(&buf); |
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4196 |
byte lang = grf_load_byte(&buf); |
6095
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4197 |
byte message_id = grf_load_byte(&buf); |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4198 |
len -= 4; |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4199 |
|
6873
b4d0648edd29
(svn r10114) -Fix: Only load newgrf error messages if the language matches the current
maedhros
parents:
6870
diff
changeset
|
4200 |
/* Skip the error if it isn't valid for the current language. */ |
b4d0648edd29
(svn r10114) -Fix: Only load newgrf error messages if the language matches the current
maedhros
parents:
6870
diff
changeset
|
4201 |
if (!CheckGrfLangID(lang, _cur_grffile->grf_version)) return; |
b4d0648edd29
(svn r10114) -Fix: Only load newgrf error messages if the language matches the current
maedhros
parents:
6870
diff
changeset
|
4202 |
|
6095
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4203 |
/* Skip the error until the activation stage unless bit 7 of the severity |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4204 |
* is set. */ |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
4205 |
if (!HasBit(severity, 7) && _cur_stage == GLS_INIT) { |
6805
3a516a89ddb4
(svn r10044) -Fix: Minor NewGRF debug message fixes, and skip sprites of an unsupported Action 5 feature.
peter1138
parents:
6781
diff
changeset
|
4206 |
grfmsg(7, "GRFLoadError: Skipping non-fatal GRFLoadError in stage %d", _cur_stage); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4207 |
return; |
3588
69817310ddf8
(svn r4474) - NewGRF: Skip non-fatal errors when not in stage 2.
peter1138
parents:
3577
diff
changeset
|
4208 |
} |
7929
6c9b25842b0f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
7928
diff
changeset
|
4209 |
ClrBit(severity, 7); |
6095
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4210 |
|
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4211 |
if (severity >= lengthof(sevstr)) { |
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4212 |
grfmsg(7, "GRFLoadError: Invalid severity id %d. Setting to 2 (non-fatal error).", severity); |
6095
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4213 |
severity = 2; |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4214 |
} else if (severity == 3) { |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4215 |
/* This is a fatal error, so make sure the GRF is deactivated and no |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4216 |
* more of it gets loaded. */ |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
4217 |
_cur_grfconfig->status = GCS_DISABLED; |
9619
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
4218 |
ClearTemporaryNewGRFData(); |
6095
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4219 |
_skip_sprites = -1; |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4220 |
} |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4221 |
|
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4222 |
if (message_id >= lengthof(msgstr) && message_id != 0xFF) { |
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4223 |
grfmsg(7, "GRFLoadError: Invalid message id."); |
6095
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4224 |
return; |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4225 |
} |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4226 |
|
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4227 |
if (len <= 1) { |
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4228 |
grfmsg(7, "GRFLoadError: No message data supplied."); |
6095
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4229 |
return; |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4230 |
} |
d02d52f58ba6
(svn r8830) -Feature: Stop loading and disable the current newgrf if a fatal error message
maedhros
parents:
6091
diff
changeset
|
4231 |
|
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4232 |
GRFError *error = CallocT<GRFError>(1); |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4233 |
|
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4234 |
error->severity = sevstr[severity]; |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4235 |
|
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4236 |
if (message_id == 0xFF) { |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4237 |
/* This is a custom error message. */ |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4238 |
const char *message = grf_load_string(&buf, len); |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4239 |
len -= (strlen(message) + 1); |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4240 |
|
8656
9731ddde8722
(svn r12317) -Fix [FS#1815]: Map string IDs that are embedded from other strings.
peter1138
parents:
8655
diff
changeset
|
4241 |
error->custom_message = TranslateTTDPatchCodes(_cur_grffile->grfid, message); |
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4242 |
} else { |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4243 |
error->message = msgstr[message_id]; |
6103
d38163ddfef9
(svn r8838) -Feature: Show newgrf error messages loaded in Action B in the newgrf gui
maedhros
parents:
6096
diff
changeset
|
4244 |
} |
d38163ddfef9
(svn r8838) -Feature: Show newgrf error messages loaded in Action B in the newgrf gui
maedhros
parents:
6096
diff
changeset
|
4245 |
|
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4246 |
if (len > 0) { |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4247 |
const char *data = grf_load_string(&buf, len); |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4248 |
len -= (strlen(data) + 1); |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4249 |
|
8656
9731ddde8722
(svn r12317) -Fix [FS#1815]: Map string IDs that are embedded from other strings.
peter1138
parents:
8655
diff
changeset
|
4250 |
error->data = TranslateTTDPatchCodes(_cur_grffile->grfid, data); |
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4251 |
} |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4252 |
|
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4253 |
/* Only two parameter numbers can be used in the string. */ |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4254 |
uint i = 0; |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4255 |
for (; i < 2 && len > 0; i++) { |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4256 |
error->param_number[i] = grf_load_byte(&buf); |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4257 |
len--; |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4258 |
} |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4259 |
error->num_params = i; |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4260 |
|
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6128
diff
changeset
|
4261 |
_cur_grfconfig->error = error; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4262 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4263 |
|
3715
b696b84baf30
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
4264 |
/* Action 0x0C */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
4265 |
static void GRFComment(byte *buf, size_t len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4266 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4267 |
/* <0C> [<ignored...>] |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4268 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4269 |
* V ignored Anything following the 0C is ignored */ |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4270 |
|
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4271 |
if (len == 1) return; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4272 |
|
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
4273 |
size_t text_len = len - 1; |
6107 | 4274 |
const char *text = (const char*)(buf + 1); |
4275 |
grfmsg(2, "GRFComment: %.*s", text_len, text); |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4276 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4277 |
|
5525
c4aadd23c749
(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:
5502
diff
changeset
|
4278 |
/* Action 0x0D (GLS_SAFETYSCAN) */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
4279 |
static void SafeParamSet(byte *buf, size_t len) |
5525
c4aadd23c749
(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:
5502
diff
changeset
|
4280 |
{ |
5590
6a0c2739e124
(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:
5587
diff
changeset
|
4281 |
if (!check_length(len, 5, "SafeParamSet")) return; |
5525
c4aadd23c749
(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:
5502
diff
changeset
|
4282 |
buf++; |
6281 | 4283 |
uint8 target = grf_load_byte(&buf); |
5525
c4aadd23c749
(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:
5502
diff
changeset
|
4284 |
|
c4aadd23c749
(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:
5502
diff
changeset
|
4285 |
/* Only writing GRF parameters is considered safe */ |
c4aadd23c749
(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:
5502
diff
changeset
|
4286 |
if (target < 0x80) return; |
c4aadd23c749
(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:
5502
diff
changeset
|
4287 |
|
c4aadd23c749
(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:
5502
diff
changeset
|
4288 |
/* GRM could be unsafe, but as here it can only happen after other GRFs |
c4aadd23c749
(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:
5502
diff
changeset
|
4289 |
* are loaded, it should be okay. If the GRF tried to use the slots it |
c4aadd23c749
(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:
5502
diff
changeset
|
4290 |
* reserved, it would be marked unsafe anyway. GRM for (e.g. bridge) |
c4aadd23c749
(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:
5502
diff
changeset
|
4291 |
* sprites is considered safe. */ |
c4aadd23c749
(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:
5502
diff
changeset
|
4292 |
|
7931
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7929
diff
changeset
|
4293 |
SetBit(_cur_grfconfig->flags, GCF_UNSAFE); |
5525
c4aadd23c749
(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:
5502
diff
changeset
|
4294 |
|
c4aadd23c749
(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:
5502
diff
changeset
|
4295 |
/* Skip remainder of GRF */ |
c4aadd23c749
(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:
5502
diff
changeset
|
4296 |
_skip_sprites = -1; |
c4aadd23c749
(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:
5502
diff
changeset
|
4297 |
} |
c4aadd23c749
(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:
5502
diff
changeset
|
4298 |
|
6515
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4299 |
|
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4300 |
static uint32 GetPatchVariable(uint8 param) |
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4301 |
{ |
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4302 |
switch (param) { |
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4303 |
/* start year - 1920 */ |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
4304 |
case 0x0B: return max(_settings_game.game_creation.starting_year, ORIGINAL_BASE_YEAR) - ORIGINAL_BASE_YEAR; |
8391
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4305 |
|
6515
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4306 |
/* freight trains weight factor */ |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
4307 |
case 0x0E: return _settings_game.vehicle.freight_trains; |
8391
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4308 |
|
6515
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4309 |
/* empty wagon speed increase */ |
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4310 |
case 0x0F: return 0; |
8391
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4311 |
|
8649
a7a8060fb837
(svn r12295) -Codechange: Make plane speed option available to NewGRFs
peter1138
parents:
8626
diff
changeset
|
4312 |
/* plane speed factor; our patch option is reversed from TTDPatch's, |
a7a8060fb837
(svn r12295) -Codechange: Make plane speed option available to NewGRFs
peter1138
parents:
8626
diff
changeset
|
4313 |
* the following is good for 1x, 2x and 4x (most common?) and... |
a7a8060fb837
(svn r12295) -Codechange: Make plane speed option available to NewGRFs
peter1138
parents:
8626
diff
changeset
|
4314 |
* well not really for 3x. */ |
a7a8060fb837
(svn r12295) -Codechange: Make plane speed option available to NewGRFs
peter1138
parents:
8626
diff
changeset
|
4315 |
case 0x10: |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
4316 |
switch (_settings_game.vehicle.plane_speed) { |
8649
a7a8060fb837
(svn r12295) -Codechange: Make plane speed option available to NewGRFs
peter1138
parents:
8626
diff
changeset
|
4317 |
default: |
a7a8060fb837
(svn r12295) -Codechange: Make plane speed option available to NewGRFs
peter1138
parents:
8626
diff
changeset
|
4318 |
case 4: return 1; |
a7a8060fb837
(svn r12295) -Codechange: Make plane speed option available to NewGRFs
peter1138
parents:
8626
diff
changeset
|
4319 |
case 3: return 2; |
a7a8060fb837
(svn r12295) -Codechange: Make plane speed option available to NewGRFs
peter1138
parents:
8626
diff
changeset
|
4320 |
case 2: return 2; |
a7a8060fb837
(svn r12295) -Codechange: Make plane speed option available to NewGRFs
peter1138
parents:
8626
diff
changeset
|
4321 |
case 1: return 4; |
a7a8060fb837
(svn r12295) -Codechange: Make plane speed option available to NewGRFs
peter1138
parents:
8626
diff
changeset
|
4322 |
} |
a7a8060fb837
(svn r12295) -Codechange: Make plane speed option available to NewGRFs
peter1138
parents:
8626
diff
changeset
|
4323 |
|
8391
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4324 |
|
6515
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4325 |
/* 2CC colormap base sprite */ |
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4326 |
case 0x11: return SPR_2CCMAP_BASE; |
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4327 |
|
8391
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4328 |
/* map size: format = -MABXYSS |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4329 |
* M : the type of map |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4330 |
* bit 0 : set : squared map. Bit 1 is now not relevant |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4331 |
* clear : rectangle map. Bit 1 will indicate the bigger edge of the map |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4332 |
* bit 1 : set : Y is the bigger edge. Bit 0 is clear |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4333 |
* clear : X is the bigger edge. |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4334 |
* A : minimum edge(log2) of the map |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4335 |
* B : maximum edge(log2) of the map |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4336 |
* XY : edges(log2) of each side of the map. |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4337 |
* SS : combination of both X and Y, thus giving the size(log2) of the map |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4338 |
*/ |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4339 |
case 0x13: { |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4340 |
byte map_bits = 0; |
8393
a0ab817a8b73
(svn r11963) -Fix(r11961): Forgot to specify the meaning of the magical 6 substraction
belugas
parents:
8391
diff
changeset
|
4341 |
byte log_X = MapLogX() - 6; // substraction is required to make the minimal size (64) zero based |
8391
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4342 |
byte log_Y = MapLogY() - 6; |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4343 |
byte max_edge = max(log_X, log_Y); |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4344 |
|
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4345 |
if (log_X == log_Y) { // we have a squared map, since both edges are identical |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4346 |
SetBit(map_bits ,0); |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4347 |
} else { |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4348 |
if (max_edge == log_Y) SetBit(map_bits, 1); // edge Y been the biggest, mark it |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4349 |
} |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4350 |
|
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4351 |
return (map_bits << 24) | (min(log_X, log_Y) << 20) | (max_edge << 16) | |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4352 |
(log_X << 12) | (log_Y << 8) | (log_X + log_Y); |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4353 |
} |
193b256c681c
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas
parents:
8372
diff
changeset
|
4354 |
|
6515
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4355 |
default: |
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4356 |
grfmsg(2, "ParamSet: Unknown Patch variable 0x%02X.", param); |
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4357 |
return 0; |
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4358 |
} |
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4359 |
} |
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4360 |
|
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4361 |
|
6781
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4362 |
static uint32 PerformGRM(uint32 *grm, uint16 num_ids, uint16 count, uint8 op, uint8 target, const char *type) |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4363 |
{ |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4364 |
uint start = 0; |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4365 |
uint size = 0; |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4366 |
|
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4367 |
if (op == 6) { |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4368 |
/* Return GRFID of set that reserved ID */ |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4369 |
return grm[_cur_grffile->param[target]]; |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4370 |
} |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4371 |
|
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4372 |
/* With an operation of 2 or 3, we want to reserve a specific block of IDs */ |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4373 |
if (op == 2 || op == 3) start = _cur_grffile->param[target]; |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4374 |
|
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4375 |
for (uint i = start; i < num_ids; i++) { |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4376 |
if (grm[i] == 0) { |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4377 |
size++; |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4378 |
} else { |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4379 |
if (op == 2 || op == 3) break; |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4380 |
start = i + 1; |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4381 |
size = 0; |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4382 |
} |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4383 |
|
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4384 |
if (size == count) break; |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4385 |
} |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4386 |
|
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4387 |
if (size == count) { |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4388 |
/* Got the slot... */ |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4389 |
if (op == 0 || op == 3) { |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4390 |
grfmsg(2, "ParamSet: GRM: Reserving %d %s at %d", count, type, start); |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4391 |
for (uint i = 0; i < count; i++) grm[start + i] = _cur_grffile->grfid; |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4392 |
} |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4393 |
return start; |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4394 |
} |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4395 |
|
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4396 |
/* Unable to allocate */ |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4397 |
if (op != 4 && op != 5) { |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4398 |
/* Deactivate GRF */ |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4399 |
grfmsg(0, "ParamSet: GRM: Unable to allocate %d %s, deactivating", count, type); |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4400 |
_cur_grfconfig->status = GCS_DISABLED; |
9619
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
4401 |
ClearTemporaryNewGRFData(); |
6781
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4402 |
_skip_sprites = -1; |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4403 |
return UINT_MAX; |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4404 |
} |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4405 |
|
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4406 |
grfmsg(1, "ParamSet: GRM: Unable to allocate %d %s", count, type); |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4407 |
return UINT_MAX; |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4408 |
} |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4409 |
|
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4410 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4411 |
/* Action 0x0D */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
4412 |
static void ParamSet(byte *buf, size_t len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4413 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4414 |
/* <0D> <target> <operation> <source1> <source2> [<data>] |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4415 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4416 |
* B target parameter number where result is stored |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4417 |
* B operation operation to perform, see below |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4418 |
* B source1 first source operand |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4419 |
* B source2 second source operand |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4420 |
* D data data to use in the calculation, not necessary |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4421 |
* if both source1 and source2 refer to actual parameters |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4422 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4423 |
* Operations |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4424 |
* 00 Set parameter equal to source1 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4425 |
* 01 Addition, source1 + source2 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4426 |
* 02 Subtraction, source1 - source2 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4427 |
* 03 Unsigned multiplication, source1 * source2 (both unsigned) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4428 |
* 04 Signed multiplication, source1 * source2 (both signed) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4429 |
* 05 Unsigned bit shift, source1 by source2 (source2 taken to be a |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4430 |
* signed quantity; left shift if positive and right shift if |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4431 |
* negative, source1 is unsigned) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4432 |
* 06 Signed bit shift, source1 by source2 |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4433 |
* (source2 like in 05, and source1 as well) |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4434 |
*/ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4435 |
|
5590
6a0c2739e124
(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:
5587
diff
changeset
|
4436 |
if (!check_length(len, 5, "ParamSet")) return; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4437 |
buf++; |
6281 | 4438 |
uint8 target = grf_load_byte(&buf); |
4439 |
uint8 oper = grf_load_byte(&buf); |
|
4440 |
uint32 src1 = grf_load_byte(&buf); |
|
4441 |
uint32 src2 = grf_load_byte(&buf); |
|
4442 |
||
4443 |
uint32 data = 0; |
|
2345 | 4444 |
if (len >= 8) data = grf_load_dword(&buf); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4445 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4446 |
/* You can add 80 to the operation to make it apply only if the target |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4447 |
* is not defined yet. In this respect, a parameter is taken to be |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4448 |
* defined if any of the following applies: |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4449 |
* - it has been set to any value in the newgrf(w).cfg parameter list |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4450 |
* - it OR A PARAMETER WITH HIGHER NUMBER has been set to any value by |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4451 |
* an earlier action D */ |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
4452 |
if (HasBit(oper, 7)) { |
3807
736ea84b3cf4
(svn r4817) - NewGRF: allow partial support for parameter retrieval in action D.
peter1138
parents:
3806
diff
changeset
|
4453 |
if (target < 0x80 && target < _cur_grffile->param_end) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
4454 |
grfmsg(7, "ParamSet: Param %u already defined, skipping", target); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4455 |
return; |
3807
736ea84b3cf4
(svn r4817) - NewGRF: allow partial support for parameter retrieval in action D.
peter1138
parents:
3806
diff
changeset
|
4456 |
} |
736ea84b3cf4
(svn r4817) - NewGRF: allow partial support for parameter retrieval in action D.
peter1138
parents:
3806
diff
changeset
|
4457 |
|
6281 | 4458 |
oper = GB(oper, 0, 7); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4459 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4460 |
|
3808
dadaaa757e8f
(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 |
if (src2 == 0xFE) { |
dadaaa757e8f
(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 |
if (GB(data, 0, 8) == 0xFF) { |
dadaaa757e8f
(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
|
4463 |
if (data == 0x0000FFFF) { |
dadaaa757e8f
(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
|
4464 |
/* Patch variables */ |
6515
df4dba70cd68
(svn r9701) -Codechange: Add support for returning 'ttdpatch variables' - http://wiki.ttdpatch.net/tiki-index.php?page=ActionDSpecialVariables
peter1138
parents:
6507
diff
changeset
|
4465 |
src1 = GetPatchVariable(src1); |
3808
dadaaa757e8f
(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
|
4466 |
} else { |
dadaaa757e8f
(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
|
4467 |
/* GRF Resource Management */ |
9098
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4468 |
uint8 op = src1; |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4469 |
uint8 feature = GB(data, 8, 8); |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4470 |
uint16 count = GB(data, 16, 16); |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4471 |
|
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4472 |
if (_cur_stage == GLS_RESERVE) { |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4473 |
if (feature == 0x08) { |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4474 |
/* General sprites */ |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4475 |
if (op == 0) { |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4476 |
/* Check if the allocated sprites will fit below the original sprite limit */ |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4477 |
if (_cur_spriteid + count >= 16384) { |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4478 |
grfmsg(0, "ParamSet: GRM: Unable to allocate %d sprites; try changing NewGRF order", count); |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4479 |
_cur_grfconfig->status = GCS_DISABLED; |
9619
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
4480 |
ClearTemporaryNewGRFData(); |
9098
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4481 |
_skip_sprites = -1; |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4482 |
return; |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4483 |
} |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4484 |
|
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4485 |
/* Reserve space at the current sprite ID */ |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4486 |
grfmsg(4, "ParamSet: GRM: Allocated %d sprites at %d", count, _cur_spriteid); |
9113
c2856e41abf3
(svn r12973) -Codechange: Rename GRMSpriteEntry to GRFLocation, as it is not necessarily specific to GRM sprites...
peter1138
parents:
9111
diff
changeset
|
4487 |
_grm_sprites[GRFLocation(_cur_grffile->grfid, _nfo_line)] = _cur_spriteid; |
9098
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4488 |
_cur_spriteid += count; |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4489 |
} |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4490 |
} |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4491 |
/* Ignore GRM result during reservation */ |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4492 |
src1 = 0; |
9098
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4493 |
} else if (_cur_stage == GLS_ACTIVATION) { |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4494 |
switch (feature) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4495 |
case 0x00: // Trains |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4496 |
case 0x01: // Road Vehicles |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4497 |
case 0x02: // Ships |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4498 |
case 0x03: // Aircraft |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
4499 |
if (!_settings_game.vehicle.dynamic_engines) { |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
4500 |
src1 = PerformGRM(&_grm_engines[_engine_offsets[feature]], _engine_counts[feature], count, op, target, "vehicles"); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
4501 |
if (_skip_sprites == -1) return; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
4502 |
} else { |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
4503 |
// GRM does not apply for dynamic engine allocation. |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
4504 |
switch (op) { |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
4505 |
case 2: |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
4506 |
case 3: |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
4507 |
src1 = _cur_grffile->param[target]; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
4508 |
break; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
4509 |
|
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
4510 |
default: |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
4511 |
src1 = 0; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
4512 |
break; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
4513 |
} |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
4514 |
} |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4515 |
break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4516 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4517 |
case 0x08: // General sprites |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4518 |
switch (op) { |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4519 |
case 0: |
9098
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4520 |
/* Return space reserved during reservation stage */ |
9113
c2856e41abf3
(svn r12973) -Codechange: Rename GRMSpriteEntry to GRFLocation, as it is not necessarily specific to GRM sprites...
peter1138
parents:
9111
diff
changeset
|
4521 |
src1 = _grm_sprites[GRFLocation(_cur_grffile->grfid, _nfo_line)]; |
9098
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4522 |
grfmsg(4, "ParamSet: GRM: Using pre-allocated sprites at %d", src1); |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4523 |
break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4524 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4525 |
case 1: |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4526 |
src1 = _cur_spriteid; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4527 |
break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4528 |
|
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4529 |
default: |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
4530 |
grfmsg(1, "ParamSet: GRM: Unsupported operation %d for general sprites", op); |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4531 |
return; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4532 |
} |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4533 |
break; |
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4534 |
|
6781
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4535 |
case 0x0B: // Cargo |
7690
293efb2185a8
(svn r11224) -Fix: GRM for cargos has registration entries for both cargo IDs and cargo bitmasks, not only cargo IDs.
rubidium
parents:
7674
diff
changeset
|
4536 |
/* There are two ranges: one for cargo IDs and one for cargo bitmasks */ |
293efb2185a8
(svn r11224) -Fix: GRM for cargos has registration entries for both cargo IDs and cargo bitmasks, not only cargo IDs.
rubidium
parents:
7674
diff
changeset
|
4537 |
src1 = PerformGRM(_grm_cargos, NUM_CARGO * 2, count, op, target, "cargos"); |
6781
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4538 |
if (_skip_sprites == -1) return; |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4539 |
break; |
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
4540 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
4541 |
default: grfmsg(1, "ParamSet: GRM: Unsupported feature 0x%X", feature); return; |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4542 |
} |
9098
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4543 |
} else { |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4544 |
/* Ignore GRM during initialization */ |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
4545 |
src1 = 0; |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
4546 |
} |
3808
dadaaa757e8f
(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
|
4547 |
} |
dadaaa757e8f
(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
|
4548 |
} else { |
dadaaa757e8f
(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
|
4549 |
/* Read another GRF File's parameter */ |
dadaaa757e8f
(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
|
4550 |
const GRFFile *file = GetFileByGRFID(data); |
9556
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
4551 |
GRFConfig *c = GetGRFConfig(data); |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
4552 |
if (c != NULL && HasBit(c->status, GCF_STATIC) && !HasBit(_cur_grfconfig->status, GCF_STATIC) && _networking) { |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
4553 |
/* Disable the read GRF if it is a static NewGRF. */ |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
4554 |
DisableStaticNewGRFInfluencingNonStaticNewGRFs(c); |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
4555 |
src1 = 0; |
0cfc541c4d38
(svn r13576) -Codechange: disable static NewGRFs when non-static NewGRFs query them in the context of network games. This makes it impossible for static NewGRFs to disable non-static NewGRFs and 'bad' things happening because the non-static NewGRF doesn't know about the static NewGRF.
rubidium
parents:
9502
diff
changeset
|
4556 |
} else if (file == NULL || src1 >= file->param_end || (c != NULL && c->status == GCS_DISABLED)) { |
3808
dadaaa757e8f
(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
|
4557 |
src1 = 0; |
dadaaa757e8f
(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
|
4558 |
} else { |
dadaaa757e8f
(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
|
4559 |
src1 = file->param[src1]; |
dadaaa757e8f
(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
|
4560 |
} |
dadaaa757e8f
(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
|
4561 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4562 |
} else { |
3808
dadaaa757e8f
(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
|
4563 |
/* The source1 and source2 operands refer to the grf parameter number |
dadaaa757e8f
(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
|
4564 |
* like in action 6 and 7. In addition, they can refer to the special |
dadaaa757e8f
(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
|
4565 |
* variables available in action 7, or they can be FF to use the value |
dadaaa757e8f
(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
|
4566 |
* of <data>. If referring to parameters that are undefined, a value |
dadaaa757e8f
(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
|
4567 |
* of 0 is used instead. */ |
3811
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
4568 |
src1 = (src1 == 0xFF) ? data : GetParamVal(src1, NULL); |
8f2b44f6b709
(svn r4821) - NewGRF: simplify parameter retrieval in Action 0x0D
peter1138
parents:
3808
diff
changeset
|
4569 |
src2 = (src2 == 0xFF) ? data : GetParamVal(src2, NULL); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4570 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4571 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4572 |
/* TODO: You can access the parameters of another GRF file by using |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4573 |
* source2=FE, source1=the other GRF's parameter number and data=GRF |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4574 |
* ID. This is only valid with operation 00 (set). If the GRF ID |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4575 |
* cannot be found, a value of 0 is used for the parameter value |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4576 |
* instead. */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4577 |
|
6281 | 4578 |
uint32 res; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4579 |
switch (oper) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4580 |
case 0x00: |
2345 | 4581 |
res = src1; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4582 |
break; |
2345 | 4583 |
|
4584 |
case 0x01: |
|
4585 |
res = src1 + src2; |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4586 |
break; |
2345 | 4587 |
|
4588 |
case 0x02: |
|
4589 |
res = src1 - src2; |
|
4590 |
break; |
|
4591 |
||
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4592 |
case 0x03: |
2345 | 4593 |
res = src1 * src2; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4594 |
break; |
2345 | 4595 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4596 |
case 0x04: |
2345 | 4597 |
res = (int32)src1 * (int32)src2; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4598 |
break; |
2345 | 4599 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4600 |
case 0x05: |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
4601 |
if ((int32)src2 < 0) { |
2345 | 4602 |
res = src1 >> -(int32)src2; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
4603 |
} else { |
2345 | 4604 |
res = src1 << src2; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
4605 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4606 |
break; |
2345 | 4607 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4608 |
case 0x06: |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
4609 |
if ((int32)src2 < 0) { |
2345 | 4610 |
res = (int32)src1 >> -(int32)src2; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
4611 |
} else { |
2345 | 4612 |
res = (int32)src1 << src2; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3997
diff
changeset
|
4613 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4614 |
break; |
2345 | 4615 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4616 |
case 0x07: // Bitwise AND |
2442
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4617 |
res = src1 & src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4618 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4619 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4620 |
case 0x08: // Bitwise OR |
2442
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4621 |
res = src1 | src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4622 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4623 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4624 |
case 0x09: // Unsigned division |
2442
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4625 |
if (src2 == 0) { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4626 |
res = src1; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4627 |
} else { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4628 |
res = src1 / src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4629 |
} |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4630 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4631 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4632 |
case 0x0A: // Signed divison |
2442
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4633 |
if (src2 == 0) { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4634 |
res = src1; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4635 |
} else { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4636 |
res = (int32)src1 / (int32)src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4637 |
} |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4638 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4639 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4640 |
case 0x0B: // Unsigned modulo |
2442
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4641 |
if (src2 == 0) { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4642 |
res = src1; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4643 |
} else { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4644 |
res = src1 % src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4645 |
} |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4646 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4647 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4648 |
case 0x0C: // Signed modulo |
2442
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4649 |
if (src2 == 0) { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4650 |
res = src1; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4651 |
} else { |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4652 |
res = (int32)src1 % (int32)src2; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4653 |
} |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4654 |
break; |
341a127f3d8c
(svn r2968) -Newgrf: Implement current set of action D (ParamSet) operations.
peter1138
parents:
2440
diff
changeset
|
4655 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
4656 |
default: grfmsg(0, "ParamSet: Unknown operation %d, skipping", oper); return; |
2345 | 4657 |
} |
4658 |
||
4659 |
switch (target) { |
|
4660 |
case 0x8E: // Y-Offset for train sprites |
|
4661 |
_traininfo_vehicle_pitch = res; |
|
4662 |
break; |
|
4663 |
||
10002
87148ad75853
(svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents:
10001
diff
changeset
|
4664 |
case 0x8F: { // Rail track type cost factors |
87148ad75853
(svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents:
10001
diff
changeset
|
4665 |
extern RailtypeInfo _railtypes[RAILTYPE_END]; |
87148ad75853
(svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents:
10001
diff
changeset
|
4666 |
_railtypes[RAILTYPE_RAIL].cost_multiplier = GB(res, 0, 8); |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
4667 |
if (_settings_game.vehicle.disable_elrails) { |
10002
87148ad75853
(svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents:
10001
diff
changeset
|
4668 |
_railtypes[RAILTYPE_ELECTRIC].cost_multiplier = GB(res, 0, 8); |
87148ad75853
(svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents:
10001
diff
changeset
|
4669 |
_railtypes[RAILTYPE_MONO].cost_multiplier = GB(res, 8, 8); |
7730
4293ba29ce21
(svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents:
7718
diff
changeset
|
4670 |
} else { |
10002
87148ad75853
(svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents:
10001
diff
changeset
|
4671 |
_railtypes[RAILTYPE_ELECTRIC].cost_multiplier = GB(res, 8, 8); |
87148ad75853
(svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents:
10001
diff
changeset
|
4672 |
_railtypes[RAILTYPE_MONO].cost_multiplier = GB(res, 16, 8); |
7730
4293ba29ce21
(svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents:
7718
diff
changeset
|
4673 |
} |
10002
87148ad75853
(svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents:
10001
diff
changeset
|
4674 |
_railtypes[RAILTYPE_MAGLEV].cost_multiplier = GB(res, 16, 8); |
7730
4293ba29ce21
(svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents:
7718
diff
changeset
|
4675 |
break; |
10002
87148ad75853
(svn r14160) -Codechange: Move _railtype_cost_multipliers into the rail type information struct.
peter1138
parents:
10001
diff
changeset
|
4676 |
} |
7730
4293ba29ce21
(svn r11265) -Feature: Make more advanced rail types more expensive to build.
maedhros
parents:
7718
diff
changeset
|
4677 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4678 |
/* @todo implement */ |
2345 | 4679 |
case 0x93: // Tile refresh offset to left |
4680 |
case 0x94: // Tile refresh offset to right |
|
4681 |
case 0x95: // Tile refresh offset upwards |
|
4682 |
case 0x96: // Tile refresh offset downwards |
|
4683 |
case 0x97: // Snow line height |
|
4684 |
case 0x99: // Global ID offset |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
4685 |
grfmsg(7, "ParamSet: Skipping unimplemented target 0x%02X", target); |
2345 | 4686 |
break; |
4687 |
||
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
4688 |
case 0x9E: // Miscellaneous GRF features |
3814
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
4689 |
_misc_grf_features = res; |
3845
af6eb0103fed
(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
|
4690 |
/* Set train list engine width */ |
6541
dfa5165a5ab7
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros
parents:
6533
diff
changeset
|
4691 |
_traininfo_vehicle_width = HasGrfMiscBit(GMB_TRAIN_WIDTH_32_PIXELS) ? 32 : 29; |
3814
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
4692 |
break; |
5fb36810d6ad
(svn r4824) - NewGRF: add support for getting/setting miscellaneous grf flags (param 0x9E)
peter1138
parents:
3811
diff
changeset
|
4693 |
|
8546
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
4694 |
case 0x9F: // locale-dependent settings |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
4695 |
grfmsg(7, "ParamSet: Skipping unimplemented target 0x%02X", target); |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
4696 |
break; |
fb64231b2976
(svn r12124) -Codechange: Move newgrf-variables that are common to VarAction2 and Action7/9/D to their own function.
frosch
parents:
8544
diff
changeset
|
4697 |
|
2345 | 4698 |
default: |
4699 |
if (target < 0x80) { |
|
4700 |
_cur_grffile->param[target] = res; |
|
4701 |
if (target + 1U > _cur_grffile->param_end) _cur_grffile->param_end = target + 1; |
|
4702 |
} else { |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
4703 |
grfmsg(7, "ParamSet: Skipping unknown target 0x%02X", target); |
2345 | 4704 |
} |
4705 |
break; |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4706 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4707 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4708 |
|
5502
003b36599ff8
(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:
5476
diff
changeset
|
4709 |
/* Action 0x0E (GLS_SAFETYSCAN) */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
4710 |
static void SafeGRFInhibit(byte *buf, size_t len) |
5502
003b36599ff8
(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:
5476
diff
changeset
|
4711 |
{ |
003b36599ff8
(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:
5476
diff
changeset
|
4712 |
/* <0E> <num> <grfids...> |
003b36599ff8
(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:
5476
diff
changeset
|
4713 |
* |
003b36599ff8
(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:
5476
diff
changeset
|
4714 |
* B num Number of GRFIDs that follow |
003b36599ff8
(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:
5476
diff
changeset
|
4715 |
* D grfids GRFIDs of the files to deactivate */ |
003b36599ff8
(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:
5476
diff
changeset
|
4716 |
|
6281 | 4717 |
if (!check_length(len, 2, "GRFInhibit")) return; |
4718 |
buf++; |
|
4719 |
uint8 num = grf_load_byte(&buf); |
|
4720 |
if (!check_length(len, 2 + 4 * num, "GRFInhibit")) return; |
|
4721 |
||
4722 |
for (uint i = 0; i < num; i++) { |
|
5502
003b36599ff8
(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:
5476
diff
changeset
|
4723 |
uint32 grfid = grf_load_dword(&buf); |
003b36599ff8
(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:
5476
diff
changeset
|
4724 |
|
003b36599ff8
(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:
5476
diff
changeset
|
4725 |
/* GRF is unsafe it if tries to deactivate other GRFs */ |
003b36599ff8
(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:
5476
diff
changeset
|
4726 |
if (grfid != _cur_grfconfig->grfid) { |
7931
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7929
diff
changeset
|
4727 |
SetBit(_cur_grfconfig->flags, GCF_UNSAFE); |
5502
003b36599ff8
(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:
5476
diff
changeset
|
4728 |
|
003b36599ff8
(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:
5476
diff
changeset
|
4729 |
/* Skip remainder of GRF */ |
003b36599ff8
(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:
5476
diff
changeset
|
4730 |
_skip_sprites = -1; |
003b36599ff8
(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:
5476
diff
changeset
|
4731 |
|
003b36599ff8
(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:
5476
diff
changeset
|
4732 |
return; |
003b36599ff8
(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:
5476
diff
changeset
|
4733 |
} |
003b36599ff8
(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:
5476
diff
changeset
|
4734 |
} |
003b36599ff8
(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:
5476
diff
changeset
|
4735 |
} |
003b36599ff8
(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:
5476
diff
changeset
|
4736 |
|
3715
b696b84baf30
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
4737 |
/* Action 0x0E */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
4738 |
static void GRFInhibit(byte *buf, size_t len) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4739 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4740 |
/* <0E> <num> <grfids...> |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4741 |
* |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4742 |
* B num Number of GRFIDs that follow |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4743 |
* D grfids GRFIDs of the files to deactivate */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4744 |
|
6281 | 4745 |
if (!check_length(len, 2, "GRFInhibit")) return; |
4746 |
buf++; |
|
4747 |
uint8 num = grf_load_byte(&buf); |
|
4748 |
if (!check_length(len, 2 + 4 * num, "GRFInhibit")) return; |
|
4749 |
||
4750 |
for (uint i = 0; i < num; i++) { |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4751 |
uint32 grfid = grf_load_dword(&buf); |
5333
dedf1f6de6d3
(svn r7495) -Fix (r7354): [NewGRF] Deactivate the target GRF, not the current GRF.
peter1138
parents:
5329
diff
changeset
|
4752 |
GRFConfig *file = GetGRFConfig(grfid); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4753 |
|
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4754 |
/* Unset activation flag */ |
5369
6420e8dd829c
(svn r7554) -Fix (r7496): In Action 0xE, don't deactivate the current GRF (to be ported to 0.5)
peter1138
parents:
5340
diff
changeset
|
4755 |
if (file != NULL && file != _cur_grfconfig) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
4756 |
grfmsg(2, "GRFInhibit: Deactivating file '%s'", file->filename); |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
4757 |
file->status = GCS_DISABLED; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4758 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4759 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4760 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4761 |
|
6956
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4762 |
/* Action 0x0F */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
4763 |
static void FeatureTownName(byte *buf, size_t len) |
6956
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4764 |
{ |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4765 |
/* <0F> <id> <style-name> <num-parts> <parts> |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4766 |
* |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4767 |
* B id ID of this definition in bottom 7 bits (final definition if bit 7 set) |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4768 |
* V style-name Name of the style (only for final definition) |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4769 |
* B num-parts Number of parts in this definition |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4770 |
* V parts The parts */ |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4771 |
|
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4772 |
if (!check_length(len, 1, "FeatureTownName: definition ID")) return; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4773 |
buf++; len--; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4774 |
|
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4775 |
uint32 grfid = _cur_grffile->grfid; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4776 |
|
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4777 |
GRFTownName *townname = AddGRFTownName(grfid); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4778 |
|
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4779 |
byte id = grf_load_byte(&buf); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4780 |
len--; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4781 |
grfmsg(6, "FeatureTownName: definition 0x%02X", id & 0x7F); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4782 |
|
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
4783 |
if (HasBit(id, 7)) { |
6956
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4784 |
/* Final definition */ |
7929
6c9b25842b0f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
7928
diff
changeset
|
4785 |
ClrBit(id, 7); |
6956
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4786 |
bool new_scheme = _cur_grffile->grf_version >= 7; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4787 |
|
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4788 |
if (!check_length(len, 1, "FeatureTownName: lang_id")) return; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4789 |
byte lang = grf_load_byte(&buf); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4790 |
len--; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4791 |
|
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4792 |
byte nb_gen = townname->nb_gen; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4793 |
do { |
7929
6c9b25842b0f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
7928
diff
changeset
|
4794 |
ClrBit(lang, 7); |
6956
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4795 |
|
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4796 |
if (!check_length(len, 1, "FeatureTownName: style name")) return; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4797 |
const char *name = grf_load_string(&buf, len); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4798 |
len -= strlen(name) + 1; |
8656
9731ddde8722
(svn r12317) -Fix [FS#1815]: Map string IDs that are embedded from other strings.
peter1138
parents:
8655
diff
changeset
|
4799 |
grfmsg(6, "FeatureTownName: lang 0x%X -> '%s'", lang, TranslateTTDPatchCodes(grfid, name)); |
6956
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4800 |
|
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4801 |
townname->name[nb_gen] = AddGRFString(grfid, id, lang, new_scheme, name, STR_UNDEFINED); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4802 |
|
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4803 |
if (!check_length(len, 1, "FeatureTownName: lang_id")) return; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4804 |
lang = grf_load_byte(&buf); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4805 |
len--; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4806 |
} while (lang != 0); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4807 |
townname->id[nb_gen] = id; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4808 |
townname->nb_gen++; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4809 |
} |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4810 |
|
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4811 |
if (!check_length(len, 1, "FeatureTownName: number of parts")) return; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4812 |
byte nb = grf_load_byte(&buf); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4813 |
len--; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4814 |
grfmsg(6, "FeatureTownName: %d parts", nb, nb); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4815 |
|
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4816 |
townname->nbparts[id] = nb; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4817 |
townname->partlist[id] = CallocT<NamePartList>(nb); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4818 |
|
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4819 |
for (int i = 0; i < nb; i++) { |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4820 |
if (!check_length(len, 3, "FeatureTownName: parts header")) return; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4821 |
byte nbtext = grf_load_byte(&buf); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4822 |
townname->partlist[id][i].bitstart = grf_load_byte(&buf); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4823 |
townname->partlist[id][i].bitcount = grf_load_byte(&buf); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4824 |
townname->partlist[id][i].maxprob = 0; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4825 |
townname->partlist[id][i].partcount = nbtext; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4826 |
townname->partlist[id][i].parts = CallocT<NamePart>(nbtext); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4827 |
len -= 3; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4828 |
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); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4829 |
|
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4830 |
for (int j = 0; j < nbtext; j++) { |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4831 |
if (!check_length(len, 2, "FeatureTownName: part")) return; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4832 |
byte prob = grf_load_byte(&buf); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4833 |
len--; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4834 |
|
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
4835 |
if (HasBit(prob, 7)) { |
6956
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4836 |
byte ref_id = grf_load_byte(&buf); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4837 |
len--; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4838 |
|
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4839 |
if (townname->nbparts[ref_id] == 0) { |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4840 |
grfmsg(0, "FeatureTownName: definition 0x%02X doesn't exist, deactivating", ref_id); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4841 |
DelGRFTownName(grfid); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4842 |
_cur_grfconfig->status = GCS_DISABLED; |
9619
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
4843 |
ClearTemporaryNewGRFData(); |
6956
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4844 |
_skip_sprites = -1; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4845 |
return; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4846 |
} |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4847 |
|
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4848 |
grfmsg(6, "FeatureTownName: part %d, text %d, uses intermediate definition 0x%02X (with probability %d)", i, j, ref_id, prob & 0x7F); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4849 |
townname->partlist[id][i].parts[j].data.id = ref_id; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4850 |
} else { |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4851 |
const char *text = grf_load_string(&buf, len); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4852 |
len -= strlen(text) + 1; |
8656
9731ddde8722
(svn r12317) -Fix [FS#1815]: Map string IDs that are embedded from other strings.
peter1138
parents:
8655
diff
changeset
|
4853 |
townname->partlist[id][i].parts[j].data.text = TranslateTTDPatchCodes(grfid, text); |
6956
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4854 |
grfmsg(6, "FeatureTownName: part %d, text %d, '%s' (with probability %d)", i, j, townname->partlist[id][i].parts[j].data.text, prob); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4855 |
} |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4856 |
townname->partlist[id][i].parts[j].prob = prob; |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4857 |
townname->partlist[id][i].maxprob += GB(prob, 0, 7); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4858 |
} |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4859 |
grfmsg(6, "FeatureTownName: part %d, total probability %d", i, townname->partlist[id][i].maxprob); |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4860 |
} |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4861 |
} |
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
4862 |
|
3715
b696b84baf30
(svn r4658) - NewGRF: add Action 0xNN comments before each action handler. This mainly aids code navigation...
peter1138
parents:
3714
diff
changeset
|
4863 |
/* Action 0x10 */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
4864 |
static void DefineGotoLabel(byte *buf, size_t len) |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4865 |
{ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4866 |
/* <10> <label> [<comment>] |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4867 |
* |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4868 |
* B label The label to define |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4869 |
* V comment Optional comment - ignored */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4870 |
|
5590
6a0c2739e124
(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:
5587
diff
changeset
|
4871 |
if (!check_length(len, 1, "DefineGotoLabel")) return; |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4872 |
buf++; len--; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4873 |
|
6281 | 4874 |
GRFLabel *label = MallocT<GRFLabel>(1); |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4875 |
label->label = grf_load_byte(&buf); |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4876 |
label->nfo_line = _nfo_line; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4877 |
label->pos = FioGetPos(); |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4878 |
label->next = NULL; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4879 |
|
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4880 |
/* Set up a linked list of goto targets which we will search in an Action 0x7/0x9 */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4881 |
if (_cur_grffile->label == NULL) { |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4882 |
_cur_grffile->label = label; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4883 |
} else { |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4884 |
/* Attach the label to the end of the list */ |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4885 |
GRFLabel *l; |
8695
6607e9b9ffe2
(svn r12368) -Codechange: use explicit body for loops and conditions and remove -Wno-empty-body from the configure script
smatz
parents:
8675
diff
changeset
|
4886 |
for (l = _cur_grffile->label; l->next != NULL; l = l->next) {} |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4887 |
l->next = label; |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4888 |
} |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4889 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
4890 |
grfmsg(2, "DefineGotoLabel: GOTO target with label 0x%02X", label->label); |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
4891 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
4892 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4893 |
/* Action 0x11 */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
4894 |
static void GRFSound(byte *buf, size_t len) |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4895 |
{ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4896 |
/* <11> <num> |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4897 |
* |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4898 |
* W num Number of sound files that follow */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4899 |
|
5590
6a0c2739e124
(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:
5587
diff
changeset
|
4900 |
if (!check_length(len, 1, "GRFSound")) return; |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4901 |
buf++; |
6281 | 4902 |
uint16 num = grf_load_word(&buf); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4903 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4904 |
_grf_data_blocks = num; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4905 |
_grf_data_type = GDT_SOUND; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4906 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4907 |
if (_cur_grffile->sound_offset == 0) _cur_grffile->sound_offset = GetNumSounds(); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4908 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4909 |
|
8431
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
4910 |
/* Action 0x11 (SKIP) */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
4911 |
static void SkipAct11(byte *buf, size_t len) |
8431
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
4912 |
{ |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
4913 |
/* <11> <num> |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
4914 |
* |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
4915 |
* W num Number of sound files that follow */ |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
4916 |
|
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
4917 |
if (!check_length(len, 1, "SkipAct11")) return; |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
4918 |
buf++; |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
4919 |
_skip_sprites = grf_load_word(&buf); |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
4920 |
|
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
4921 |
grfmsg(3, "SkipAct11: Skipping %d sprites", _skip_sprites); |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
4922 |
} |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
4923 |
|
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4924 |
static void ImportGRFSound(byte *buf, int len) |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4925 |
{ |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4926 |
const GRFFile *file; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4927 |
FileEntry *se = AllocateFileEntry(); |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4928 |
uint32 grfid = grf_load_dword(&buf); |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4929 |
uint16 sound = grf_load_word(&buf); |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4930 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4931 |
file = GetFileByGRFID(grfid); |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4932 |
if (file == NULL || file->sound_offset == 0) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
4933 |
grfmsg(1, "ImportGRFSound: Source file not available"); |
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4934 |
return; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4935 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4936 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4937 |
if (file->sound_offset + sound >= GetNumSounds()) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
4938 |
grfmsg(1, "ImportGRFSound: Sound effect %d is invalid", sound); |
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4939 |
return; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4940 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4941 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
4942 |
grfmsg(2, "ImportGRFSound: Copying sound %d (%d) from file %X", sound, file->sound_offset + sound, grfid); |
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4943 |
|
5024
5e98bf731469
(svn r7065) Use simple assignment instead of memcpy()
tron
parents:
5011
diff
changeset
|
4944 |
*se = *GetSound(file->sound_offset + sound); |
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4945 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4946 |
/* Reset volume and priority, which TTDPatch doesn't copy */ |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4947 |
se->volume = 128; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4948 |
se->priority = 0; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4949 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4950 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4951 |
/* 'Action 0xFE' */ |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4952 |
static void GRFImportBlock(byte *buf, int len) |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4953 |
{ |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4954 |
if (_grf_data_blocks == 0) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
4955 |
grfmsg(2, "GRFImportBlock: Unexpected import block, skipping"); |
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4956 |
return; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4957 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4958 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4959 |
buf++; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4960 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4961 |
_grf_data_blocks--; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4962 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4963 |
/* XXX 'Action 0xFE' isn't really specified. It is only mentioned for |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4964 |
* importing sounds, so this is probably all wrong... */ |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4965 |
if (grf_load_byte(&buf) != _grf_data_type) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
4966 |
grfmsg(1, "GRFImportBlock: Import type mismatch"); |
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4967 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4968 |
|
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4969 |
switch (_grf_data_type) { |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4970 |
case GDT_SOUND: ImportGRFSound(buf, len - 1); break; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4971 |
default: NOT_REACHED(); break; |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4972 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4973 |
} |
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
4974 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4975 |
static void LoadGRFSound(byte *buf, int len) |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4976 |
{ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4977 |
byte *buf_start = buf; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4978 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4979 |
/* Allocate a sound entry. This is done even if the data is not loaded |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4980 |
* so that the indices used elsewhere are still correct. */ |
6281 | 4981 |
FileEntry *se = AllocateFileEntry(); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4982 |
|
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
4983 |
if (grf_load_dword(&buf) != BSWAP32('RIFF')) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
4984 |
grfmsg(1, "LoadGRFSound: Missing RIFF header"); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4985 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4986 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4987 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4988 |
/* Size of file -- we ignore this */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4989 |
grf_load_dword(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4990 |
|
5379
929378a0014f
(svn r7564) -Codechange: Some newgrf changes. FFIR/EVAW endian-swapping, functionalize
Darkvater
parents:
5369
diff
changeset
|
4991 |
if (grf_load_dword(&buf) != BSWAP32('WAVE')) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
4992 |
grfmsg(1, "LoadGRFSound: Invalid RIFF type"); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4993 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4994 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4995 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4996 |
for (;;) { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4997 |
uint32 tag = grf_load_dword(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4998 |
uint32 size = grf_load_dword(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
4999 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5000 |
switch (tag) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
5001 |
case ' tmf': // 'fmt ' |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5002 |
/* Audio format, must be 1 (PCM) */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5003 |
if (grf_load_word(&buf) != 1) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
5004 |
grfmsg(1, "LoadGRFSound: Invalid audio format"); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5005 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5006 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5007 |
se->channels = grf_load_word(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5008 |
se->rate = grf_load_dword(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5009 |
grf_load_dword(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5010 |
grf_load_word(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5011 |
se->bits_per_sample = grf_load_word(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5012 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5013 |
/* Consume any extra bytes */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5014 |
for (; size > 16; size--) grf_load_byte(&buf); |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5015 |
break; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5016 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
5017 |
case 'atad': // 'data' |
7570
5d5d9b6af0ef
(svn r11095) -Codechange: don't abuse 'file_pos' by storing the file_slot in it too, but use a nice seperate variable for it
truelight
parents:
7459
diff
changeset
|
5018 |
se->file_size = size; |
5d5d9b6af0ef
(svn r11095) -Codechange: don't abuse 'file_pos' by storing the file_slot in it too, but use a nice seperate variable for it
truelight
parents:
7459
diff
changeset
|
5019 |
se->file_offset = FioGetPos() - (len - (buf - buf_start)) + 1; |
5d5d9b6af0ef
(svn r11095) -Codechange: don't abuse 'file_pos' by storing the file_slot in it too, but use a nice seperate variable for it
truelight
parents:
7459
diff
changeset
|
5020 |
se->file_slot = _file_index; |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5021 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5022 |
/* Set default volume and priority */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5023 |
se->volume = 0x80; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5024 |
se->priority = 0; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5025 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
5026 |
grfmsg(2, "LoadGRFSound: channels %u, sample rate %u, bits per sample %u, length %u", se->channels, se->rate, se->bits_per_sample, size); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5027 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5028 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5029 |
default: |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5030 |
se->file_size = 0; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5031 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5032 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5033 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5034 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5035 |
|
5108
aeaef6fe53b7
(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
|
5036 |
/* Action 0x12 */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
5037 |
static void LoadFontGlyph(byte *buf, size_t len) |
5108
aeaef6fe53b7
(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
|
5038 |
{ |
aeaef6fe53b7
(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
|
5039 |
/* <12> <num_def> <font_size> <num_char> <base_char> |
aeaef6fe53b7
(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
|
5040 |
* |
aeaef6fe53b7
(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
|
5041 |
* B num_def Number of definitions |
aeaef6fe53b7
(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
|
5042 |
* B font_size Size of font (0 = normal, 1 = small, 2 = large) |
aeaef6fe53b7
(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
|
5043 |
* B num_char Number of consecutive glyphs |
aeaef6fe53b7
(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
|
5044 |
* W base_char First character index */ |
aeaef6fe53b7
(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
|
5045 |
|
aeaef6fe53b7
(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
|
5046 |
buf++; len--; |
5590
6a0c2739e124
(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:
5587
diff
changeset
|
5047 |
if (!check_length(len, 1, "LoadFontGlyph")) return; |
5108
aeaef6fe53b7
(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
|
5048 |
|
6281 | 5049 |
uint8 num_def = grf_load_byte(&buf); |
5108
aeaef6fe53b7
(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
|
5050 |
|
5590
6a0c2739e124
(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:
5587
diff
changeset
|
5051 |
if (!check_length(len, 1 + num_def * 4, "LoadFontGlyph")) return; |
5108
aeaef6fe53b7
(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
|
5052 |
|
6281 | 5053 |
for (uint i = 0; i < num_def; i++) { |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
5054 |
FontSize size = (FontSize)grf_load_byte(&buf); |
5108
aeaef6fe53b7
(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
|
5055 |
uint8 num_char = grf_load_byte(&buf); |
aeaef6fe53b7
(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
|
5056 |
uint16 base_char = grf_load_word(&buf); |
aeaef6fe53b7
(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
|
5057 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
5058 |
grfmsg(7, "LoadFontGlyph: Loading %u glyph(s) at 0x%04X for size %u", num_char, base_char, size); |
5108
aeaef6fe53b7
(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
|
5059 |
|
6281 | 5060 |
for (uint c = 0; c < num_char; c++) { |
5108
aeaef6fe53b7
(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
|
5061 |
SetUnicodeGlyph(size, base_char + c, _cur_spriteid); |
7953
db4cd9ef0efc
(svn r11509) -Fix: off-by-one error in some sprite numbers; increase sprite number counter before loading the next sprite instead of after doing so.
rubidium
parents:
7941
diff
changeset
|
5062 |
_nfo_line++; |
6908
6b1324d7a2c9
(svn r10157) -Fix: use as indentified for PNGs, the place of the image as it was in the grf, not the internal SpriteID
truelight
parents:
6894
diff
changeset
|
5063 |
LoadNextSprite(_cur_spriteid++, _file_index, _nfo_line); |
5108
aeaef6fe53b7
(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
|
5064 |
} |
aeaef6fe53b7
(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
|
5065 |
} |
aeaef6fe53b7
(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
|
5066 |
} |
aeaef6fe53b7
(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
|
5067 |
|
8431
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5068 |
/* Action 0x12 (SKIP) */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
5069 |
static void SkipAct12(byte *buf, size_t len) |
8431
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5070 |
{ |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5071 |
/* <12> <num_def> <font_size> <num_char> <base_char> |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5072 |
* |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5073 |
* B num_def Number of definitions |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5074 |
* B font_size Size of font (0 = normal, 1 = small, 2 = large) |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5075 |
* B num_char Number of consecutive glyphs |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5076 |
* W base_char First character index */ |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5077 |
|
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5078 |
buf++; len--; |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5079 |
if (!check_length(len, 1, "SkipAct12")) return; |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5080 |
uint8 num_def = grf_load_byte(&buf); |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5081 |
|
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5082 |
if (!check_length(len, 1 + num_def * 4, "SkipAct12")) return; |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5083 |
|
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5084 |
for (uint i = 0; i < num_def; i++) { |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5085 |
/* Ignore 'size' byte */ |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5086 |
grf_load_byte(&buf); |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5087 |
|
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5088 |
/* Sum up number of characters */ |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5089 |
_skip_sprites += grf_load_byte(&buf); |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5090 |
|
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5091 |
/* Ignore 'base_char' word */ |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5092 |
grf_load_word(&buf); |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5093 |
} |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5094 |
|
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5095 |
grfmsg(3, "SkipAct12: Skipping %d sprites", _skip_sprites); |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5096 |
} |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5097 |
|
6234
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5098 |
/* Action 0x13 */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
5099 |
static void TranslateGRFStrings(byte *buf, size_t len) |
6234
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5100 |
{ |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5101 |
/* <13> <grfid> <num-ent> <offset> <text...> |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5102 |
* |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5103 |
* 4*B grfid The GRFID of the file whose texts are to be translated |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5104 |
* B num-ent Number of strings |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5105 |
* W offset First text ID |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5106 |
* S text... Zero-terminated strings */ |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5107 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5108 |
buf++; len--; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5109 |
if (!check_length(len, 7, "TranslateGRFString")) return; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5110 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5111 |
uint32 grfid = grf_load_dword(&buf); |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5112 |
const GRFConfig *c = GetGRFConfig(grfid); |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5113 |
if (c == NULL || (c->status != GCS_INITIALISED && c->status != GCS_ACTIVATED)) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
5114 |
grfmsg(7, "TranslateGRFStrings: GRFID 0x%08x unknown, skipping action 13", BSWAP32(grfid)); |
6234
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5115 |
return; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5116 |
} |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5117 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5118 |
if (c->status == GCS_INITIALISED) { |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5119 |
/* If the file is not active but will be activated later, give an error |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5120 |
* and disable this file. */ |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5121 |
GRFError *error = CallocT<GRFError>(1); |
6873
b4d0648edd29
(svn r10114) -Fix: Only load newgrf error messages if the language matches the current
maedhros
parents:
6870
diff
changeset
|
5122 |
|
b4d0648edd29
(svn r10114) -Fix: Only load newgrf error messages if the language matches the current
maedhros
parents:
6870
diff
changeset
|
5123 |
char tmp[256]; |
b4d0648edd29
(svn r10114) -Fix: Only load newgrf error messages if the language matches the current
maedhros
parents:
6870
diff
changeset
|
5124 |
GetString(tmp, STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE, lastof(tmp)); |
b4d0648edd29
(svn r10114) -Fix: Only load newgrf error messages if the language matches the current
maedhros
parents:
6870
diff
changeset
|
5125 |
error->data = strdup(tmp); |
b4d0648edd29
(svn r10114) -Fix: Only load newgrf error messages if the language matches the current
maedhros
parents:
6870
diff
changeset
|
5126 |
|
6234
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5127 |
error->message = STR_NEWGRF_ERROR_LOAD_AFTER; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5128 |
error->severity = STR_NEWGRF_ERROR_MSG_FATAL; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5129 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5130 |
if (_cur_grfconfig->error != NULL) free(_cur_grfconfig->error); |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5131 |
_cur_grfconfig->error = error; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5132 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5133 |
_cur_grfconfig->status = GCS_DISABLED; |
9619
9cf5022932aa
(svn r13675) -Fix: memory leak when NewGRFs got forcefully disabled and they defined GOTO labels.
rubidium
parents:
9570
diff
changeset
|
5134 |
ClearTemporaryNewGRFData(); |
6234
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5135 |
_skip_sprites = -1; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5136 |
return; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5137 |
} |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5138 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5139 |
byte num_strings = grf_load_byte(&buf); |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5140 |
uint16 first_id = grf_load_word(&buf); |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5141 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5142 |
if (!((first_id >= 0xD000 && first_id + num_strings <= 0xD3FF) || (first_id >= 0xDC00 && first_id + num_strings <= 0xDCFF))) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
5143 |
grfmsg(7, "TranslateGRFStrings: Attempting to set out-of-range string IDs in action 13 (first: 0x%4X, number: 0x%2X)", first_id, num_strings); |
6234
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5144 |
return; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5145 |
} |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5146 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5147 |
len -= 7; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5148 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5149 |
for (uint i = 0; i < num_strings && len > 0; i++) { |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5150 |
const char *string = grf_load_string(&buf, len); |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5151 |
size_t string_length = strlen(string) + 1; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5152 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5153 |
len -= (int)string_length; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5154 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5155 |
if (string_length == 1) { |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5156 |
grfmsg(7, "TranslateGRFString: Ignoring empty string."); |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5157 |
continue; |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5158 |
} |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5159 |
|
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5160 |
/* Since no language id is supplied this string has to be added as a |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5161 |
* generic string, thus the language id of 0x7F. For this to work |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5162 |
* new_scheme has to be true as well. A language id of 0x7F will be |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5163 |
* overridden by a non-generic id, so this will not change anything if |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5164 |
* a string has been provided specifically for this language. */ |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5165 |
AddGRFString(grfid, first_id + i, 0x7F, true, string, STR_UNDEFINED); |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5166 |
} |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5167 |
} |
023a25b334b6
(svn r9037) -Feature: [NewGRF] Add support for Action 13, which allows you to translate
maedhros
parents:
6229
diff
changeset
|
5168 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5169 |
/* 'Action 0xFF' */ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5170 |
static void GRFDataBlock(byte *buf, int len) |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5171 |
{ |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5172 |
if (_grf_data_blocks == 0) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
5173 |
grfmsg(2, "GRFDataBlock: unexpected data block, skipping"); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5174 |
return; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5175 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5176 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5177 |
buf++; |
6281 | 5178 |
uint8 name_len = grf_load_byte(&buf); |
5179 |
const char *name = (const char *)buf; |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5180 |
buf += name_len + 1; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5181 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
5182 |
grfmsg(2, "GRFDataBlock: block name '%s'...", name); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5183 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5184 |
_grf_data_blocks--; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5185 |
|
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5186 |
switch (_grf_data_type) { |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5187 |
case GDT_SOUND: LoadGRFSound(buf, len - name_len - 2); break; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5188 |
default: NOT_REACHED(); break; |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5189 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5190 |
} |
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5191 |
|
5329
9c5e8061ea0f
(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
|
5192 |
|
9c5e8061ea0f
(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
|
5193 |
/* Used during safety scan on unsafe actions */ |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
9113
diff
changeset
|
5194 |
static void GRFUnsafe(byte *buf, size_t len) |
5329
9c5e8061ea0f
(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
|
5195 |
{ |
7931
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7929
diff
changeset
|
5196 |
SetBit(_cur_grfconfig->flags, GCF_UNSAFE); |
5329
9c5e8061ea0f
(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
|
5197 |
|
5502
003b36599ff8
(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:
5476
diff
changeset
|
5198 |
/* Skip remainder of GRF */ |
003b36599ff8
(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:
5476
diff
changeset
|
5199 |
_skip_sprites = -1; |
5329
9c5e8061ea0f
(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
|
5200 |
} |
9c5e8061ea0f
(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
|
5201 |
|
9c5e8061ea0f
(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
|
5202 |
|
6247 | 5203 |
static void InitializeGRFSpecial() |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5204 |
{ |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
5205 |
_ttdpatch_flags[0] = ((_settings_game.station.always_small_airport ? 1 : 0) << 0x0C) // keepsmallairport |
9354
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5206 |
| (1 << 0x0D) // newairports |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5207 |
| (1 << 0x0E) // largestations |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
5208 |
| ((_settings_game.construction.longbridges ? 1 : 0) << 0x0F) // longbridges |
9354
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5209 |
| (0 << 0x10) // loadtime |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5210 |
| (1 << 0x12) // presignals |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5211 |
| (1 << 0x13) // extpresignals |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
5212 |
| ((_settings_game.vehicle.never_expire_vehicles ? 1 : 0) << 0x16) // enginespersist |
9354
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5213 |
| (1 << 0x1B) // multihead |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5214 |
| (1 << 0x1D) // lowmemory |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5215 |
| (1 << 0x1E); // generalfixes |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5216 |
|
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
5217 |
_ttdpatch_flags[1] = ((_settings_game.economy.station_noise_level ? 1 : 0) << 0x07) // moreairports - based on units of noise |
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
5218 |
| ((_settings_game.vehicle.mammoth_trains ? 1 : 0) << 0x08) // mammothtrains |
9354
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5219 |
| (1 << 0x09) // trainrefit |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5220 |
| (0 << 0x0B) // subsidiaries |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
5221 |
| ((_settings_game.order.gradual_loading ? 1 : 0) << 0x0C) // gradualloading |
9354
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5222 |
| (1 << 0x12) // unifiedmaglevmode - set bit 0 mode. Not revelant to OTTD |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5223 |
| (1 << 0x13) // unifiedmaglevmode - set bit 1 mode |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5224 |
| (1 << 0x14) // bridgespeedlimits |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5225 |
| (1 << 0x16) // eternalgame |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5226 |
| (1 << 0x17) // newtrains |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5227 |
| (1 << 0x18) // newrvs |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5228 |
| (1 << 0x19) // newships |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5229 |
| (1 << 0x1A) // newplanes |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
5230 |
| ((_settings_game.construction.signal_side ? 1 : 0) << 0x1B) // signalsontrafficside |
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
5231 |
| ((_settings_game.vehicle.disable_elrails ? 0 : 1) << 0x1C); // electrifiedrailway |
9354
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5232 |
|
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5233 |
_ttdpatch_flags[2] = (1 << 0x01) // loadallgraphics - obsolote |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5234 |
| (1 << 0x03) // semaphores |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5235 |
| (0 << 0x0B) // enhancedgui |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5236 |
| (0 << 0x0C) // newagerating |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
5237 |
| ((_settings_game.construction.build_on_slopes ? 1 : 0) << 0x0D) // buildonslopes |
9354
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5238 |
| (1 << 0x0E) // fullloadany |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5239 |
| (1 << 0x0F) // planespeed |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5240 |
| (0 << 0x10) // moreindustriesperclimate - obsolete |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5241 |
| (0 << 0x11) // moretoylandfeatures |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5242 |
| (1 << 0x12) // newstations |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5243 |
| (1 << 0x13) // tracktypecostdiff |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5244 |
| (1 << 0x14) // manualconvert |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
5245 |
| ((_settings_game.construction.build_on_slopes ? 1 : 0) << 0x15) // buildoncoasts |
9354
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5246 |
| (1 << 0x16) // canals |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5247 |
| (1 << 0x17) // newstartyear |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
5248 |
| ((_settings_game.vehicle.freight_trains > 1 ? 1 : 0) << 0x18) // freighttrains |
9354
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5249 |
| (1 << 0x19) // newhouses |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5250 |
| (1 << 0x1A) // newbridges |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5251 |
| (1 << 0x1B) // newtownnames |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5252 |
| (1 << 0x1C) // moreanimation |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
5253 |
| ((_settings_game.vehicle.wagon_speed_limits ? 1 : 0) << 0x1D) // wagonspeedlimits |
9354
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5254 |
| (1 << 0x1E) // newshistory |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5255 |
| (0 << 0x1F); // custombridgeheads |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5256 |
|
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5257 |
_ttdpatch_flags[3] = (0 << 0x00) // newcargodistribution |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5258 |
| (1 << 0x01) // windowsnap |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5259 |
| (0 << 0x02) // townbuildnoroad |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5260 |
| (0 << 0x03) // pathbasedsignalling. To enable if ever pbs is back |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5261 |
| (0 << 0x04) // aichoosechance |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5262 |
| (1 << 0x05) // resolutionwidth |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5263 |
| (1 << 0x06) // resolutionheight |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5264 |
| (1 << 0x07) // newindustries |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
5265 |
| ((_settings_game.order.improved_load ? 1 : 0) << 0x08) // fifoloading |
9354
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5266 |
| (0 << 0x09) // townroadbranchprob |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5267 |
| (0 << 0x0A) // tempsnowline |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5268 |
| (1 << 0x0B) // newcargo |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5269 |
| (1 << 0x0C) // enhancemultiplayer |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5270 |
| (1 << 0x0D) // onewayroads |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
5271 |
| ((_settings_game.station.nonuniform_stations ? 1 : 0) << 0x0E) // irregularstations |
9354
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5272 |
| (1 << 0x0F) // statistics |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5273 |
| (1 << 0x10) // newsounds |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5274 |
| (1 << 0x11) // autoreplace |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5275 |
| (1 << 0x12) // autoslope |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5276 |
| (0 << 0x13) // followvehicle |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5277 |
| (1 << 0x14) // trams |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5278 |
| (0 << 0x15) // enhancetunnels |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5279 |
| (1 << 0x16) // shortrvs |
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5280 |
| (1 << 0x17) // articulatedrvs |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
5281 |
| ((_settings_game.vehicle.dynamic_engines ? 1 : 0) << 0x18) // dynamic engines |
9354
845e07db4549
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium
parents:
9334
diff
changeset
|
5282 |
| (1 << 0x1E); // variablerunningcosts |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5283 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5284 |
|
6247 | 5285 |
static void ResetCustomStations() |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
5286 |
{ |
6281 | 5287 |
for (GRFFile *file = _first_grffile; file != NULL; file = file->next) { |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
5288 |
if (file->stations == NULL) continue; |
6281 | 5289 |
for (uint i = 0; i < MAX_STATIONS; i++) { |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
5290 |
if (file->stations[i] == NULL) continue; |
6281 | 5291 |
StationSpec *statspec = file->stations[i]; |
3740
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
5292 |
|
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
5293 |
/* Release renderdata, if it wasn't copied from another custom station spec */ |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
5294 |
if (!statspec->copied_renderdata) { |
6281 | 5295 |
for (uint t = 0; t < statspec->tiles; t++) { |
3740
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
5296 |
free((void*)statspec->renderdata[t].seq); |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
5297 |
} |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
5298 |
free(statspec->renderdata); |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
5299 |
} |
4742b3d6f37b
(svn r4722) - Newstations: release station sprite layout data when uninitializing NewGRF data.
peter1138
parents:
3738
diff
changeset
|
5300 |
|
5061
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5301 |
/* Release platforms and layouts */ |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5302 |
if (!statspec->copied_layouts) { |
6281 | 5303 |
for (uint l = 0; l < statspec->lengths; l++) { |
5304 |
for (uint p = 0; p < statspec->platforms[l]; p++) { |
|
5061
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5305 |
free(statspec->layouts[l][p]); |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5306 |
} |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5307 |
free(statspec->layouts[l]); |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5308 |
} |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5309 |
free(statspec->layouts); |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5310 |
free(statspec->platforms); |
9ca17a7278fa
(svn r7114) -Codechange: [NewStations] Free up custom station layouts
peter1138
parents:
5060
diff
changeset
|
5311 |
} |
3768
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
5312 |
|
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
5313 |
/* Release this station */ |
5194cf3c57b1
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3761
diff
changeset
|
5314 |
free(statspec); |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
5315 |
} |
3501
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
5316 |
|
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
5317 |
/* Free and reset the station data */ |
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
5318 |
free(file->stations); |
0a0c5bcc9a72
(svn r4352) - NewGRF Codechange: dynamically allocate the memory used to store custom station data. This saves us approximately 40KB per GRF file, if there are no stations defined.
peter1138
parents:
3488
diff
changeset
|
5319 |
file->stations = NULL; |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
5320 |
} |
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
5321 |
} |
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
5322 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5323 |
static void ResetCustomHouses() |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5324 |
{ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5325 |
GRFFile *file; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5326 |
uint i; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5327 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5328 |
for (file = _first_grffile; file != NULL; file = file->next) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5329 |
if (file->housespec == NULL) continue; |
6848 | 5330 |
for (i = 0; i < HOUSE_MAX; i++) { |
5331 |
free(file->housespec[i]); |
|
5332 |
} |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5333 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5334 |
free(file->housespec); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5335 |
file->housespec = NULL; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5336 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5337 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5338 |
|
6759
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5339 |
static void ResetCustomIndustries() |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5340 |
{ |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5341 |
GRFFile *file; |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5342 |
|
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5343 |
for (file = _first_grffile; file != NULL; file = file->next) { |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5344 |
uint i; |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5345 |
/* We are verifiying both tiles and industries specs loaded from the grf file |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5346 |
* First, let's deal with industryspec */ |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5347 |
if (file->industryspec != NULL) { |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5348 |
|
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5349 |
for (i = 0; i < NUM_INDUSTRYTYPES; i++) { |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5350 |
IndustrySpec *ind = file->industryspec[i]; |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5351 |
|
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5352 |
if (ind != NULL) { |
6765
50903afa1a48
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
belugas
parents:
6764
diff
changeset
|
5353 |
/* We need to remove the sounds array */ |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
5354 |
if (HasBit(ind->cleanup_flag, CLEAN_RANDOMSOUNDS)) { |
6765
50903afa1a48
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
belugas
parents:
6764
diff
changeset
|
5355 |
free((void*)ind->random_sounds); |
50903afa1a48
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
belugas
parents:
6764
diff
changeset
|
5356 |
} |
50903afa1a48
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
belugas
parents:
6764
diff
changeset
|
5357 |
|
50903afa1a48
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
belugas
parents:
6764
diff
changeset
|
5358 |
/* We need to remove the tiles layouts */ |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
5359 |
if (HasBit(ind->cleanup_flag, CLEAN_TILELSAYOUT) && ind->table != NULL) { |
6765
50903afa1a48
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
belugas
parents:
6764
diff
changeset
|
5360 |
for (int j = 0; j < ind->num_table; j++) { |
50903afa1a48
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
belugas
parents:
6764
diff
changeset
|
5361 |
/* remove the individual layouts */ |
50903afa1a48
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
belugas
parents:
6764
diff
changeset
|
5362 |
if (ind->table[j] != NULL) { |
50903afa1a48
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
belugas
parents:
6764
diff
changeset
|
5363 |
free((IndustryTileTable*)ind->table[j]); |
50903afa1a48
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
belugas
parents:
6764
diff
changeset
|
5364 |
} |
50903afa1a48
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
belugas
parents:
6764
diff
changeset
|
5365 |
} |
50903afa1a48
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
belugas
parents:
6764
diff
changeset
|
5366 |
/* remove the layouts pointers */ |
50903afa1a48
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
belugas
parents:
6764
diff
changeset
|
5367 |
free((IndustryTileTable**)ind->table); |
50903afa1a48
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
belugas
parents:
6764
diff
changeset
|
5368 |
ind->table = NULL; |
50903afa1a48
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
belugas
parents:
6764
diff
changeset
|
5369 |
} |
50903afa1a48
(svn r10001) -Codechange: Add support for removing dynamically allocated newgrf data
belugas
parents:
6764
diff
changeset
|
5370 |
|
6759
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5371 |
free(ind); |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5372 |
ind = NULL; |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5373 |
} |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5374 |
} |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5375 |
|
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5376 |
free(file->industryspec); |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5377 |
file->industryspec = NULL; |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5378 |
} |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5379 |
|
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5380 |
if (file->indtspec != NULL) { |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5381 |
for (i = 0; i < NUM_INDUSTRYTILES; i++) { |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5382 |
if (file->indtspec[i] != NULL) { |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5383 |
free(file->indtspec[i]); |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5384 |
file->indtspec[i] = NULL; |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5385 |
} |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5386 |
} |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5387 |
|
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5388 |
free(file->indtspec); |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5389 |
file->indtspec = NULL; |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5390 |
} |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5391 |
} |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5392 |
} |
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5393 |
|
6247 | 5394 |
static void ResetNewGRF() |
4953
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5395 |
{ |
6281 | 5396 |
GRFFile *next; |
5397 |
||
5398 |
for (GRFFile *f = _first_grffile; f != NULL; f = next) { |
|
4953
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5399 |
next = f->next; |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5400 |
|
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5401 |
free(f->filename); |
6684
2f8288bdd427
(svn r9916) -Codechange: Free memory used by cargo translation tables
peter1138
parents:
6659
diff
changeset
|
5402 |
free(f->cargo_list); |
4953
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5403 |
free(f); |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5404 |
} |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5405 |
|
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5406 |
_first_grffile = NULL; |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5407 |
_cur_grffile = NULL; |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5408 |
} |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5409 |
|
6870
02df7ee32d9a
(svn r10110) -Fix: Reset NewGRF errors along with all the other NewGRF data so that errors get loaded again when pressing "Apply".
maedhros
parents:
6857
diff
changeset
|
5410 |
static void ResetNewGRFErrors() |
02df7ee32d9a
(svn r10110) -Fix: Reset NewGRF errors along with all the other NewGRF data so that errors get loaded again when pressing "Apply".
maedhros
parents:
6857
diff
changeset
|
5411 |
{ |
02df7ee32d9a
(svn r10110) -Fix: Reset NewGRF errors along with all the other NewGRF data so that errors get loaded again when pressing "Apply".
maedhros
parents:
6857
diff
changeset
|
5412 |
for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) { |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
5413 |
if (!HasBit(c->flags, GCF_COPY) && c->error != NULL) { |
6873
b4d0648edd29
(svn r10114) -Fix: Only load newgrf error messages if the language matches the current
maedhros
parents:
6870
diff
changeset
|
5414 |
free(c->error->custom_message); |
b4d0648edd29
(svn r10114) -Fix: Only load newgrf error messages if the language matches the current
maedhros
parents:
6870
diff
changeset
|
5415 |
free(c->error->data); |
6870
02df7ee32d9a
(svn r10110) -Fix: Reset NewGRF errors along with all the other NewGRF data so that errors get loaded again when pressing "Apply".
maedhros
parents:
6857
diff
changeset
|
5416 |
free(c->error); |
02df7ee32d9a
(svn r10110) -Fix: Reset NewGRF errors along with all the other NewGRF data so that errors get loaded again when pressing "Apply".
maedhros
parents:
6857
diff
changeset
|
5417 |
c->error = NULL; |
02df7ee32d9a
(svn r10110) -Fix: Reset NewGRF errors along with all the other NewGRF data so that errors get loaded again when pressing "Apply".
maedhros
parents:
6857
diff
changeset
|
5418 |
} |
02df7ee32d9a
(svn r10110) -Fix: Reset NewGRF errors along with all the other NewGRF data so that errors get loaded again when pressing "Apply".
maedhros
parents:
6857
diff
changeset
|
5419 |
} |
02df7ee32d9a
(svn r10110) -Fix: Reset NewGRF errors along with all the other NewGRF data so that errors get loaded again when pressing "Apply".
maedhros
parents:
6857
diff
changeset
|
5420 |
} |
02df7ee32d9a
(svn r10110) -Fix: Reset NewGRF errors along with all the other NewGRF data so that errors get loaded again when pressing "Apply".
maedhros
parents:
6857
diff
changeset
|
5421 |
|
2491
15a117630a4f
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
5422 |
/** |
2463
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
5423 |
* Reset all NewGRF loaded data |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
5424 |
* TODO |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
5425 |
*/ |
6247 | 5426 |
static void ResetNewGRFData() |
2463
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
5427 |
{ |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
5428 |
CleanUpStrings(); |
6956
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
5429 |
CleanUpGRFTownNames(); |
3601
138bf309cf27
(svn r4493) Newgrf : Action 04. Beginning of implementation.
belugas
parents:
3595
diff
changeset
|
5430 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
5431 |
/* Copy/reset original engine info data */ |
8221
59791d0e0c04
(svn r11784) -Codechange: set up initial engine data in one place
peter1138
parents:
8214
diff
changeset
|
5432 |
SetupEngines(); |
2478
cd6a02ba3853
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2476
diff
changeset
|
5433 |
|
8489
28bedfca9e27
(svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas
parents:
8484
diff
changeset
|
5434 |
/* Copy/reset original bridge info data */ |
28bedfca9e27
(svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas
parents:
8484
diff
changeset
|
5435 |
ResetBridges(); |
2491
15a117630a4f
(svn r3017) -NewGRF: Implement sprite group unreferencing and unloading.
peter1138
parents:
2490
diff
changeset
|
5436 |
|
10001
df9284007ed5
(svn r14158) -Codechange: Initialization of rail type data from static source, so data can be changed.
peter1138
parents:
9989
diff
changeset
|
5437 |
/* Reset rail type information */ |
df9284007ed5
(svn r14158) -Codechange: Initialization of rail type data from static source, so data can be changed.
peter1138
parents:
9989
diff
changeset
|
5438 |
ResetRailTypes(); |
df9284007ed5
(svn r14158) -Codechange: Initialization of rail type data from static source, so data can be changed.
peter1138
parents:
9989
diff
changeset
|
5439 |
|
9025
be4668a781b8
(svn r12839) -Codechange: Allocate temporary engine data when loading GRFs as needed instead of statically.
peter1138
parents:
9003
diff
changeset
|
5440 |
/* Allocate temporary refit/cargo class data */ |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5441 |
_gted = CallocT<GRFTempEngineData>(GetEnginePoolSize()); |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5442 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
5443 |
/* Reset GRM reservations */ |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
5444 |
memset(&_grm_engines, 0, sizeof(_grm_engines)); |
6781
17e17ed7d032
(svn r10019) -Codechange: Implement GRM for newcargos
peter1138
parents:
6769
diff
changeset
|
5445 |
memset(&_grm_cargos, 0, sizeof(_grm_cargos)); |
4961
5c6439ce39f1
(svn r6960) - Feature: NewGRF: Implement some support for GRF Resource Management (GRM)
peter1138
parents:
4953
diff
changeset
|
5446 |
|
8544
47b99dc2da26
(svn r12122) -Codechange: Add framework for generic feature callbacks, along with some parts for AI use.
peter1138
parents:
8541
diff
changeset
|
5447 |
/* Reset generic feature callback lists */ |
47b99dc2da26
(svn r12122) -Codechange: Add framework for generic feature callbacks, along with some parts for AI use.
peter1138
parents:
8541
diff
changeset
|
5448 |
ResetGenericCallbacks(); |
47b99dc2da26
(svn r12122) -Codechange: Add framework for generic feature callbacks, along with some parts for AI use.
peter1138
parents:
8541
diff
changeset
|
5449 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
5450 |
/* Reset price base data */ |
2506
eca87f30e05a
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
peter1138
parents:
2491
diff
changeset
|
5451 |
ResetPriceBaseMultipliers(); |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
5452 |
|
4377
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
5453 |
/* Reset the curencies array */ |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
5454 |
ResetCurrencies(); |
f04bcf6f9a04
(svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents:
4322
diff
changeset
|
5455 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5456 |
/* Reset the house array */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5457 |
ResetCustomHouses(); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5458 |
ResetHouses(); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5459 |
|
6743
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6691
diff
changeset
|
5460 |
/* Reset the industries structures*/ |
6759
cd55b02175dd
(svn r9994) -Codechange: Add pointers for Industry and Industry Tiles in the grf file.
belugas
parents:
6743
diff
changeset
|
5461 |
ResetCustomIndustries(); |
6743
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6691
diff
changeset
|
5462 |
ResetIndustries(); |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6691
diff
changeset
|
5463 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
5464 |
/* Reset station classes */ |
2625
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
5465 |
ResetStationClasses(); |
19bf7f695537
(svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
2624
diff
changeset
|
5466 |
ResetCustomStations(); |
2812
95102021c840
(svn r3360) Fix initialization of engines for precalculation of default refit mask.
peter1138
parents:
2769
diff
changeset
|
5467 |
|
8372
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
5468 |
/* Reset canal sprite groups and flags */ |
49f8ca06527d
(svn r11938) -Codechange: support loading of canal/river properties (though still ignored)
peter1138
parents:
8323
diff
changeset
|
5469 |
memset(_water_feature, 0, sizeof(_water_feature)); |
6583
71d62b85d3ad
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6581
diff
changeset
|
5470 |
|
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
5471 |
/* Reset the snowline table. */ |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
5472 |
ClearSnowLine(); |
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6342
diff
changeset
|
5473 |
|
4953
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5474 |
/* Reset NewGRF files */ |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5475 |
ResetNewGRF(); |
2a33d1ff2ab7
(svn r6948) - Codechange: Clear out all NewGRF file data before loading files again
peter1138
parents:
4952
diff
changeset
|
5476 |
|
6870
02df7ee32d9a
(svn r10110) -Fix: Reset NewGRF errors along with all the other NewGRF data so that errors get loaded again when pressing "Apply".
maedhros
parents:
6857
diff
changeset
|
5477 |
/* Reset NewGRF errors. */ |
02df7ee32d9a
(svn r10110) -Fix: Reset NewGRF errors along with all the other NewGRF data so that errors get loaded again when pressing "Apply".
maedhros
parents:
6857
diff
changeset
|
5478 |
ResetNewGRFErrors(); |
02df7ee32d9a
(svn r10110) -Fix: Reset NewGRF errors along with all the other NewGRF data so that errors get loaded again when pressing "Apply".
maedhros
parents:
6857
diff
changeset
|
5479 |
|
6091
c8827d9ae04a
(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:
6090
diff
changeset
|
5480 |
/* Set up the default cargo types */ |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9390
diff
changeset
|
5481 |
SetupCargoForClimate(_settings_game.game_creation.landscape); |
6091
c8827d9ae04a
(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:
6090
diff
changeset
|
5482 |
|
3845
af6eb0103fed
(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
|
5483 |
/* Reset misc GRF features and train list display variables */ |
af6eb0103fed
(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
|
5484 |
_misc_grf_features = 0; |
af6eb0103fed
(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
|
5485 |
_traininfo_vehicle_pitch = 0; |
af6eb0103fed
(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
|
5486 |
_traininfo_vehicle_width = 29; |
6769
13ccbd0f86b3
(svn r10005) -Codechange: Merge two flags (2cc and newhouses) indicating some newgrf features have been loaded, and introduce the newindustry one.
belugas
parents:
6765
diff
changeset
|
5487 |
|
6914
6219e65dd7bf
(svn r10167) -Codechange: Change the flagging system of grf loaded feature from a bitset to a bool evaluation.
belugas
parents:
6908
diff
changeset
|
5488 |
_loaded_newgrf_features.has_2CC = false; |
6219e65dd7bf
(svn r10167) -Codechange: Change the flagging system of grf loaded feature from a bitset to a bool evaluation.
belugas
parents:
6908
diff
changeset
|
5489 |
_loaded_newgrf_features.has_newhouses = false; |
7661
3c1f788966ec
(svn r11192) -Fix: Little typo with bigger consequences when trying to remove a newindustries aware grf
belugas
parents:
7660
diff
changeset
|
5490 |
_loaded_newgrf_features.has_newindustries = false; |
8403
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5491 |
_loaded_newgrf_features.shore = SHORE_REPLACE_NONE; |
3845
af6eb0103fed
(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
|
5492 |
|
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5493 |
/* Clear all GRF overrides */ |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5494 |
_grf_id_overrides.clear(); |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5495 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5496 |
InitializeSoundPool(); |
3595
a0acdb23e662
(svn r4486) - NewGRF: Create and use a memory pool to manage sprite groups. This
peter1138
parents:
3593
diff
changeset
|
5497 |
InitializeSpriteGroupPool(); |
2463
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
5498 |
} |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
5499 |
|
6147
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5500 |
static void BuildCargoTranslationMap() |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5501 |
{ |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5502 |
memset(_cur_grffile->cargo_map, 0xFF, sizeof(_cur_grffile->cargo_map)); |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5503 |
|
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5504 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5505 |
const CargoSpec *cs = GetCargo(c); |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5506 |
if (!cs->IsValid()) continue; |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5507 |
|
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5508 |
if (_cur_grffile->cargo_max == 0) { |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5509 |
/* Default translation table, so just a straight mapping to bitnum */ |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5510 |
_cur_grffile->cargo_map[c] = cs->bitnum; |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5511 |
} else { |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5512 |
/* Check the translation table for this cargo's label */ |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5513 |
for (uint i = 0; i < _cur_grffile->cargo_max; i++) { |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5514 |
if (cs->label == _cur_grffile->cargo_list[i]) { |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5515 |
_cur_grffile->cargo_map[c] = i; |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5516 |
break; |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5517 |
} |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5518 |
} |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5519 |
} |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5520 |
} |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5521 |
} |
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
5522 |
|
3628
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
5523 |
static void InitNewGRFFile(const GRFConfig *config, int sprite_offset) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5524 |
{ |
6281 | 5525 |
GRFFile *newfile = GetFileByFilename(config->filename); |
490
03e2d2abeec7
(svn r772) Whoops, I know. Do not consider pointer to be a boolean value. Sorry 'bout that, sirs.
pasky
parents:
489
diff
changeset
|
5526 |
if (newfile != NULL) { |
489
a419f732c8ef
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
5527 |
/* We already loaded it once. */ |
a419f732c8ef
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
5528 |
newfile->sprite_offset = sprite_offset; |
a419f732c8ef
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
5529 |
_cur_grffile = newfile; |
a419f732c8ef
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
5530 |
return; |
a419f732c8ef
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
5531 |
} |
a419f732c8ef
(svn r771) Do not give a file new {struct GRFFile} if it was already loaded once. Eliminates those double entries in the newgrf manager and also some possible memory leaks.
pasky
parents:
478
diff
changeset
|
5532 |
|
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
5533 |
newfile = CallocT<GRFFile>(1); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5534 |
|
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
5535 |
if (newfile == NULL) error ("Out of memory"); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5536 |
|
7034
e2d80a01d9c1
(svn r10298) -Fix [FS#903]: show the subdirectory below the default data directory in this filename in the newgrf list. The directory was removed in r9560 because then it used to full path instead of the path relative to the data directory, but since the inclusion of "search paths" that is not necessary anymore.
rubidium
parents:
6956
diff
changeset
|
5537 |
newfile->filename = strdup(config->filename); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5538 |
newfile->sprite_offset = sprite_offset; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5539 |
|
3628
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
5540 |
/* Copy the initial parameter list */ |
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
5541 |
assert(lengthof(newfile->param) == lengthof(config->param) && lengthof(config->param) == 0x80); |
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
5542 |
newfile->param_end = config->num_params; |
5430
7864a926dd4d
(svn r7636) -Cleanup: Remove unused window classes (sorry WC-mess) and use sizeof(array) instead
Darkvater
parents:
5413
diff
changeset
|
5543 |
memcpy(newfile->param, config->param, sizeof(newfile->param)); |
3628
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
5544 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5545 |
if (_first_grffile == NULL) { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5546 |
_cur_grffile = newfile; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5547 |
_first_grffile = newfile; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5548 |
} else { |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5549 |
_cur_grffile->next = newfile; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5550 |
_cur_grffile = newfile; |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5551 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5552 |
} |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5553 |
|
5037
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
5554 |
|
6145
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5555 |
/** List of what cargo labels are refittable for the given the vehicle-type. |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5556 |
* Only currently active labels are applied. */ |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5557 |
static const CargoLabel _default_refitmasks_rail[] = { |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5558 |
'PASS', 'COAL', 'MAIL', 'LVST', 'GOOD', 'GRAI', 'WHEA', 'MAIZ', 'WOOD', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5559 |
'IORE', 'STEL', 'VALU', 'GOLD', 'DIAM', 'PAPR', 'FOOD', 'FRUT', 'CORE', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5560 |
'WATR', 'SUGR', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5561 |
'PLST', 'FZDR', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5562 |
0 }; |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5563 |
|
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5564 |
static const CargoLabel _default_refitmasks_road[] = { |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5565 |
0 }; |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5566 |
|
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5567 |
static const CargoLabel _default_refitmasks_ships[] = { |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5568 |
'COAL', 'MAIL', 'LVST', 'GOOD', 'GRAI', 'WHEA', 'MAIZ', 'WOOD', 'IORE', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5569 |
'STEL', 'VALU', 'GOLD', 'DIAM', 'PAPR', 'FOOD', 'FRUT', 'CORE', 'WATR', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5570 |
'RUBR', 'SUGR', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5571 |
'PLST', 'FZDR', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5572 |
0 }; |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5573 |
|
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5574 |
static const CargoLabel _default_refitmasks_aircraft[] = { |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5575 |
'PASS', 'MAIL', 'GOOD', 'VALU', 'GOLD', 'DIAM', 'FOOD', 'FRUT', 'SUGR', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5576 |
'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', 'PLST', 'FZDR', |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5577 |
0 }; |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5578 |
|
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5579 |
static const CargoLabel *_default_refitmasks[] = { |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5580 |
_default_refitmasks_rail, |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5581 |
_default_refitmasks_road, |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5582 |
_default_refitmasks_ships, |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5583 |
_default_refitmasks_aircraft, |
5037
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
5584 |
}; |
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
5585 |
|
70f2158c5de0
(svn r7079) -Codechange: Move an array to the only place it is used.
peter1138
parents:
5024
diff
changeset
|
5586 |
|
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5587 |
/** |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5588 |
* Precalculate refit masks from cargo classes for all vehicles. |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5589 |
*/ |
6247 | 5590 |
static void CalculateRefitMasks() |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5591 |
{ |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5592 |
Engine *e; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5593 |
|
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5594 |
FOR_ALL_ENGINES(e) { |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5595 |
EngineID engine = e->index; |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5596 |
EngineInfo *ei = &e->info; |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5597 |
uint32 mask = 0; |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5598 |
uint32 not_mask = 0; |
6284
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5599 |
uint32 xor_mask = 0; |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5600 |
|
8754
17855b1b7e36
(svn r12450) -Codechange: Use a pointer instead of several array dereferences.
peter1138
parents:
8753
diff
changeset
|
5601 |
if (ei->refit_mask != 0) { |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5602 |
const GRFFile *file = e->grffile; |
6284
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5603 |
if (file != NULL && file->cargo_max != 0) { |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5604 |
/* Apply cargo translation table to the refit mask */ |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5605 |
uint num_cargo = min(32, file->cargo_max); |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5606 |
for (uint i = 0; i < num_cargo; i++) { |
8754
17855b1b7e36
(svn r12450) -Codechange: Use a pointer instead of several array dereferences.
peter1138
parents:
8753
diff
changeset
|
5607 |
if (!HasBit(ei->refit_mask, i)) continue; |
6284
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5608 |
|
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5609 |
CargoID c = GetCargoIDByLabel(file->cargo_list[i]); |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5610 |
if (c == CT_INVALID) continue; |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5611 |
|
7931
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7929
diff
changeset
|
5612 |
SetBit(xor_mask, c); |
6284
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5613 |
} |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5614 |
} else { |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5615 |
/* No cargo table, so use the cargo bitnum values */ |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5616 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5617 |
const CargoSpec *cs = GetCargo(c); |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5618 |
if (!cs->IsValid()) continue; |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5619 |
|
8754
17855b1b7e36
(svn r12450) -Codechange: Use a pointer instead of several array dereferences.
peter1138
parents:
8753
diff
changeset
|
5620 |
if (HasBit(ei->refit_mask, cs->bitnum)) SetBit(xor_mask, c); |
6284
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5621 |
} |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5622 |
} |
29edfea44492
(svn r9102) -Codechange: (NewGRF) Apply cargo translation table to vehicle refit masks
peter1138
parents:
6282
diff
changeset
|
5623 |
} |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5624 |
|
9025
be4668a781b8
(svn r12839) -Codechange: Allocate temporary engine data when loading GRFs as needed instead of statically.
peter1138
parents:
9003
diff
changeset
|
5625 |
if (_gted[engine].cargo_allowed != 0) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
5626 |
/* Build up the list of cargo types from the set cargo classes. */ |
6281 | 5627 |
for (CargoID i = 0; i < NUM_CARGO; i++) { |
6113
a10ede03ac58
(svn r8849) -Codechange: Replace hardcoded global/climate cargo mapping tables with dynamically generated data. Change associated code to use new functions.
peter1138
parents:
6107
diff
changeset
|
5628 |
const CargoSpec *cs = GetCargo(i); |
9025
be4668a781b8
(svn r12839) -Codechange: Allocate temporary engine data when loading GRFs as needed instead of statically.
peter1138
parents:
9003
diff
changeset
|
5629 |
if (_gted[engine].cargo_allowed & cs->classes) SetBit(mask, i); |
be4668a781b8
(svn r12839) -Codechange: Allocate temporary engine data when loading GRFs as needed instead of statically.
peter1138
parents:
9003
diff
changeset
|
5630 |
if (_gted[engine].cargo_disallowed & cs->classes) SetBit(not_mask, i); |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5631 |
} |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5632 |
} else if (xor_mask == 0) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
5633 |
/* Don't apply default refit mask to wagons or engines with no capacity */ |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5634 |
if (e->type != VEH_TRAIN || (e->u.rail.capacity != 0 && e->u.rail.railveh_type != RAILVEH_WAGON)) { |
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5635 |
const CargoLabel *cl = _default_refitmasks[e->type]; |
6145
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5636 |
for (uint i = 0;; i++) { |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5637 |
if (cl[i] == 0) break; |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5638 |
|
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5639 |
CargoID cargo = GetCargoIDByLabel(cl[i]); |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5640 |
if (cargo == CT_INVALID) continue; |
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5641 |
|
7931
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7929
diff
changeset
|
5642 |
SetBit(xor_mask, cargo); |
6145
c839ab950ecc
(svn r8888) -Codechange: Replace hardcoded default cargo bitmasks with a list of cargo labels.
peter1138
parents:
6143
diff
changeset
|
5643 |
} |
3033
9cba043eb38f
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3026
diff
changeset
|
5644 |
} |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5645 |
} |
8754
17855b1b7e36
(svn r12450) -Codechange: Use a pointer instead of several array dereferences.
peter1138
parents:
8753
diff
changeset
|
5646 |
|
17855b1b7e36
(svn r12450) -Codechange: Use a pointer instead of several array dereferences.
peter1138
parents:
8753
diff
changeset
|
5647 |
ei->refit_mask = ((mask & ~not_mask) ^ xor_mask) & _cargo_mask; |
6142
80f876e7bb9f
(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:
6139
diff
changeset
|
5648 |
|
80f876e7bb9f
(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:
6139
diff
changeset
|
5649 |
/* Check if this engine's cargo type is valid. If not, set to the first refittable |
80f876e7bb9f
(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:
6139
diff
changeset
|
5650 |
* cargo type. Apparently cargo_type isn't a common property... */ |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5651 |
switch (e->type) { |
6638
09c5d7bf69a5
(svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents:
6629
diff
changeset
|
5652 |
default: NOT_REACHED(); |
09c5d7bf69a5
(svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents:
6629
diff
changeset
|
5653 |
case VEH_AIRCRAFT: break; |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6248
diff
changeset
|
5654 |
case VEH_TRAIN: { |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5655 |
RailVehicleInfo *rvi = &e->u.rail; |
6142
80f876e7bb9f
(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:
6139
diff
changeset
|
5656 |
if (rvi->cargo_type == CT_INVALID) rvi->cargo_type = FindFirstRefittableCargo(engine); |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5657 |
if (rvi->cargo_type == CT_INVALID) ei->climates = 0x80; |
6142
80f876e7bb9f
(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:
6139
diff
changeset
|
5658 |
break; |
80f876e7bb9f
(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:
6139
diff
changeset
|
5659 |
} |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6248
diff
changeset
|
5660 |
case VEH_ROAD: { |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5661 |
RoadVehicleInfo *rvi = &e->u.road; |
6142
80f876e7bb9f
(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:
6139
diff
changeset
|
5662 |
if (rvi->cargo_type == CT_INVALID) rvi->cargo_type = FindFirstRefittableCargo(engine); |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5663 |
if (rvi->cargo_type == CT_INVALID) ei->climates = 0x80; |
6142
80f876e7bb9f
(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:
6139
diff
changeset
|
5664 |
break; |
80f876e7bb9f
(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:
6139
diff
changeset
|
5665 |
} |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6248
diff
changeset
|
5666 |
case VEH_SHIP: { |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5667 |
ShipVehicleInfo *svi = &e->u.ship; |
6142
80f876e7bb9f
(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:
6139
diff
changeset
|
5668 |
if (svi->cargo_type == CT_INVALID) svi->cargo_type = FindFirstRefittableCargo(engine); |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
5669 |
if (svi->cargo_type == CT_INVALID) ei->climates = 0x80; |
6142
80f876e7bb9f
(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:
6139
diff
changeset
|
5670 |
break; |
80f876e7bb9f
(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:
6139
diff
changeset
|
5671 |
} |
80f876e7bb9f
(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:
6139
diff
changeset
|
5672 |
} |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5673 |
} |
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
5674 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5675 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5676 |
/** Add all new houses to the house array. House properties can be set at any |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5677 |
* time in the GRF file, so we can only add a house spec to the house array |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5678 |
* after the file has finished loading. We also need to check the dates, due to |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5679 |
* the TTDPatch behaviour described below that we need to emulate. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5680 |
static void FinaliseHouseArray() |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5681 |
{ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5682 |
/* If there are no houses with start dates before 1930, then all houses |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5683 |
* with start dates of 1930 have them reset to 0. This is in order to be |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5684 |
* compatible with TTDPatch, where if no houses have start dates before |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5685 |
* 1930 and the date is before 1930, the game pretends that this is 1930. |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5686 |
* If there have been any houses defined with start dates before 1930 then |
8165
5ba605a5dd90
(svn r11728) -Fix [FS#1577]: if there are no houses that can be build in a specific year yet, force the houses with the earliest introduction year to be available.
rubidium
parents:
8164
diff
changeset
|
5687 |
* the dates are left alone. |
5ba605a5dd90
(svn r11728) -Fix [FS#1577]: if there are no houses that can be build in a specific year yet, force the houses with the earliest introduction year to be available.
rubidium
parents:
8164
diff
changeset
|
5688 |
* On the other hand, why 1930? Just 'fix' the houses with the lowest |
5ba605a5dd90
(svn r11728) -Fix [FS#1577]: if there are no houses that can be build in a specific year yet, force the houses with the earliest introduction year to be available.
rubidium
parents:
8164
diff
changeset
|
5689 |
* minimum introduction date to 0. |
5ba605a5dd90
(svn r11728) -Fix [FS#1577]: if there are no houses that can be build in a specific year yet, force the houses with the earliest introduction year to be available.
rubidium
parents:
8164
diff
changeset
|
5690 |
*/ |
9450
9e7d05b0b1e5
(svn r13368) -Codechange: give house's min/max_date a better name, as it is really year, not date
belugas
parents:
9446
diff
changeset
|
5691 |
Year min_year = MAX_YEAR; |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5692 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5693 |
for (GRFFile *file = _first_grffile; file != NULL; file = file->next) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5694 |
if (file->housespec == NULL) continue; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5695 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5696 |
for (int i = 0; i < HOUSE_MAX; i++) { |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5697 |
HouseSpec *hs = file->housespec[i]; |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5698 |
if (hs != NULL) { |
6629
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
6623
diff
changeset
|
5699 |
_house_mngr.SetEntitySpec(hs); |
9450
9e7d05b0b1e5
(svn r13368) -Codechange: give house's min/max_date a better name, as it is really year, not date
belugas
parents:
9446
diff
changeset
|
5700 |
if (hs->min_year < min_year) min_year = hs->min_year; |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5701 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5702 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5703 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5704 |
|
9450
9e7d05b0b1e5
(svn r13368) -Codechange: give house's min/max_date a better name, as it is really year, not date
belugas
parents:
9446
diff
changeset
|
5705 |
if (min_year != 0) { |
8165
5ba605a5dd90
(svn r11728) -Fix [FS#1577]: if there are no houses that can be build in a specific year yet, force the houses with the earliest introduction year to be available.
rubidium
parents:
8164
diff
changeset
|
5706 |
for (int i = 0; i < HOUSE_MAX; i++) { |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5707 |
HouseSpec *hs = GetHouseSpecs(i); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5708 |
|
9450
9e7d05b0b1e5
(svn r13368) -Codechange: give house's min/max_date a better name, as it is really year, not date
belugas
parents:
9446
diff
changeset
|
5709 |
if (hs->enabled && hs->min_year == min_year) hs->min_year = 0; |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5710 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5711 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5712 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5713 |
|
7183
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5714 |
/** Add all new industries to the industry array. Industry properties can be set at any |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5715 |
* time in the GRF file, so we can only add a industry spec to the industry array |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5716 |
* after the file has finished loading. */ |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5717 |
static void FinaliseIndustriesArray() |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5718 |
{ |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5719 |
for (GRFFile *file = _first_grffile; file != NULL; file = file->next) { |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5720 |
if (file->industryspec != NULL) { |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5721 |
for (int i = 0; i < NUM_INDUSTRYTYPES; i++) { |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5722 |
IndustrySpec *indsp = file->industryspec[i]; |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5723 |
|
7217
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5724 |
if (indsp != NULL && indsp->enabled) { |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5725 |
StringID strid; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5726 |
/* process the conversion of text at the end, so to be sure everything will be fine |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5727 |
* and available. Check if it does not return undefind marker, which is a very good sign of a |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5728 |
* substitute industry who has not changed the string been examined, thus using it as such */ |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5729 |
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->name); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5730 |
if (strid != STR_UNDEFINED) indsp->name = strid; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5731 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5732 |
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->closure_text); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5733 |
if (strid != STR_UNDEFINED) indsp->closure_text = strid; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5734 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5735 |
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->production_up_text); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5736 |
if (strid != STR_UNDEFINED) indsp->production_up_text = strid; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5737 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5738 |
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->production_down_text); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5739 |
if (strid != STR_UNDEFINED) indsp->production_down_text = strid; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5740 |
|
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5741 |
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->new_industry_text); |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5742 |
if (strid != STR_UNDEFINED) indsp->new_industry_text = strid; |
ff5b3c502e84
(svn r10495) -Codechange: Add the Action 00 property handlers for Industries and Industry tiles
belugas
parents:
7183
diff
changeset
|
5743 |
|
8470
ea11349a25ed
(svn r12041) -Codechange: Add the loader and the property for action 00 industries, prop 24, nearby station name.
belugas
parents:
8449
diff
changeset
|
5744 |
if (indsp->station_name != STR_NULL) { |
ea11349a25ed
(svn r12041) -Codechange: Add the loader and the property for action 00 industries, prop 24, nearby station name.
belugas
parents:
8449
diff
changeset
|
5745 |
/* STR_NULL (0) can be set by grf. It has a meaning regarding assignation of the |
10015
2b721243365f
(svn r14174) -Fix: since now, we are 'losing' things, not 'loosing'
smatz
parents:
10013
diff
changeset
|
5746 |
* station's name. Don't want to lose the value, therefore, do not process. */ |
8470
ea11349a25ed
(svn r12041) -Codechange: Add the loader and the property for action 00 industries, prop 24, nearby station name.
belugas
parents:
8449
diff
changeset
|
5747 |
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->station_name); |
ea11349a25ed
(svn r12041) -Codechange: Add the loader and the property for action 00 industries, prop 24, nearby station name.
belugas
parents:
8449
diff
changeset
|
5748 |
if (strid != STR_UNDEFINED) indsp->station_name = strid; |
ea11349a25ed
(svn r12041) -Codechange: Add the loader and the property for action 00 industries, prop 24, nearby station name.
belugas
parents:
8449
diff
changeset
|
5749 |
} |
ea11349a25ed
(svn r12041) -Codechange: Add the loader and the property for action 00 industries, prop 24, nearby station name.
belugas
parents:
8449
diff
changeset
|
5750 |
|
7183
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5751 |
_industry_mngr.SetEntitySpec(indsp); |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5752 |
_loaded_newgrf_features.has_newindustries = true; |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5753 |
} |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5754 |
} |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5755 |
} |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5756 |
|
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5757 |
if (file->indtspec != NULL) { |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5758 |
for (int i = 0; i < NUM_INDUSTRYTILES; i++) { |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5759 |
IndustryTileSpec *indtsp = file->indtspec[i]; |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5760 |
if (indtsp != NULL) { |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5761 |
_industile_mngr.SetEntitySpec(indtsp); |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5762 |
} |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5763 |
} |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5764 |
} |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5765 |
} |
7233
aadfbb505671
(svn r10514) -Codechange: add support for getting the nearest industry with a given type.
rubidium
parents:
7229
diff
changeset
|
5766 |
|
aadfbb505671
(svn r10514) -Codechange: add support for getting the nearest industry with a given type.
rubidium
parents:
7229
diff
changeset
|
5767 |
for (uint j = 0; j < NUM_INDUSTRYTYPES; j++) { |
aadfbb505671
(svn r10514) -Codechange: add support for getting the nearest industry with a given type.
rubidium
parents:
7229
diff
changeset
|
5768 |
IndustrySpec *indsp = &_industry_specs[j]; |
aadfbb505671
(svn r10514) -Codechange: add support for getting the nearest industry with a given type.
rubidium
parents:
7229
diff
changeset
|
5769 |
if (indsp->enabled && indsp->grf_prop.grffile != NULL) { |
aadfbb505671
(svn r10514) -Codechange: add support for getting the nearest industry with a given type.
rubidium
parents:
7229
diff
changeset
|
5770 |
for (uint i = 0; i < 3; i++) { |
aadfbb505671
(svn r10514) -Codechange: add support for getting the nearest industry with a given type.
rubidium
parents:
7229
diff
changeset
|
5771 |
indsp->conflicting[i] = MapNewGRFIndustryType(indsp->conflicting[i], indsp->grf_prop.grffile->grfid); |
aadfbb505671
(svn r10514) -Codechange: add support for getting the nearest industry with a given type.
rubidium
parents:
7229
diff
changeset
|
5772 |
} |
aadfbb505671
(svn r10514) -Codechange: add support for getting the nearest industry with a given type.
rubidium
parents:
7229
diff
changeset
|
5773 |
} |
aadfbb505671
(svn r10514) -Codechange: add support for getting the nearest industry with a given type.
rubidium
parents:
7229
diff
changeset
|
5774 |
} |
7183
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
5775 |
} |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
5776 |
|
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5777 |
/* Here we perform initial decoding of some special sprites (as are they |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5778 |
* described at http://www.ttdpatch.net/src/newgrf.txt, but this is only a very |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5779 |
* partial implementation yet). */ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5780 |
/* XXX: We consider GRF files trusted. It would be trivial to exploit OTTD by |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5781 |
* a crafted invalid GRF file. We should tell that to the user somehow, or |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5782 |
* better make this more robust in the future. */ |
5008
c2b96042d529
(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
|
5783 |
static void DecodeSpecialSprite(uint num, GrfLoadingStage stage) |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5784 |
{ |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5785 |
/* XXX: There is a difference between staged loading in TTDPatch and |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5786 |
* here. In TTDPatch, for some reason actions 1 and 2 are carried out |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
5787 |
* during stage 1, whilst action 3 is carried out during stage 2 (to |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5788 |
* "resolve" cargo IDs... wtf). This is a little problem, because cargo |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5789 |
* IDs are valid only within a given set (action 1) block, and may be |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5790 |
* overwritten after action 3 associates them. But overwriting happens |
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5791 |
* in an earlier stage than associating, so... We just process actions |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
5792 |
* 1 and 2 in stage 2 now, let's hope that won't get us into problems. |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5793 |
* --pasky */ |
3561
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
5794 |
/* We need a pre-stage to set up GOTO labels of Action 0x10 because the grf |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
5795 |
* is not in memory and scanning the file every time would be too expensive. |
2f67415d44aa
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3557
diff
changeset
|
5796 |
* In other stages we skip action 0x10 since it's already dealt with. */ |
5008
c2b96042d529
(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
|
5797 |
static const SpecialSpriteHandler handlers[][GLS_END] = { |
7899
ff8ddda625b5
(svn r11450) -Fix [FS#1432](r8886): cargo translation table was loaded too early
glx
parents:
7892
diff
changeset
|
5798 |
/* 0x00 */ { NULL, SafeChangeInfo, NULL, NULL, ReserveChangeInfo, FeatureChangeInfo, }, |
6576
3a7cc737dec8
(svn r9790) -Codechange: [NewGRF] Skip action 1 sprites in all stages except activation. This also cleans up some special-case handling of the sprites. Actions 1 and 2 are now not considered unsafe, as an Action 3 (which is unsafe) is required for them.
peter1138
parents:
6570
diff
changeset
|
5799 |
/* 0x01 */ { SkipAct1, SkipAct1, SkipAct1, SkipAct1, SkipAct1, NewSpriteSet, }, |
3a7cc737dec8
(svn r9790) -Codechange: [NewGRF] Skip action 1 sprites in all stages except activation. This also cleans up some special-case handling of the sprites. Actions 1 and 2 are now not considered unsafe, as an Action 3 (which is unsafe) is required for them.
peter1138
parents:
6570
diff
changeset
|
5800 |
/* 0x02 */ { NULL, NULL, NULL, NULL, NULL, NewSpriteGroup, }, |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
5801 |
/* 0x03 */ { NULL, GRFUnsafe, NULL, NULL, NULL, FeatureMapSpriteGroup, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
5802 |
/* 0x04 */ { NULL, NULL, NULL, NULL, NULL, FeatureNewName, }, |
6529
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
5803 |
/* 0x05 */ { SkipAct5, SkipAct5, SkipAct5, SkipAct5, SkipAct5, GraphicsNew, }, |
6373
75654b0484cd
(svn r9436) -Fix (r9411): don't deactivate GRF in an action 7/9 during reservation (and loading of cargo data), and action 6 should be run also
peter1138
parents:
6365
diff
changeset
|
5804 |
/* 0x06 */ { NULL, NULL, NULL, CfgApply, CfgApply, CfgApply, }, |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
5805 |
/* 0x07 */ { NULL, NULL, NULL, NULL, SkipIf, SkipIf, }, |
6806
c0faecfdc59f
(svn r10045) -Codechange: Process Action 8 during GLS_RESERVATION to allow Action 7/Action 9s to work properly
peter1138
parents:
6805
diff
changeset
|
5806 |
/* 0x08 */ { ScanInfo, NULL, NULL, GRFInfo, GRFInfo, GRFInfo, }, |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
5807 |
/* 0x09 */ { NULL, NULL, NULL, SkipIf, SkipIf, SkipIf, }, |
6529
c572290f0cb9
(svn r9717) -Codechange: (NewGRF) Skip Action 5 & A sprites in all loading stages except activation.
peter1138
parents:
6515
diff
changeset
|
5808 |
/* 0x0A */ { SkipActA, SkipActA, SkipActA, SkipActA, SkipActA, SpriteReplace, }, |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
5809 |
/* 0x0B */ { NULL, NULL, NULL, GRFLoadError, GRFLoadError, GRFLoadError, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
5810 |
/* 0x0C */ { NULL, NULL, NULL, GRFComment, NULL, GRFComment, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
5811 |
/* 0x0D */ { NULL, SafeParamSet, NULL, ParamSet, ParamSet, ParamSet, }, |
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
5812 |
/* 0x0E */ { NULL, SafeGRFInhibit, NULL, GRFInhibit, GRFInhibit, GRFInhibit, }, |
6956
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
5813 |
/* 0x0F */ { NULL, GRFUnsafe, NULL, FeatureTownName, NULL, NULL, }, |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
5814 |
/* 0x10 */ { NULL, NULL, DefineGotoLabel, NULL, NULL, NULL, }, |
8431
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5815 |
/* 0x11 */ { SkipAct11,GRFUnsafe, SkipAct11, SkipAct11, SkipAct11, GRFSound, }, |
3efd3b25763d
(svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites.
frosch
parents:
8403
diff
changeset
|
5816 |
/* 0x12 */ { SkipAct12, SkipAct12, SkipAct12, SkipAct12, SkipAct12, LoadFontGlyph, }, |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
5817 |
/* 0x13 */ { NULL, NULL, NULL, NULL, NULL, TranslateGRFStrings, }, |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5818 |
}; |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5819 |
|
9947
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
5820 |
bool preloaded_sprite = true; |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
5821 |
GRFLocation location(_cur_grfconfig->grfid, _nfo_line); |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
5822 |
byte *buf; |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
5823 |
|
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
5824 |
GRFLineToSpriteOverride::iterator it = _grf_line_to_action6_sprite_override.find(location); |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
5825 |
if (it == _grf_line_to_action6_sprite_override.end()) { |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5826 |
/* No preloaded sprite to work with; allocate and read the |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5827 |
* pseudo sprite content. */ |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5593
diff
changeset
|
5828 |
buf = MallocT<byte>(num); |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5829 |
FioReadBlock(buf, num); |
9947
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
5830 |
preloaded_sprite = false; |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5831 |
} else { |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5832 |
/* Use the preloaded sprite data. */ |
9947
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
5833 |
buf = _grf_line_to_action6_sprite_override[location]; |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5379
diff
changeset
|
5834 |
grfmsg(7, "DecodeSpecialSprite: Using preloaded pseudo sprite data"); |
3895
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5835 |
|
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5836 |
/* Skip the real (original) content of this action. */ |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5837 |
FioSeekTo(num, SEEK_CUR); |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5838 |
} |
ebe5f95d8917
(svn r4965) - NewGRF: add support for action 0x06 (modify sprite data) for pseudo sprites
peter1138
parents:
3879
diff
changeset
|
5839 |
|
6281 | 5840 |
byte action = buf[0]; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5841 |
|
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5842 |
if (action == 0xFF) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
5843 |
grfmsg(7, "DecodeSpecialSprite: Handling data block in stage %d", stage); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5844 |
GRFDataBlock(buf, num); |
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
5845 |
} else if (action == 0xFE) { |
7899
ff8ddda625b5
(svn r11450) -Fix [FS#1432](r8886): cargo translation table was loaded too early
glx
parents:
7892
diff
changeset
|
5846 |
grfmsg(7, "DecodeSpecialSprite: Handling import block in stage %d", stage); |
4818
6caf76622964
(svn r6742) - Newsounds: Add support for importing sounds from previously loaded GRF files.
peter1138
parents:
4817
diff
changeset
|
5847 |
GRFImportBlock(buf, num); |
4656
9c1d8c4d3e60
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4625
diff
changeset
|
5848 |
} else if (action >= lengthof(handlers)) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
5849 |
grfmsg(7, "DecodeSpecialSprite: Skipping unknown action 0x%02X", action); |
5008
c2b96042d529
(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
|
5850 |
} else if (handlers[action][stage] == NULL) { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
5851 |
grfmsg(7, "DecodeSpecialSprite: Skipping action 0x%02X in stage %d", action, stage); |
2645
841087328e0e
(svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents:
2628
diff
changeset
|
5852 |
} else { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
5853 |
grfmsg(7, "DecodeSpecialSprite: Handling action 0x%02X in stage %d", action, stage); |
5008
c2b96042d529
(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
|
5854 |
handlers[action][stage](buf, num); |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5855 |
} |
9947
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
5856 |
if (!preloaded_sprite) free(buf); |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5857 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5858 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5859 |
|
8194
46b8e23a8f44
(svn r11757) -Fix(r11727): Don't use a function's default parameter when the value can be (more adequately, even better) computed from another source.
belugas
parents:
8185
diff
changeset
|
5860 |
void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage) |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5861 |
{ |
7034
e2d80a01d9c1
(svn r10298) -Fix [FS#903]: show the subdirectory below the default data directory in this filename in the newgrf list. The directory was removed in r9560 because then it used to full path instead of the path relative to the data directory, but since the inclusion of "search paths" that is not necessary anymore.
rubidium
parents:
6956
diff
changeset
|
5862 |
const char *filename = config->filename; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5863 |
uint16 num; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5864 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5865 |
/* A .grf file is activated only if it was active when the game was |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5866 |
* started. If a game is loaded, only its active .grfs will be |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5867 |
* reactivated, unless "loadallgraphics on" is used. A .grf file is |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5868 |
* considered active if its action 8 has been processed, i.e. its |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5869 |
* action 8 hasn't been skipped using an action 7. |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5870 |
* |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5871 |
* During activation, only actions 0, 1, 2, 3, 4, 5, 7, 8, 9, 0A and 0B are |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5872 |
* carried out. All others are ignored, because they only need to be |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5873 |
* processed once at initialization. */ |
5329
9c5e8061ea0f
(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
|
5874 |
if (stage != GLS_FILESCAN && stage != GLS_SAFETYSCAN && stage != GLS_LABELSCAN) { |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5875 |
_cur_grffile = GetFileByFilename(filename); |
9470
08424e2e79e4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx
parents:
9468
diff
changeset
|
5876 |
if (_cur_grffile == NULL) usererror("File '%s' lost in cache.\n", filename); |
6806
c0faecfdc59f
(svn r10045) -Codechange: Process Action 8 during GLS_RESERVATION to allow Action 7/Action 9s to work properly
peter1138
parents:
6805
diff
changeset
|
5877 |
if (stage == GLS_RESERVE && config->status != GCS_INITIALISED) return; |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
5878 |
if (stage == GLS_ACTIVATION && !HasBit(config->flags, GCF_RESERVED)) return; |
8194
46b8e23a8f44
(svn r11757) -Fix(r11727): Don't use a function's default parameter when the value can be (more adequately, even better) computed from another source.
belugas
parents:
8185
diff
changeset
|
5879 |
_cur_grffile->is_ottdfile = config->IsOpenTTDBaseGRF(); |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5880 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5881 |
|
7805
7ab20f94cc80
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents:
7796
diff
changeset
|
5882 |
if (file_index > LAST_GRF_SLOT) { |
7ab20f94cc80
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents:
7796
diff
changeset
|
5883 |
DEBUG(grf, 0, "'%s' is not loaded as the maximum number of GRFs has been reached", filename); |
7ab20f94cc80
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents:
7796
diff
changeset
|
5884 |
config->status = GCS_DISABLED; |
7ab20f94cc80
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents:
7796
diff
changeset
|
5885 |
config->error = CallocT<GRFError>(1); |
7ab20f94cc80
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents:
7796
diff
changeset
|
5886 |
config->error->severity = STR_NEWGRF_ERROR_MSG_FATAL; |
7ab20f94cc80
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents:
7796
diff
changeset
|
5887 |
config->error->message = STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED; |
7ab20f94cc80
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents:
7796
diff
changeset
|
5888 |
return; |
7ab20f94cc80
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents:
7796
diff
changeset
|
5889 |
} |
7ab20f94cc80
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents:
7796
diff
changeset
|
5890 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5891 |
FioOpenFile(file_index, filename); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5892 |
_file_index = file_index; // XXX |
10066
f18e97752eeb
(svn r14233) -Feature/Fix [FS#2172]: save the palette of the loaded NewGRFs in the savegame, so joining with a server using Windows palette will make a client with the DOS palette do palette conversion and (thus) not cause a desync due to the different palettes disabling different NewGRFs.
rubidium
parents:
10063
diff
changeset
|
5893 |
_palette_remap_grf[_file_index] = (config->windows_paletted != (_use_palette == PAL_WINDOWS)); |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5894 |
|
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
5895 |
_cur_grfconfig = config; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
5896 |
|
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
5897 |
DEBUG(grf, 2, "LoadNewGRFFile: Reading NewGRF-file '%s'", filename); |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5898 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5899 |
/* Skip the first sprite; we don't care about how many sprites this |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5900 |
* does contain; newest TTDPatches and George's longvehicles don't |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5901 |
* neither, apparently. */ |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5902 |
if (FioReadWord() == 4 && FioReadByte() == 0xFF) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5903 |
FioReadDword(); |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5904 |
} else { |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
5905 |
DEBUG(grf, 7, "LoadNewGRFFile: Custom .grf has invalid format"); |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
5906 |
return; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5907 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5908 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5909 |
_skip_sprites = 0; // XXX |
3557
1e9867319bce
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
5910 |
_nfo_line = 0; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5911 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5912 |
while ((num = FioReadWord()) != 0) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5913 |
byte type = FioReadByte(); |
3557
1e9867319bce
(svn r4431) - NewGRF: rename nfo_line to _nfo_line, to avoid confusing Darkvater ;)
peter1138
parents:
3555
diff
changeset
|
5914 |
_nfo_line++; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5915 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5916 |
if (type == 0xFF) { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5917 |
if (_skip_sprites == 0) { |
2958
ac0a9673b522
(svn r3520) Remove unused parameters from some functions
tron
parents:
2935
diff
changeset
|
5918 |
DecodeSpecialSprite(num, stage); |
5011
0b0003ba213e
(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
|
5919 |
|
0b0003ba213e
(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
|
5920 |
/* Stop all processing if we are to skip the remaining sprites */ |
0b0003ba213e
(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
|
5921 |
if (_skip_sprites == -1) break; |
0b0003ba213e
(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
|
5922 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5923 |
continue; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5924 |
} else { |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5925 |
FioSkipBytes(num); |
1611 | 5926 |
} |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5927 |
} else { |
10025
4aef0b1dd009
(svn r14184) -Codechange: [NewGRF] Since our NewGRF handling is better than it used to be, disable a NewGRF if unexpected sprites are reached.
peter1138
parents:
10023
diff
changeset
|
5928 |
if (_skip_sprites == 0) { |
4aef0b1dd009
(svn r14184) -Codechange: [NewGRF] Since our NewGRF handling is better than it used to be, disable a NewGRF if unexpected sprites are reached.
peter1138
parents:
10023
diff
changeset
|
5929 |
grfmsg(0, "LoadNewGRFFile: Unexpected sprite, disabling"); |
4aef0b1dd009
(svn r14184) -Codechange: [NewGRF] Since our NewGRF handling is better than it used to be, disable a NewGRF if unexpected sprites are reached.
peter1138
parents:
10023
diff
changeset
|
5930 |
config->status = GCS_DISABLED; |
4aef0b1dd009
(svn r14184) -Codechange: [NewGRF] Since our NewGRF handling is better than it used to be, disable a NewGRF if unexpected sprites are reached.
peter1138
parents:
10023
diff
changeset
|
5931 |
config->error = CallocT<GRFError>(1); |
4aef0b1dd009
(svn r14184) -Codechange: [NewGRF] Since our NewGRF handling is better than it used to be, disable a NewGRF if unexpected sprites are reached.
peter1138
parents:
10023
diff
changeset
|
5932 |
config->error->severity = STR_NEWGRF_ERROR_MSG_FATAL; |
4aef0b1dd009
(svn r14184) -Codechange: [NewGRF] Since our NewGRF handling is better than it used to be, disable a NewGRF if unexpected sprites are reached.
peter1138
parents:
10023
diff
changeset
|
5933 |
config->error->message = STR_NEWGRF_ERROR_UNEXPECTED_SPRITE; |
4aef0b1dd009
(svn r14184) -Codechange: [NewGRF] Since our NewGRF handling is better than it used to be, disable a NewGRF if unexpected sprites are reached.
peter1138
parents:
10023
diff
changeset
|
5934 |
break; |
4aef0b1dd009
(svn r14184) -Codechange: [NewGRF] Since our NewGRF handling is better than it used to be, disable a NewGRF if unexpected sprites are reached.
peter1138
parents:
10023
diff
changeset
|
5935 |
} |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5936 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5937 |
FioSkipBytes(7); |
10032
1f6c6f3bea28
(svn r14191) -Codechange: unify the code to skip sprite payload (i.e. not the header).
rubidium
parents:
10030
diff
changeset
|
5938 |
SkipSpriteData(type, num - 8); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
5939 |
} |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5940 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5941 |
if (_skip_sprites > 0) _skip_sprites--; |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5942 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5943 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5944 |
|
8403
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5945 |
/** |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5946 |
* Relocates the old shore sprites at new positions. |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5947 |
* |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5948 |
* 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) |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5949 |
* 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) |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5950 |
* 3. If a newgrf replaces shore sprites by Action5 any shore replacement by ActionA has no effect. (SHORE_REPLACE_ACTION_5) |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5951 |
*/ |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5952 |
static void ActivateOldShore() |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5953 |
{ |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5954 |
/* Use default graphics, if no shore sprites were loaded. |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5955 |
* Should not happen, as openttd(w/d).grf includes some. */ |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5956 |
if (_loaded_newgrf_features.shore == SHORE_REPLACE_NONE) _loaded_newgrf_features.shore = SHORE_REPLACE_ACTION_A; |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5957 |
|
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5958 |
if (_loaded_newgrf_features.shore != SHORE_REPLACE_ACTION_5) { |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5959 |
DupSprite(SPR_ORIGINALSHORE_START + 1, SPR_SHORE_BASE + 1); // SLOPE_W |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5960 |
DupSprite(SPR_ORIGINALSHORE_START + 2, SPR_SHORE_BASE + 2); // SLOPE_S |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5961 |
DupSprite(SPR_ORIGINALSHORE_START + 6, SPR_SHORE_BASE + 3); // SLOPE_SW |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5962 |
DupSprite(SPR_ORIGINALSHORE_START , SPR_SHORE_BASE + 4); // SLOPE_E |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5963 |
DupSprite(SPR_ORIGINALSHORE_START + 4, SPR_SHORE_BASE + 6); // SLOPE_SE |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5964 |
DupSprite(SPR_ORIGINALSHORE_START + 3, SPR_SHORE_BASE + 8); // SLOPE_N |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5965 |
DupSprite(SPR_ORIGINALSHORE_START + 7, SPR_SHORE_BASE + 9); // SLOPE_NW |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5966 |
DupSprite(SPR_ORIGINALSHORE_START + 5, SPR_SHORE_BASE + 12); // SLOPE_NE |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5967 |
} |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5968 |
|
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5969 |
if (_loaded_newgrf_features.shore == SHORE_REPLACE_ACTION_A) { |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5970 |
DupSprite(SPR_FLAT_GRASS_TILE + 16, SPR_SHORE_BASE + 0); // SLOPE_STEEP_S |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5971 |
DupSprite(SPR_FLAT_GRASS_TILE + 17, SPR_SHORE_BASE + 5); // SLOPE_STEEP_W |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5972 |
DupSprite(SPR_FLAT_GRASS_TILE + 7, SPR_SHORE_BASE + 7); // SLOPE_WSE |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5973 |
DupSprite(SPR_FLAT_GRASS_TILE + 15, SPR_SHORE_BASE + 10); // SLOPE_STEEP_N |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5974 |
DupSprite(SPR_FLAT_GRASS_TILE + 11, SPR_SHORE_BASE + 11); // SLOPE_NWS |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5975 |
DupSprite(SPR_FLAT_GRASS_TILE + 13, SPR_SHORE_BASE + 13); // SLOPE_ENW |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5976 |
DupSprite(SPR_FLAT_GRASS_TILE + 14, SPR_SHORE_BASE + 14); // SLOPE_SEN |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5977 |
DupSprite(SPR_FLAT_GRASS_TILE + 18, SPR_SHORE_BASE + 15); // SLOPE_STEEP_E |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5978 |
|
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5979 |
/* XXX - SLOPE_EW, SLOPE_NS are currently not used. |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5980 |
* If they would be used somewhen, then these grass tiles will most like not look as needed */ |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5981 |
DupSprite(SPR_FLAT_GRASS_TILE + 5, SPR_SHORE_BASE + 16); // SLOPE_EW |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5982 |
DupSprite(SPR_FLAT_GRASS_TILE + 10, SPR_SHORE_BASE + 17); // SLOPE_NS |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5983 |
} |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5984 |
} |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
5985 |
|
6247 | 5986 |
void InitDepotWindowBlockSizes(); |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
5987 |
|
8323
d5531c7645a7
(svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents:
8298
diff
changeset
|
5988 |
extern void InitGRFTownGeneratorNames(); |
6956
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
5989 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5990 |
static void AfterLoadGRFs() |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
5991 |
{ |
8959
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
5992 |
for (StringIDToGRFIDMapping::iterator it = _string_to_grf_mapping.begin(); it != _string_to_grf_mapping.end(); it++) { |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
5993 |
*((*it).first) = MapGRFStringID((*it).second, *((*it).first)); |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
5994 |
} |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
5995 |
_string_to_grf_mapping.clear(); |
636d242edd89
(svn r12751) -Codechange: do what has been done in r11862 in a different way so it uses less memory.
rubidium
parents:
8881
diff
changeset
|
5996 |
|
9947
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
5997 |
/* Free the action 6 override sprites. */ |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
5998 |
for (GRFLineToSpriteOverride::iterator it = _grf_line_to_action6_sprite_override.begin(); it != _grf_line_to_action6_sprite_override.end(); it++) { |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
5999 |
free((*it).second); |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
6000 |
} |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
6001 |
_grf_line_to_action6_sprite_override.clear(); |
7d0c7f02e64f
(svn r14102) -Fix [FS#1986]: make NewGRF action 0x06's changes persistent over the several loading stages.
rubidium
parents:
9923
diff
changeset
|
6002 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
6003 |
/* Pre-calculate all refit masks after loading GRF files. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
6004 |
CalculateRefitMasks(); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
6005 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
6006 |
/* Set the block size in the depot windows based on vehicle sprite sizes */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
6007 |
InitDepotWindowBlockSizes(); |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
6008 |
|
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
6009 |
/* Add all new houses to the house array. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
6010 |
FinaliseHouseArray(); |
6359
8527262c4cf8
(svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents:
6357
diff
changeset
|
6011 |
|
7183
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
6012 |
/* Add all new industries to the industry array. */ |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
6013 |
FinaliseIndustriesArray(); |
a7182cc3a8ea
(svn r10457) -Codechange: Load the newly read definitions of Industries and Industry tiles.
belugas
parents:
7182
diff
changeset
|
6014 |
|
6533
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6529
diff
changeset
|
6015 |
/* Create dynamic list of industry legends for smallmap_gui.cpp */ |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6529
diff
changeset
|
6016 |
BuildIndustriesLegend(); |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6529
diff
changeset
|
6017 |
|
6956
3579bfc5157b
(svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents:
6927
diff
changeset
|
6018 |
/* Update the townname generators list */ |
8323
d5531c7645a7
(svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents:
8298
diff
changeset
|
6019 |
InitGRFTownGeneratorNames(); |
8403
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
6020 |
|
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
6021 |
/* Run all queued vehicle list order changes */ |
9672
02fe9b0dc41b
(svn r13761) -Codechange: Remove dependency on rail for altering purchase list position (mostly function renaming)
peter1138
parents:
9619
diff
changeset
|
6022 |
CommitVehicleListOrderChanges(); |
9070
dd0121143eba
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
9025
diff
changeset
|
6023 |
|
8403
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
6024 |
/* Load old shore sprites in new position, if they were replaced by ActionA */ |
44f101c68312
(svn r11973) -Fix (r11726, r11947)[FS#1683]: Use grass tiles for corner shores, if shores got replaced by ActionA.
frosch
parents:
8393
diff
changeset
|
6025 |
ActivateOldShore(); |
9025
be4668a781b8
(svn r12839) -Codechange: Allocate temporary engine data when loading GRFs as needed instead of statically.
peter1138
parents:
9003
diff
changeset
|
6026 |
|
be4668a781b8
(svn r12839) -Codechange: Allocate temporary engine data when loading GRFs as needed instead of statically.
peter1138
parents:
9003
diff
changeset
|
6027 |
/* Deallocate temporary loading data */ |
be4668a781b8
(svn r12839) -Codechange: Allocate temporary engine data when loading GRFs as needed instead of statically.
peter1138
parents:
9003
diff
changeset
|
6028 |
free(_gted); |
9098
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
6029 |
_grm_sprites.clear(); |
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
6030 |
} |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
6031 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
6032 |
void LoadNewGRF(uint load_index, uint file_index) |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
6033 |
{ |
2930
99088d4aba31
(svn r3486) - NewGRF fix: Always reinitialize the ttdpatch flags as patch settings may have changed.
peter1138
parents:
2895
diff
changeset
|
6034 |
InitializeGRFSpecial(); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
6035 |
|
2463
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
6036 |
ResetNewGRFData(); |
db029c987bc7
(svn r2989) - Make engine/vehicle information tables constant. Duplicate them so NewGRF data can be loaded without wiping out the default data.
peter1138
parents:
2458
diff
changeset
|
6037 |
|
8159
0c9c45471c99
(svn r11721) -Fix: do not disable NewGRFs for 'eternity' during games.
rubidium
parents:
8158
diff
changeset
|
6038 |
/* |
0c9c45471c99
(svn r11721) -Fix: do not disable NewGRFs for 'eternity' during games.
rubidium
parents:
8158
diff
changeset
|
6039 |
* Reset the status of all files, so we can 'retry' to load them. |
0c9c45471c99
(svn r11721) -Fix: do not disable NewGRFs for 'eternity' during games.
rubidium
parents:
8158
diff
changeset
|
6040 |
* This is needed when one for example rearranges the NewGRFs in-game |
0c9c45471c99
(svn r11721) -Fix: do not disable NewGRFs for 'eternity' during games.
rubidium
parents:
8158
diff
changeset
|
6041 |
* and a previously disabled NewGRF becomes useable. If it would not |
0c9c45471c99
(svn r11721) -Fix: do not disable NewGRFs for 'eternity' during games.
rubidium
parents:
8158
diff
changeset
|
6042 |
* be reset, the NewGRF would remain disabled even though it should |
0c9c45471c99
(svn r11721) -Fix: do not disable NewGRFs for 'eternity' during games.
rubidium
parents:
8158
diff
changeset
|
6043 |
* have been enabled. |
0c9c45471c99
(svn r11721) -Fix: do not disable NewGRFs for 'eternity' during games.
rubidium
parents:
8158
diff
changeset
|
6044 |
*/ |
0c9c45471c99
(svn r11721) -Fix: do not disable NewGRFs for 'eternity' during games.
rubidium
parents:
8158
diff
changeset
|
6045 |
for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) { |
0c9c45471c99
(svn r11721) -Fix: do not disable NewGRFs for 'eternity' during games.
rubidium
parents:
8158
diff
changeset
|
6046 |
if (c->status != GCS_NOT_FOUND) c->status = GCS_UNKNOWN; |
0c9c45471c99
(svn r11721) -Fix: do not disable NewGRFs for 'eternity' during games.
rubidium
parents:
8158
diff
changeset
|
6047 |
} |
0c9c45471c99
(svn r11721) -Fix: do not disable NewGRFs for 'eternity' during games.
rubidium
parents:
8158
diff
changeset
|
6048 |
|
9098
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
6049 |
_cur_spriteid = load_index; |
4bfb936de6a6
(svn r12958) -Codechange: Allocate sprites reserved by GRM in advance of 'Action 1' sprites, giving much less chance of GRM reservation failure if lots of NewGRF sets are loaded.
peter1138
parents:
9091
diff
changeset
|
6050 |
|
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
6051 |
/* Load newgrf sprites |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
6052 |
* in each loading stage, (try to) open each file specified in the config |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
6053 |
* and load information from it. */ |
7830
146cbcd4c29e
(svn r11380) -Revert (r11191, r11196): it worked, but broke cargo loading
glx
parents:
7808
diff
changeset
|
6054 |
for (GrfLoadingStage stage = GLS_LABELSCAN; stage <= GLS_ACTIVATION; stage++) { |
8668
ec186f7909f2
(svn r12333) -Fix: Switch grfstatus from 'activated' back to 'will-be-active' between reservation- and activation-stage.
frosch
parents:
8656
diff
changeset
|
6055 |
/* Set activated grfs back to will-be-activated between reservation- and activation-stage. |
ec186f7909f2
(svn r12333) -Fix: Switch grfstatus from 'activated' back to 'will-be-active' between reservation- and activation-stage.
frosch
parents:
8656
diff
changeset
|
6056 |
* This ensures that action7/9 conditions 0x06 - 0x0A work correctly. */ |
ec186f7909f2
(svn r12333) -Fix: Switch grfstatus from 'activated' back to 'will-be-active' between reservation- and activation-stage.
frosch
parents:
8656
diff
changeset
|
6057 |
for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) { |
ec186f7909f2
(svn r12333) -Fix: Switch grfstatus from 'activated' back to 'will-be-active' between reservation- and activation-stage.
frosch
parents:
8656
diff
changeset
|
6058 |
if (c->status == GCS_ACTIVATED) c->status = GCS_INITIALISED; |
ec186f7909f2
(svn r12333) -Fix: Switch grfstatus from 'activated' back to 'will-be-active' between reservation- and activation-stage.
frosch
parents:
8656
diff
changeset
|
6059 |
} |
ec186f7909f2
(svn r12333) -Fix: Switch grfstatus from 'activated' back to 'will-be-active' between reservation- and activation-stage.
frosch
parents:
8656
diff
changeset
|
6060 |
|
2400
2b258097156f
(svn r2926) -Fix: Use the same file slots in both initialisation stages when loading a patch grf
tron
parents:
2346
diff
changeset
|
6061 |
uint slot = file_index; |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
6062 |
|
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
6063 |
_cur_stage = stage; |
6281 | 6064 |
for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) { |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6193
diff
changeset
|
6065 |
if (c->status == GCS_DISABLED || c->status == GCS_NOT_FOUND) continue; |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
6066 |
if (stage > GLS_INIT && HasBit(c->flags, GCF_INIT_ONLY)) continue; |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
6067 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6343
diff
changeset
|
6068 |
/* @todo usererror() */ |
9470
08424e2e79e4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx
parents:
9468
diff
changeset
|
6069 |
if (!FioCheckFileExists(c->filename)) usererror("NewGRF file is missing '%s'", c->filename); |
3628
69646d0924a5
(svn r4527) - Feature [NewGRF]: Add support for specifying parameters to GRF files. Usage: "mygrf = 1". You can pass up to 128 parameters, each one seperated by a comma or a space-character. Big thanks to peter1138 for the inspiration and examples.
Darkvater
parents:
3620
diff
changeset
|
6070 |
|
5008
c2b96042d529
(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
|
6071 |
if (stage == GLS_LABELSCAN) InitNewGRFFile(c, _cur_spriteid); |
8194
46b8e23a8f44
(svn r11757) -Fix(r11727): Don't use a function's default parameter when the value can be (more adequately, even better) computed from another source.
belugas
parents:
8185
diff
changeset
|
6072 |
LoadNewGRFFile(c, slot++, stage); |
6820
1b9283c26656
(svn r10059) -Fix (r10045): Pretend GRF is still in initialisation state when leaving reservation stage. This fixes action 7/9 tests for grfs that will be active.
peter1138
parents:
6813
diff
changeset
|
6073 |
if (stage == GLS_RESERVE) { |
7931
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7929
diff
changeset
|
6074 |
SetBit(c->flags, GCF_RESERVED); |
7830
146cbcd4c29e
(svn r11380) -Revert (r11191, r11196): it worked, but broke cargo loading
glx
parents:
7808
diff
changeset
|
6075 |
} else if (stage == GLS_ACTIVATION) { |
7929
6c9b25842b0f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
7928
diff
changeset
|
6076 |
ClrBit(c->flags, GCF_RESERVED); |
5476
fa6583f537ce
(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:
5475
diff
changeset
|
6077 |
ClearTemporaryNewGRFData(); |
6147
ee050ca3889f
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6145
diff
changeset
|
6078 |
BuildCargoTranslationMap(); |
6477
573b27af65be
(svn r9653) -Codechange: Indicate the proper function names in the GRF messages
belugas
parents:
6470
diff
changeset
|
6079 |
DEBUG(sprite, 2, "LoadNewGRF: Currently %i sprites are loaded", _cur_spriteid); |
5476
fa6583f537ce
(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:
5475
diff
changeset
|
6080 |
} |
2342
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
6081 |
} |
aae24c9661ba
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
6082 |
} |
2611
36aa372eeb34
(svn r3148) -NewGRF, Feature: Add support for cargo refitting specification by cargo classes.
peter1138
parents:
2582
diff
changeset
|
6083 |
|
6332
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
6084 |
/* Call any functions that should be run after GRFs have been loaded. */ |
f3f436dcd7d0
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6288
diff
changeset
|
6085 |
AfterLoadGRFs(); |
452
14dfdf98b719
(svn r662) [newgrf] Moved grfspecial.c to newgrf.c/newgrf.h
dominik
parents:
diff
changeset
|
6086 |
} |
6541
dfa5165a5ab7
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros
parents:
6533
diff
changeset
|
6087 |
|
dfa5165a5ab7
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros
parents:
6533
diff
changeset
|
6088 |
bool HasGrfMiscBit(GrfMiscBit bit) |
dfa5165a5ab7
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros
parents:
6533
diff
changeset
|
6089 |
{ |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7922
diff
changeset
|
6090 |
return HasBit(_misc_grf_features, bit); |
6541
dfa5165a5ab7
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros
parents:
6533
diff
changeset
|
6091 |
} |