00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef NEWGRF_H
00013 #define NEWGRF_H
00014
00015 #include "cargotype.h"
00016 #include "rail_type.h"
00017
00018 enum GrfLoadingStage {
00019 GLS_FILESCAN,
00020 GLS_SAFETYSCAN,
00021 GLS_LABELSCAN,
00022 GLS_INIT,
00023 GLS_RESERVE,
00024 GLS_ACTIVATION,
00025 GLS_END,
00026 };
00027
00028 DECLARE_POSTFIX_INCREMENT(GrfLoadingStage)
00029
00030 enum GrfMiscBit {
00031 GMB_DESERT_TREES_FIELDS = 0,
00032 GMB_DESERT_PAVED_ROADS = 1,
00033 GMB_FIELD_BOUNDING_BOX = 2,
00034 GMB_TRAIN_WIDTH_32_PIXELS = 3,
00035 GMB_AMBIENT_SOUND_CALLBACK = 4,
00036 GMB_CATENARY_ON_3RD_TRACK = 5,
00037 };
00038
00039 enum GrfSpecFeature {
00040 GSF_TRAINS,
00041 GSF_ROADVEHICLES,
00042 GSF_SHIPS,
00043 GSF_AIRCRAFT,
00044 GSF_STATIONS,
00045 GSF_CANALS,
00046 GSF_BRIDGES,
00047 GSF_HOUSES,
00048 GSF_GLOBALVAR,
00049 GSF_INDUSTRYTILES,
00050 GSF_INDUSTRIES,
00051 GSF_CARGOS,
00052 GSF_SOUNDFX,
00053 GSF_AIRPORTS,
00054 GSF_SIGNALS,
00055 GSF_OBJECTS,
00056 GSF_RAILTYPES,
00057 GSF_AIRPORTTILES,
00058 GSF_END,
00059
00060 GSF_FAKE_TOWNS = GSF_END,
00061 GSF_FAKE_END,
00062
00063 GSF_INVALID = 0xFF
00064 };
00065
00066 static const uint32 INVALID_GRFID = 0xFFFFFFFF;
00067
00068 struct GRFLabel {
00069 byte label;
00070 uint32 nfo_line;
00071 size_t pos;
00072 struct GRFLabel *next;
00073 };
00074
00076 struct GRFFile {
00077 char *filename;
00078 bool is_ottdfile;
00079 uint32 grfid;
00080 byte grf_version;
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 SpriteID spriteset_start;
00094 int spriteset_numsets;
00095 int spriteset_numents;
00096 int spriteset_feature;
00097
00098 int spritegroups_count;
00099 struct SpriteGroup **spritegroups;
00100
00101 uint sound_offset;
00102 uint16 num_sounds;
00103
00104 struct StationSpec **stations;
00105 struct HouseSpec **housespec;
00106 struct IndustrySpec **industryspec;
00107 struct IndustryTileSpec **indtspec;
00108 struct ObjectSpec **objectspec;
00109 struct AirportSpec **airportspec;
00110 struct AirportTileSpec **airtspec;
00111
00112 uint32 param[0x80];
00113 uint param_end;
00114
00115 GRFLabel *label;
00116
00117 uint8 cargo_max;
00118 CargoLabel *cargo_list;
00119 uint8 cargo_map[NUM_CARGO];
00120
00121 uint8 railtype_max;
00122 RailTypeLabel *railtype_list;
00123 RailType railtype_map[RAILTYPE_END];
00124
00125 struct LanguageMap *language_map;
00126
00127 int traininfo_vehicle_pitch;
00128 uint traininfo_vehicle_width;
00129
00130 uint32 grf_features;
00131 PriceMultipliers price_base_multipliers;
00132
00134 uint32 GetParam(uint number) const
00135 {
00136
00137
00138 assert(this->param_end <= lengthof(this->param));
00139 return (number < this->param_end) ? this->param[number] : 0;
00140 }
00141 };
00142
00143 enum ShoreReplacement {
00144 SHORE_REPLACE_NONE,
00145 SHORE_REPLACE_ACTION_5,
00146 SHORE_REPLACE_ACTION_A,
00147 SHORE_REPLACE_ONLY_NEW,
00148 };
00149
00150 struct GRFLoadedFeatures {
00151 bool has_2CC;
00152 uint64 used_liveries;
00153 bool has_newhouses;
00154 bool has_newindustries;
00155 ShoreReplacement shore;
00156 };
00157
00158
00159 extern GRFLoadedFeatures _loaded_newgrf_features;
00160
00161 void LoadNewGRFFile(struct GRFConfig *config, uint file_index, GrfLoadingStage stage);
00162 void LoadNewGRF(uint load_index, uint file_index);
00163 void ReloadNewGRFData();
00164 void ResetNewGRFData();
00165
00166 void CDECL grfmsg(int severity, const char *str, ...) WARN_FORMAT(2, 3);
00167
00168 bool HasGrfMiscBit(GrfMiscBit bit);
00169 bool GetGlobalVariable(byte param, uint32 *value);
00170
00171 StringID MapGRFStringID(uint32 grfid, StringID str);
00172 void ShowNewGRFError();
00173
00174 #endif