OpenTTD
industrytype.h
Go to the documentation of this file.
1 /* $Id$ */
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 <array>
16 #include <vector>
17 #include "map_type.h"
18 #include "slope_type.h"
19 #include "industry_type.h"
20 #include "landscape_type.h"
21 #include "cargo_type.h"
22 #include "newgrf_animation_type.h"
23 #include "newgrf_commons.h"
24 
27 };
28 
35 };
36 
41 enum CheckProc {
52 };
53 
60 };
61 
64  INDUSTRYBEH_NONE = 0,
79  /* The following flags are only used for newindustries and do no represent any normal behaviour */
85 };
87 
88 
90  INDTILE_SPECIAL_NONE = 0,
93 };
95 
96 
98  TileIndexDiffC ti;
99  IndustryGfx gfx;
100 };
101 
103 using IndustryTileLayout = std::vector<IndustryTileLayoutTile>;
104 
108 struct IndustrySpec {
109  std::vector<IndustryTileLayout> layouts;
113  IndustryType conflicting[3];
114  byte check_proc;
115  CargoID produced_cargo[INDUSTRY_NUM_OUTPUTS];
116  byte production_rate[INDUSTRY_NUM_OUTPUTS];
127  byte map_colour;
134  byte appear_ingame[NUM_LANDSCAPE];
135  byte appear_creation[NUM_LANDSCAPE];
137  const uint8 *random_sounds;
138  /* Newgrf data */
139  uint16 callback_mask;
140  uint8 cleanup_flag;
141  bool enabled;
143 
144  bool IsRawIndustry() const;
145  bool IsProcessingIndustry() const;
146  Money GetConstructionCost() const;
147  Money GetRemovalCost() const;
148  bool UsesSmoothEconomy() const;
149 
150  ~IndustrySpec();
151 };
152 
159  int8 acceptance[INDUSTRY_NUM_INPUTS];
162  byte anim_next;
163 
168  /* Newgrf data */
172  bool enabled;
174 };
175 
176 /* industry_cmd.cpp*/
177 const IndustrySpec *GetIndustrySpec(IndustryType thistype);
178 const IndustryTileSpec *GetIndustryTileSpec(IndustryGfx gfx);
179 void ResetIndustries();
180 
181 /* writable arrays of specs */
182 extern IndustrySpec _industry_specs[NUM_INDUSTRYTYPES];
183 extern IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES];
184 
185 /* industry_gui.cpp */
186 void SortIndustryTypes();
187 /* Industry types sorted alphabetically by name. */
188 extern std::array<IndustryType, NUM_INDUSTRYTYPES> _sorted_industry_types;
189 
195 static inline IndustryGfx GetTranslatedIndustryTileID(IndustryGfx gfx)
196 {
197  /* the 0xFF should be GFX_WATERTILE_SPECIALCHECK but for reasons of include mess,
198  * we'll simplify the writing.
199  * Basically, the first test is required since the GFX_WATERTILE_SPECIALCHECK value
200  * will never be assigned as a tile index and is only required in order to do some
201  * tests while building the industry (as in WATER REQUIRED */
202  if (gfx != 0xFF) {
203  assert(gfx < INVALID_INDUSTRYTILE);
204  const IndustryTileSpec *it = &_industry_tile_specs[gfx];
205  return it->grf_prop.override == INVALID_INDUSTRYTILE ? gfx : it->grf_prop.override;
206  } else {
207  return gfx;
208  }
209 }
210 
211 static const uint8 IT_INVALID = 255;
212 
213 #endif /* INDUSTRYTYPE_H */
CargoID accepts_cargo[INDUSTRY_NUM_INPUTS]
16 accepted cargoes.
Definition: industrytype.h:122
can be exploded by a military airplane (oil refinery)
Definition: industrytype.h:76
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Array of industries data.
bool enabled
entity still available (by default true).newgrf can disable it, though
Definition: industrytype.h:141
Types related to the industry.
Definitions of a slope.
static const int INDUSTRY_NUM_INPUTS
Number of cargo types an industry can accept.
Definition: industry_type.h:40
IndustryConstructionType
How was the industry created.
Definition: industrytype.h:55
byte map_colour
colour used for the small map
Definition: industrytype.h:127
while editing a scenario
Definition: industrytype.h:59
in previous game version or without newindustries activated
Definition: industrytype.h:56
Money GetRemovalCost() const
Get the cost for removing this industry Take note that the cost will always be zero for non-grf indus...
Types related to maps.
uint32 prospecting_chance
Chance prospecting succeeds.
Definition: industrytype.h:112
Industries at sea should be positioned near edge of the map.
Definition: industrytype.h:50
Free the dynamically allocated sounds table.
Definition: industrytype.h:26
static const IndustryGfx INVALID_INDUSTRYTILE
one above amount is considered invalid
Definition: industry_type.h:36
ai will attempt to establish air/ship routes to this industry (oil rig)
Definition: industrytype.h:75
IndustryLifeType life_type
This is also known as Industry production flag, in newgrf specs.
Definition: industrytype.h:124
periodically plants fields around itself (temp and arctic farms)
Definition: industrytype.h:65
do not increase production (oil wells) in the temperate climate
Definition: industrytype.h:72
Definitions related to NewGRF animation.
uint16 callback_mask
Bitmask of industry callbacks that have to be called.
Definition: industrytype.h:139
Always succeeds.
Definition: industrytype.h:42
uint32 removal_cost_multiplier
Base removal cost multiplier.
Definition: industrytype.h:111
during random map creation
Definition: industrytype.h:58
can cause a subsidence (coal mine, shaft that collapses)
Definition: industrytype.h:78
Like factories.
Definition: industrytype.h:34
const IndustryTileSpec * GetIndustryTileSpec(IndustryGfx gfx)
Array of industry tiles data.
uint16 input_cargo_multiplier[INDUSTRY_NUM_INPUTS][INDUSTRY_NUM_OUTPUTS]
Input cargo multipliers (multiply amount of incoming cargo for the produced cargoes) ...
Definition: industrytype.h:123
std::vector< IndustryTileLayout > layouts
List of possible tile layouts for the industry.
Definition: industrytype.h:109
is always built near towns (toy shop)
Definition: industrytype.h:70
Types related to cargoes...
static const int INDUSTRY_NUM_OUTPUTS
Number of cargo types an industry can produce.
Definition: industry_type.h:41
StringID production_down_text
Message appearing when the industry&#39;s production is decreasing.
Definition: industrytype.h:132
StringID name
Displayed name of the industry.
Definition: industrytype.h:128
Automatic production multiplier handling.
Definition: industrytype.h:80
IndustryTileSpecialFlags special_flags
Bitmask of extra flags used by the tile.
Definition: industrytype.h:171
can only be built in towns (arctic/tropic banks, water tower)
Definition: industrytype.h:69
Do not force one instance of this type to appear on map generation.
Definition: industrytype.h:82
Industry should be below snow-line in arctic.
Definition: industrytype.h:45
IndustryLifeType
Available types of industry lifetimes.
Definition: industrytype.h:30
can be exploded by a military helicopter (factory)
Definition: industrytype.h:77
static IndustryGfx GetTranslatedIndustryTileID(IndustryGfx gfx)
Do industry gfx ID translation for NewGRFs.
Definition: industrytype.h:195
uint8 cleanup_flag
flags indicating which data should be freed upon cleaning up
Definition: industrytype.h:140
Slope slopes_refused
slope pattern on which this tile cannot be built
Definition: industrytype.h:160
const uint8 * random_sounds
array of random sounds.
Definition: industrytype.h:137
can only be built after 1960 (oil rigs)
Definition: industrytype.h:74
bool IsRawIndustry() const
Is an industry with the spec a raw industry?
Like power plants and banks.
Definition: industrytype.h:31
either by user or random creation process
Definition: industrytype.h:57
bool IsProcessingIndustry() const
Is an industry with the spec a processing industry?
Data related to the handling of grf files.
Tile always accepts all cargoes the associated industry accepts.
Definition: industrytype.h:92
void ResetIndustries()
This function initialize the spec arrays of both industry and industry tiles.
bool UsesSmoothEconomy() const
Determines whether this industrytype uses smooth economy or whether it uses standard/newgrf productio...
StringID new_industry_text
Message appearing when the industry is built.
Definition: industrytype.h:129
End marker of the industry check procedures.
Definition: industrytype.h:51
byte anim_production
Animation frame to start when goods are produced.
Definition: industrytype.h:161
Industry should be build above snow-line in arctic climate.
Definition: industrytype.h:43
static const IndustryGfx NUM_INDUSTRYTILES
total number of industry tiles, new and old
Definition: industry_type.h:35
Industry should be in the desert.
Definition: industrytype.h:47
Defines the data structure for constructing industry.
Definition: industrytype.h:108
bool enabled
entity still available (by default true).newgrf can disable it, though
Definition: industrytype.h:172
GRFFileProps grf_prop
properties related to the grf file
Definition: industrytype.h:173
Industry should be positioned near edge of the map.
Definition: industrytype.h:44
Money GetConstructionCost() const
Get the cost for constructing this industry.
IndustryBehaviour behaviour
How this industry will behave, and how others entities can use it.
Definition: industrytype.h:126
GRFFileProps grf_prop
properties related to the grf file
Definition: industrytype.h:142
byte appear_ingame[NUM_LANDSCAPE]
Probability of appearance in game.
Definition: industrytype.h:134
cuts trees and produce first output cargo from them (lumber mill)
Definition: industrytype.h:66
IndustryCleanupType
Definition: industrytype.h:25
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
Industry should NOT be in the desert.
Definition: industrytype.h:46
Industry should be in the rain forest.
Definition: industrytype.h:48
uint8 callback_mask
Bitmask of industry tile callbacks that have to be called.
Definition: industrytype.h:169
uint16 override
id of the entity been replaced by
A pair-construct of a TileIndexDiff.
Definition: map_type.h:59
std::vector< IndustryTileLayoutTile > IndustryTileLayout
A complete tile layout for an industry is a list of tiles.
Definition: industrytype.h:103
IndustryTileSpecialFlags
Flags for miscellaneous industry tile specialities.
Definition: industrytype.h:89
is built on water (oil rig)
Definition: industrytype.h:67
byte minimal_cargo
minimum amount of cargo transported to the stations.
Definition: industrytype.h:121
uint8 cost_multiplier
Base construction cost multiplier.
Definition: industrytype.h:110
byte appear_creation[NUM_LANDSCAPE]
Probability of appearance during map creation.
Definition: industrytype.h:135
Types related to the landscape.
AnimationInfo animation
Information about the animation (is it looping, how many loops etc)
Definition: industrytype.h:170
static const IndustryType NUM_INDUSTRYTYPES
total number of industry types, new and old; limited to 240 because we need some special ids like INV...
Definition: industry_type.h:28
StringID closure_text
Message appearing when the industry closes.
Definition: industrytype.h:130
byte anim_next
Next frame in an animation.
Definition: industrytype.h:162
Allow produced/accepted cargoes callbacks to supply more than 2 and 3 types.
Definition: industrytype.h:84
std::array< IndustryType, NUM_INDUSTRYTYPES > _sorted_industry_types
Industry types sorted by name.
CheckProc
Available procedures to check whether an industry may build at a given location.
Definition: industrytype.h:41
Slope
Enumeration for the slope-type.
Definition: slope_type.h:50
void SortIndustryTypes()
Initialize the list of sorted industry types.
byte climate_availability
Bitmask, giving landscape enums as bit position.
Definition: industrytype.h:125
IndustryBehaviour
Various industry behaviours mostly to represent original TTD specialities.
Definition: industrytype.h:63
Callback 0x26 needs random bits.
Definition: industrytype.h:91
IndustryType conflicting[3]
Industries this industry cannot be close to.
Definition: industrytype.h:113
Fields are planted around when built (all farms)
Definition: industrytype.h:71
Allow closing down the last instance of this type.
Definition: industrytype.h:83
This file simplyfies and embeds a common mechanism of loading/saving and mapping of grf entities...
Information about animation.
uint8 number_of_sounds
Number of sounds available in the sounds array.
Definition: industrytype.h:136
StringID station_name
Default name for nearby station.
Definition: industrytype.h:133
StringID production_up_text
Message appearing when the industry&#39;s production is increasing.
Definition: industrytype.h:131
byte check_proc
Index to a procedure to check for conflicting circumstances.
Definition: industrytype.h:114
Definition of one tile in an industry tile layout.
Definition: industrytype.h:97
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:22
Defines the data structure of each individual tile of an industry.
Definition: industrytype.h:157
can only be built in towns larger than 1200 inhabitants (temperate bank)
Definition: industrytype.h:68
Industry should be in low land.
Definition: industrytype.h:49
Like forests.
Definition: industrytype.h:33
Production callback needs random bits in var 10.
Definition: industrytype.h:81
can only be built before 1950 (oil wells)
Definition: industrytype.h:73
bool anim_state
When true, the tile has to be drawn using the animation state instead of the construction state...
Definition: industrytype.h:167