src/industry.h
branchNewGRF_ports
changeset 6868 7eb395287b3d
parent 6743 cabfaa4a0295
child 6870 ca3fd1fbe311
equal deleted inserted replaced
6867:a4ad48192617 6868:7eb395287b3d
   116 
   116 
   117 	OwnerByte founder;                  ///< Founder of the industry
   117 	OwnerByte founder;                  ///< Founder of the industry
   118 	Date construction_date;             ///< Date of the construction of the industry
   118 	Date construction_date;             ///< Date of the construction of the industry
   119 	uint8 construction_type;            ///< Way the industry was constructed (@see IndustryConstructionType)
   119 	uint8 construction_type;            ///< Way the industry was constructed (@see IndustryConstructionType)
   120 	Date last_cargo_accepted_at;        ///< Last day cargo was accepted by this industry
   120 	Date last_cargo_accepted_at;        ///< Last day cargo was accepted by this industry
       
   121 	byte selected_layout;               ///< Which tile layout was used when creating the industry
   121 
   122 
   122 	Industry(TileIndex tile = 0) : xy(tile) {}
   123 	Industry(TileIndex tile = 0) : xy(tile) {}
   123 	~Industry();
   124 	~Industry();
   124 
   125 
   125 	bool IsValid() const { return this->xy != 0; }
   126 	inline bool IsValid() const { return this->xy != 0; }
   126 };
   127 };
   127 
   128 
   128 struct IndustryTileTable {
   129 struct IndustryTileTable {
   129 	TileIndexDiffC ti;
   130 	TileIndexDiffC ti;
   130 	IndustryGfx gfx;
   131 	IndustryGfx gfx;
   131 };
   132 };
   132 
   133 
   133 /** Data related to the handling of grf files.  Common to both industry and industry tile */
   134 /** Data related to the handling of grf files.  Common to both industry and industry tile */
   134 struct GRFFileProps {
   135 struct GRFFileProps {
   135 	uint8 subst_id;
   136 	uint16 subst_id;
   136 	uint16 local_id;                      ///< id defined by the grf file for this industry
   137 	uint16 local_id;                      ///< id defined by the grf file for this industry
   137 	struct SpriteGroup *spritegroup;      ///< pointer to the different sprites of the industry
   138 	struct SpriteGroup *spritegroup;      ///< pointer to the different sprites of the industry
   138 	const struct GRFFile *grffile;        ///< grf file that introduced this industry
   139 	const struct GRFFile *grffile;        ///< grf file that introduced this industry
   139 	uint16 override;                      ///< id of the entity been replaced by
   140 	uint16 override;                      ///< id of the entity been replaced by
   140 };
   141 };
   209 	struct GRFFileProps grf_prop;
   210 	struct GRFFileProps grf_prop;
   210 };
   211 };
   211 
   212 
   212 /* industry_cmd.cpp*/
   213 /* industry_cmd.cpp*/
   213 const IndustrySpec *GetIndustrySpec(IndustryType thistype);    ///< Array of industries data
   214 const IndustrySpec *GetIndustrySpec(IndustryType thistype);    ///< Array of industries data
   214 const IndustryTileSpec *GetIndustryTileSpec(IndustryGfx gfx, bool full_check = true);  ///< Array of industry tiles data
   215 const IndustryTileSpec *GetIndustryTileSpec(IndustryGfx gfx);  ///< Array of industry tiles data
   215 void ResetIndustries();
   216 void ResetIndustries();
   216 void PlantRandomFarmField(const Industry *i);
   217 void PlantRandomFarmField(const Industry *i);
   217 
   218 
   218 /* writable arrays of specs */
   219 /* writable arrays of specs */
   219 extern IndustrySpec _industry_specs[NUM_INDUSTRYTYPES];
   220 extern IndustrySpec _industry_specs[NUM_INDUSTRYTYPES];
   220 extern IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES];
   221 extern IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES];
       
   222 
       
   223 static inline IndustryGfx GetTranslatedIndustryTileID(IndustryGfx gfx)
       
   224 {
       
   225 	/* the 0xFF should be GFX_WATERTILE_SPECIALCHECK but for reasons of include mess,
       
   226 	 * we'll simplify the writing.
       
   227 	 * Basically, the first test is required since the GFX_WATERTILE_SPECIALCHECK value
       
   228 	 * will never be assigned as a tile index and is only required in order to do some
       
   229 	 * tests while building the industry (as in WATER REQUIRED */
       
   230 	if (gfx != 0xFF) {
       
   231 		assert(gfx < INVALID_INDUSTRYTILE);
       
   232 		const IndustryTileSpec *it = &_industry_tile_specs[gfx];
       
   233 		return it->grf_prop.override == INVALID_INDUSTRYTILE ? gfx : it->grf_prop.override;
       
   234 	} else {
       
   235 		return gfx;
       
   236 	}
       
   237 }
   221 
   238 
   222 /* smallmap_gui.cpp */
   239 /* smallmap_gui.cpp */
   223 void BuildIndustriesLegend();
   240 void BuildIndustriesLegend();
   224 
   241 
   225 /**
   242 /**