author | truebrain |
Fri, 13 Jun 2008 19:12:55 +0000 | |
branch | noai |
changeset 10956 | 82aa600a9922 |
parent 10776 | 07203fc29812 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
9837
diff
changeset
|
3 |
/** @file newgrf.h Base for the NewGRF implementation. */ |
9505 | 4 |
|
455 | 5 |
#ifndef NEWGRF_H |
6 |
#define NEWGRF_H |
|
7 |
||
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
8 |
#include "town_type.h" |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
9 |
#include "newgrf_config.h" |
6469
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
5838
diff
changeset
|
10 |
#include "cargotype.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
11 |
#include "industry_type.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
12 |
#include "station_type.h" |
463
91bcad840bcd
(svn r687) Export InitNewGRFFile() and DecodeSpecialSprite() properly.
pasky
parents:
455
diff
changeset
|
13 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
14 |
enum GrfLoadingStage { |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
15 |
GLS_FILESCAN, |
5329
2b117d8652f0
(svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents:
5234
diff
changeset
|
16 |
GLS_SAFETYSCAN, |
5225
52ddcedcc6f7
(svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents:
5210
diff
changeset
|
17 |
GLS_LABELSCAN, |
52ddcedcc6f7
(svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents:
5210
diff
changeset
|
18 |
GLS_INIT, |
9517 | 19 |
GLS_RESERVE, |
5225
52ddcedcc6f7
(svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents:
5210
diff
changeset
|
20 |
GLS_ACTIVATION, |
52ddcedcc6f7
(svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents:
5210
diff
changeset
|
21 |
GLS_END, |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
22 |
}; |
5225
52ddcedcc6f7
(svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents:
5210
diff
changeset
|
23 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
24 |
DECLARE_POSTFIX_INCREMENT(GrfLoadingStage); |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
25 |
|
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9517
diff
changeset
|
26 |
enum GrfMiscBit { |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9517
diff
changeset
|
27 |
GMB_DESERT_TREES_FIELDS = 0, // Unsupported. |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9517
diff
changeset
|
28 |
GMB_DESERT_PAVED_ROADS = 1, |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9517
diff
changeset
|
29 |
GMB_FIELD_BOUNDING_BOX = 2, // Unsupported. |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9517
diff
changeset
|
30 |
GMB_TRAIN_WIDTH_32_PIXELS = 3, |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9517
diff
changeset
|
31 |
GMB_AMBIENT_SOUND_CALLBACK = 4, // Unsupported. |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9517
diff
changeset
|
32 |
GMB_CATENARY_ON_3RD_TRACK = 5, // Unsupported. |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9517
diff
changeset
|
33 |
}; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
34 |
|
9732 | 35 |
enum GrfSpecFeature { |
36 |
GSF_TRAIN, |
|
37 |
GSF_ROAD, |
|
38 |
GSF_SHIP, |
|
39 |
GSF_AIRCRAFT, |
|
40 |
GSF_STATION, |
|
41 |
GSF_CANAL, |
|
42 |
GSF_BRIDGE, |
|
43 |
GSF_TOWNHOUSE, |
|
44 |
GSF_GLOBALVAR, |
|
45 |
GSF_INDUSTRYTILES, |
|
46 |
GSF_INDUSTRIES, |
|
47 |
GSF_CARGOS, |
|
48 |
GSF_SOUNDFX, |
|
49 |
GSF_END, |
|
50 |
}; |
|
51 |
||
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
52 |
struct GRFLabel { |
3561
29c95ab685c0
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3501
diff
changeset
|
53 |
byte label; |
29c95ab685c0
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3501
diff
changeset
|
54 |
uint32 nfo_line; |
10776 | 55 |
size_t pos; |
3561
29c95ab685c0
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3501
diff
changeset
|
56 |
struct GRFLabel *next; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
57 |
}; |
3561
29c95ab685c0
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3501
diff
changeset
|
58 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
59 |
struct GRFFile { |
455 | 60 |
char *filename; |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
61 |
bool is_ottdfile; |
455 | 62 |
uint32 grfid; |
63 |
uint16 sprite_offset; |
|
3640
b73687dd2b62
(svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents:
3638
diff
changeset
|
64 |
byte grf_version; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
65 |
GRFFile *next; |
455 | 66 |
|
67 |
/* A sprite group contains all sprites of a given vehicle (or multiple |
|
68 |
* vehicles) when carrying given cargo. It consists of several sprite |
|
69 |
* sets. Group ids are refered as "cargo id"s by TTDPatch |
|
70 |
* documentation, contributing to the global confusion. |
|
71 |
* |
|
72 |
* A sprite set contains all sprites of a given vehicle carrying given |
|
73 |
* cargo at a given *stage* - that is usually its load stage. Ie. you |
|
74 |
* can have a spriteset for an empty wagon, wagon full of coal, |
|
75 |
* half-filled wagon etc. Each spriteset contains eight sprites (one |
|
76 |
* per direction) or four sprites if the vehicle is symmetric. */ |
|
77 |
||
3707
2999a89e8abd
(svn r4650) - NewGRF: use the correct type for _cur_spriteid
peter1138
parents:
3640
diff
changeset
|
78 |
SpriteID spriteset_start; |
455 | 79 |
int spriteset_numsets; |
80 |
int spriteset_numents; |
|
81 |
int spriteset_feature; |
|
82 |
||
83 |
int spritegroups_count; |
|
3865
a0bf688e6f85
(svn r4901) - Codechange: change 'SpriteGroup *' to 'struct SpriteGroup *' within StationSpec and GRFFile struct declarations. Now only code which actually references those pointers needs to know about the SpriteGroup struct. Remove some unnecessary lingering header dependencies.
peter1138
parents:
3775
diff
changeset
|
84 |
struct SpriteGroup **spritegroups; |
455 | 85 |
|
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
3865
diff
changeset
|
86 |
uint sound_offset; |
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
3865
diff
changeset
|
87 |
|
3768
46d328178509
(svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents:
3707
diff
changeset
|
88 |
StationSpec **stations; |
9476 | 89 |
HouseSpec **housespec; |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
90 |
IndustrySpec **industryspec; |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
91 |
IndustryTileSpec **indtspec; |
2345 | 92 |
|
93 |
uint32 param[0x80]; |
|
9505 | 94 |
uint param_end; ///< one more than the highest set parameter |
3561
29c95ab685c0
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3501
diff
changeset
|
95 |
|
29c95ab685c0
(svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents:
3501
diff
changeset
|
96 |
GRFLabel *label; ///< Pointer to the first label. This is a linked list, not an array. |
6469
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
5838
diff
changeset
|
97 |
|
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
5838
diff
changeset
|
98 |
uint8 cargo_max; |
05a2e97144ec
(svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents:
5838
diff
changeset
|
99 |
CargoLabel *cargo_list; |
6473
03480a0f016e
(svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents:
6469
diff
changeset
|
100 |
uint8 cargo_map[NUM_CARGO]; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
101 |
}; |
455 | 102 |
|
1477 | 103 |
extern GRFFile *_first_grffile; |
455 | 104 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
105 |
enum ShoreReplacement { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
106 |
SHORE_REPLACE_NONE, ///< No shore sprites were replaced. |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
107 |
SHORE_REPLACE_ACTION_5, ///< Shore sprites were replaced by Action5. |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
108 |
SHORE_REPLACE_ACTION_A, ///< Shore sprites were replaced by ActionA (using grass tiles for the corner-shores). |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
109 |
SHORE_REPLACE_ONLY_NEW, ///< Only corner-shores were loaded by Action5 (openttd(w/d).grf only). |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
110 |
}; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
111 |
|
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9625
diff
changeset
|
112 |
struct GRFLoadedFeatures { |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9625
diff
changeset
|
113 |
bool has_2CC; ///< Set if any vehicle is loaded which uses 2cc (two company colours). |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9625
diff
changeset
|
114 |
bool has_newhouses; ///< Set if there are any newhouses loaded. |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9625
diff
changeset
|
115 |
bool has_newindustries; ///< Set if there are any newindustries loaded. |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
116 |
ShoreReplacement shore; ///< It which way shore sprites were replaced. |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
117 |
}; |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
118 |
|
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9620
diff
changeset
|
119 |
/* Indicates which are the newgrf features currently loaded ingame */ |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9625
diff
changeset
|
120 |
extern GRFLoadedFeatures _loaded_newgrf_features; |
463
91bcad840bcd
(svn r687) Export InitNewGRFFile() and DecodeSpecialSprite() properly.
pasky
parents:
455
diff
changeset
|
121 |
|
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5225
diff
changeset
|
122 |
void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage); |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2186
diff
changeset
|
123 |
void LoadNewGRF(uint load_index, uint file_index); |
9505 | 124 |
void ReloadNewGRFData(); // in openttd.cpp |
455 | 125 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5352
diff
changeset
|
126 |
void CDECL grfmsg(int severity, const char *str, ...); |
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5352
diff
changeset
|
127 |
|
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9517
diff
changeset
|
128 |
bool HasGrfMiscBit(GrfMiscBit bit); |
9732 | 129 |
bool GetGlobalVariable(byte param, uint32 *value); |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9517
diff
changeset
|
130 |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
131 |
StringID MapGRFStringID(uint32 grfid, StringID str); |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
132 |
|
455 | 133 |
#endif /* NEWGRF_H */ |