OpenTTD
industrytype.h
Go to the documentation of this file.
1 /* $Id: industrytype.h 24900 2013-01-08 22:46:42Z planetmaker $ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * 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.
6  * 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.
7  * 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/>.
8  */
9 
12 #ifndef INDUSTRYTYPE_H
13 #define INDUSTRYTYPE_H
14 
15 #include "map_type.h"
16 #include "slope_type.h"
17 #include "industry_type.h"
18 #include "landscape_type.h"
19 #include "cargo_type.h"
20 #include "newgrf_animation_type.h"
21 #include "newgrf_commons.h"
22 
26 };
27 
34 };
35 
40 enum CheckProc {
51 };
52 
59 };
60 
63  INDUSTRYBEH_NONE = 0,
78  /* The following flags are only used for newindustries and do no represent any normal behaviour */
83 };
85 
86 
88  INDTILE_SPECIAL_NONE = 0,
90 };
92 
94  TileIndexDiffC ti;
95  IndustryGfx gfx;
96 };
97 
101 struct IndustrySpec {
102  const IndustryTileTable * const *table;
103  byte num_table;
107  IndustryType conflicting[3];
108  byte check_proc;
109  CargoID produced_cargo[2];
110  byte production_rate[2];
117  uint16 input_cargo_multiplier[3][2];
121  byte map_colour;
128  byte appear_ingame[NUM_LANDSCAPE];
129  byte appear_creation[NUM_LANDSCAPE];
131  const uint8 *random_sounds;
132  /* Newgrf data */
133  uint16 callback_mask;
134  uint8 cleanup_flag;
135  bool enabled;
137 
138  bool IsRawIndustry() const;
139  bool IsProcessingIndustry() const;
140  Money GetConstructionCost() const;
141  Money GetRemovalCost() const;
142  bool UsesSmoothEconomy() const;
143 };
144 
150  uint8 acceptance[3];
153  byte anim_next;
154 
159  /* Newgrf data */
163  bool enabled;
165 };
166 
167 /* industry_cmd.cpp*/
168 const IndustrySpec *GetIndustrySpec(IndustryType thistype);
169 const IndustryTileSpec *GetIndustryTileSpec(IndustryGfx gfx);
170 void ResetIndustries();
171 
172 /* writable arrays of specs */
173 extern IndustrySpec _industry_specs[NUM_INDUSTRYTYPES];
174 extern IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES];
175 
176 /* industry_gui.cpp */
177 void SortIndustryTypes();
178 /* Industry types sorted alphabetically by name. */
179 extern IndustryType _sorted_industry_types[NUM_INDUSTRYTYPES];
180 
186 static inline IndustryGfx GetTranslatedIndustryTileID(IndustryGfx gfx)
187 {
188  /* the 0xFF should be GFX_WATERTILE_SPECIALCHECK but for reasons of include mess,
189  * we'll simplify the writing.
190  * Basically, the first test is required since the GFX_WATERTILE_SPECIALCHECK value
191  * will never be assigned as a tile index and is only required in order to do some
192  * tests while building the industry (as in WATER REQUIRED */
193  if (gfx != 0xFF) {
194  assert(gfx < INVALID_INDUSTRYTILE);
195  const IndustryTileSpec *it = &_industry_tile_specs[gfx];
196  return it->grf_prop.override == INVALID_INDUSTRYTILE ? gfx : it->grf_prop.override;
197  } else {
198  return gfx;
199  }
200 }
201 
202 static const uint8 IT_INVALID = 255;
203 
204 #endif /* INDUSTRYTYPE_H */