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_END,
00058 };
00059
00060 static const uint32 INVALID_GRFID = 0xFFFFFFFF;
00061
00062 struct GRFLabel {
00063 byte label;
00064 uint32 nfo_line;
00065 size_t pos;
00066 struct GRFLabel *next;
00067 };
00068
00070 struct GRFFile {
00071 char *filename;
00072 bool is_ottdfile;
00073 uint32 grfid;
00074 uint16 sprite_offset;
00075 byte grf_version;
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 SpriteID spriteset_start;
00089 int spriteset_numsets;
00090 int spriteset_numents;
00091 int spriteset_feature;
00092
00093 int spritegroups_count;
00094 struct SpriteGroup **spritegroups;
00095
00096 uint sound_offset;
00097
00098 StationSpec **stations;
00099 HouseSpec **housespec;
00100 IndustrySpec **industryspec;
00101 IndustryTileSpec **indtspec;
00102
00103 uint32 param[0x80];
00104 uint param_end;
00105
00106 GRFLabel *label;
00107
00108 uint8 cargo_max;
00109 CargoLabel *cargo_list;
00110 uint8 cargo_map[NUM_CARGO];
00111
00112 uint8 railtype_max;
00113 RailTypeLabel *railtype_list;
00114
00115 int traininfo_vehicle_pitch;
00116 int traininfo_vehicle_width;
00117
00118 uint32 grf_features;
00119 PriceMultipliers price_base_multipliers;
00120
00122 uint32 GetParam(uint number) const
00123 {
00124
00125
00126 assert(this->param_end <= lengthof(this->param));
00127 return (number < this->param_end) ? this->param[number] : 0;
00128 }
00129 };
00130
00131 enum ShoreReplacement {
00132 SHORE_REPLACE_NONE,
00133 SHORE_REPLACE_ACTION_5,
00134 SHORE_REPLACE_ACTION_A,
00135 SHORE_REPLACE_ONLY_NEW,
00136 };
00137
00138 struct GRFLoadedFeatures {
00139 bool has_2CC;
00140 bool has_newhouses;
00141 bool has_newindustries;
00142 ShoreReplacement shore;
00143 };
00144
00145
00146 extern GRFLoadedFeatures _loaded_newgrf_features;
00147
00148 void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage);
00149 void LoadNewGRF(uint load_index, uint file_index);
00150 void ReloadNewGRFData();
00151
00152 void CDECL grfmsg(int severity, const char *str, ...) WARN_FORMAT(2, 3);
00153
00154 bool HasGrfMiscBit(GrfMiscBit bit);
00155 bool GetGlobalVariable(byte param, uint32 *value);
00156
00157 StringID MapGRFStringID(uint32 grfid, StringID str);
00158 void ShowNewGRFError();
00159
00160 #endif