newgrf.h

Go to the documentation of this file.
00001 /* $Id$ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
00008  */
00009 
00012 #ifndef NEWGRF_H
00013 #define NEWGRF_H
00014 
00015 #include "town_type.h"
00016 #include "newgrf_config.h"
00017 #include "cargotype.h"
00018 #include "industry_type.h"
00019 #include "station_type.h"
00020 #include "rail_type.h"
00021 #include "house_type.h"
00022 
00023 enum GrfLoadingStage {
00024   GLS_FILESCAN,
00025   GLS_SAFETYSCAN,
00026   GLS_LABELSCAN,
00027   GLS_INIT,
00028   GLS_RESERVE,
00029   GLS_ACTIVATION,
00030   GLS_END,
00031 };
00032 
00033 DECLARE_POSTFIX_INCREMENT(GrfLoadingStage);
00034 
00035 enum GrfMiscBit {
00036   GMB_DESERT_TREES_FIELDS    = 0, // Unsupported.
00037   GMB_DESERT_PAVED_ROADS     = 1,
00038   GMB_FIELD_BOUNDING_BOX     = 2, // Unsupported.
00039   GMB_TRAIN_WIDTH_32_PIXELS  = 3, 
00040   GMB_AMBIENT_SOUND_CALLBACK = 4, // Unsupported.
00041   GMB_CATENARY_ON_3RD_TRACK  = 5, // Unsupported.
00042 };
00043 
00044 enum GrfSpecFeature {
00045   GSF_TRAIN,
00046   GSF_ROAD,
00047   GSF_SHIP,
00048   GSF_AIRCRAFT,
00049   GSF_STATION,
00050   GSF_CANAL,
00051   GSF_BRIDGE,
00052   GSF_TOWNHOUSE,
00053   GSF_GLOBALVAR,
00054   GSF_INDUSTRYTILES,
00055   GSF_INDUSTRIES,
00056   GSF_CARGOS,
00057   GSF_SOUNDFX,
00058   GSF_END,
00059 };
00060 
00061 static const uint32 INVALID_GRFID = 0xFFFFFFFF;
00062 
00063 struct GRFLabel {
00064   byte label;
00065   uint32 nfo_line;
00066   size_t pos;
00067   struct GRFLabel *next;
00068 };
00069 
00071 struct GRFFile {
00072   char *filename;
00073   bool is_ottdfile;
00074   uint32 grfid;
00075   uint16 sprite_offset;
00076   byte grf_version;
00077 
00078   /* A sprite group contains all sprites of a given vehicle (or multiple
00079    * vehicles) when carrying given cargo. It consists of several sprite
00080    * sets.  Group ids are refered as "cargo id"s by TTDPatch
00081    * documentation, contributing to the global confusion.
00082    *
00083    * A sprite set contains all sprites of a given vehicle carrying given
00084    * cargo at a given *stage* - that is usually its load stage. Ie. you
00085    * can have a spriteset for an empty wagon, wagon full of coal,
00086    * half-filled wagon etc.  Each spriteset contains eight sprites (one
00087    * per direction) or four sprites if the vehicle is symmetric. */
00088 
00089   SpriteID spriteset_start;
00090   int spriteset_numsets;
00091   int spriteset_numents;
00092   int spriteset_feature;
00093 
00094   int spritegroups_count;
00095   struct SpriteGroup **spritegroups;
00096 
00097   uint sound_offset;
00098 
00099   StationSpec **stations;
00100   HouseSpec **housespec;
00101   IndustrySpec **industryspec;
00102   IndustryTileSpec **indtspec;
00103 
00104   uint32 param[0x80];
00105   uint param_end;  
00106 
00107   GRFLabel *label; 
00108 
00109   uint8 cargo_max;
00110   CargoLabel *cargo_list;
00111   uint8 cargo_map[NUM_CARGO];
00112 
00113   uint8 railtype_max;
00114   RailTypeLabel *railtype_list;
00115 
00116   int traininfo_vehicle_pitch;  
00117   int traininfo_vehicle_width;  
00118 
00119   uint32 grf_features;                     
00120   PriceMultipliers price_base_multipliers; 
00121 };
00122 
00123 enum ShoreReplacement {
00124   SHORE_REPLACE_NONE,       
00125   SHORE_REPLACE_ACTION_5,   
00126   SHORE_REPLACE_ACTION_A,   
00127   SHORE_REPLACE_ONLY_NEW,   
00128 };
00129 
00130 struct GRFLoadedFeatures {
00131   bool has_2CC;             
00132   bool has_newhouses;       
00133   bool has_newindustries;   
00134   ShoreReplacement shore;   
00135 };
00136 
00137 /* Indicates which are the newgrf features currently loaded ingame */
00138 extern GRFLoadedFeatures _loaded_newgrf_features;
00139 
00140 void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage);
00141 void LoadNewGRF(uint load_index, uint file_index);
00142 void ReloadNewGRFData(); // in saveload/afterload.cpp
00143 
00144 void CDECL grfmsg(int severity, const char *str, ...) WARN_FORMAT(2, 3);
00145 
00146 bool HasGrfMiscBit(GrfMiscBit bit);
00147 bool GetGlobalVariable(byte param, uint32 *value);
00148 
00149 StringID MapGRFStringID(uint32 grfid, StringID str);
00150 void ShowNewGRFError();
00151 
00152 #endif /* NEWGRF_H */

Generated on Sat Dec 26 20:06:02 2009 for OpenTTD by  doxygen 1.5.6