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