newgrf.h

Go to the documentation of this file.
00001 /* $Id: newgrf.h 15417 2009-02-08 18:11:06Z peter1138 $ */
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, // Unsupported.
00029   GMB_DESERT_PAVED_ROADS     = 1,
00030   GMB_FIELD_BOUNDING_BOX     = 2, // Unsupported.
00031   GMB_TRAIN_WIDTH_32_PIXELS  = 3,
00032   GMB_AMBIENT_SOUND_CALLBACK = 4, // Unsupported.
00033   GMB_CATENARY_ON_3RD_TRACK  = 5, // Unsupported.
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 struct GRFLabel {
00054   byte label;
00055   uint32 nfo_line;
00056   size_t pos;
00057   struct GRFLabel *next;
00058 };
00059 
00060 struct GRFFile {
00061   char *filename;
00062   bool is_ottdfile;
00063   uint32 grfid;
00064   uint16 sprite_offset;
00065   byte grf_version;
00066   GRFFile *next;
00067 
00068   /* A sprite group contains all sprites of a given vehicle (or multiple
00069    * vehicles) when carrying given cargo. It consists of several sprite
00070    * sets.  Group ids are refered as "cargo id"s by TTDPatch
00071    * documentation, contributing to the global confusion.
00072    *
00073    * A sprite set contains all sprites of a given vehicle carrying given
00074    * cargo at a given *stage* - that is usually its load stage. Ie. you
00075    * can have a spriteset for an empty wagon, wagon full of coal,
00076    * half-filled wagon etc.  Each spriteset contains eight sprites (one
00077    * per direction) or four sprites if the vehicle is symmetric. */
00078 
00079   SpriteID spriteset_start;
00080   int spriteset_numsets;
00081   int spriteset_numents;
00082   int spriteset_feature;
00083 
00084   int spritegroups_count;
00085   struct SpriteGroup **spritegroups;
00086 
00087   uint sound_offset;
00088 
00089   StationSpec **stations;
00090   HouseSpec **housespec;
00091   IndustrySpec **industryspec;
00092   IndustryTileSpec **indtspec;
00093 
00094   uint32 param[0x80];
00095   uint param_end;  
00096 
00097   GRFLabel *label; 
00098 
00099   uint8 cargo_max;
00100   CargoLabel *cargo_list;
00101   uint8 cargo_map[NUM_CARGO];
00102 
00103   uint8 railtype_max;
00104   RailTypeLabel *railtype_list;
00105 };
00106 
00107 extern GRFFile *_first_grffile;
00108 
00109 enum ShoreReplacement {
00110   SHORE_REPLACE_NONE,       
00111   SHORE_REPLACE_ACTION_5,   
00112   SHORE_REPLACE_ACTION_A,   
00113   SHORE_REPLACE_ONLY_NEW,   
00114 };
00115 
00116 struct GRFLoadedFeatures {
00117   bool has_2CC;             
00118   bool has_newhouses;       
00119   bool has_newindustries;   
00120   ShoreReplacement shore;   
00121 };
00122 
00123 /* Indicates which are the newgrf features currently loaded ingame */
00124 extern GRFLoadedFeatures _loaded_newgrf_features;
00125 
00126 void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage);
00127 void LoadNewGRF(uint load_index, uint file_index);
00128 void ReloadNewGRFData(); // in saveload/afterload.cpp
00129 
00130 void CDECL grfmsg(int severity, const char *str, ...);
00131 
00132 bool HasGrfMiscBit(GrfMiscBit bit);
00133 bool GetGlobalVariable(byte param, uint32 *value);
00134 
00135 StringID MapGRFStringID(uint32 grfid, StringID str);
00136 
00137 #endif /* NEWGRF_H */

Generated on Mon Feb 16 23:12:08 2009 for openttd by  doxygen 1.5.6