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