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