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
23 enum IndustryCleanupType {
24 CLEAN_RANDOMSOUNDS,
25 CLEAN_TILELAYOUT,
26 };
27
29 enum IndustryLifeType {
30 INDUSTRYLIFE_BLACK_HOLE = 0,
31 INDUSTRYLIFE_EXTRACTIVE = 1 << 0,
32 INDUSTRYLIFE_ORGANIC = 1 << 1,
33 INDUSTRYLIFE_PROCESSING = 1 << 2,
34 };
35
40 enum CheckProc {
41 CHECK_NOTHING,
42 CHECK_FOREST,
43 CHECK_REFINERY,
44 CHECK_FARM,
45 CHECK_PLANTATION,
46 CHECK_WATER,
47 CHECK_LUMBERMILL,
48 CHECK_BUBBLEGEN,
49 CHECK_OIL_RIG,
50 CHECK_END,
51 };
52
54 enum IndustryConstructionType {
55 ICT_UNKNOWN,
56 ICT_NORMAL_GAMEPLAY,
57 ICT_MAP_GENERATION,
58 ICT_SCENARIO_EDITOR,
59 };
60
62 enum IndustryBehaviour {
63 INDUSTRYBEH_NONE = 0,
64 INDUSTRYBEH_PLANT_FIELDS = 1 << 0,
65 INDUSTRYBEH_CUT_TREES = 1 << 1,
66 INDUSTRYBEH_BUILT_ONWATER = 1 << 2,
67 INDUSTRYBEH_TOWN1200_MORE = 1 << 3,
68 INDUSTRYBEH_ONLY_INTOWN = 1 << 4,
69 INDUSTRYBEH_ONLY_NEARTOWN = 1 << 5,
70 INDUSTRYBEH_PLANT_ON_BUILT = 1 << 6,
71 INDUSTRYBEH_DONT_INCR_PROD = 1 << 7,
72 INDUSTRYBEH_BEFORE_1950 = 1 << 8,
73 INDUSTRYBEH_AFTER_1960 = 1 << 9,
74 INDUSTRYBEH_AI_AIRSHIP_ROUTES = 1 << 10,
75 INDUSTRYBEH_AIRPLANE_ATTACKS = 1 << 11,
76 INDUSTRYBEH_CHOPPER_ATTACKS = 1 << 12,
77 INDUSTRYBEH_CAN_SUBSIDENCE = 1 << 13,
78 /* The following flags are only used for newindustries and do no represent any normal behaviour */
79 INDUSTRYBEH_PROD_MULTI_HNDLING = 1 << 14,
80 INDUSTRYBEH_PRODCALLBACK_RANDOM = 1 << 15,
81 INDUSTRYBEH_NOBUILT_MAPCREATION = 1 << 16,
82 INDUSTRYBEH_CANCLOSE_LASTINSTANCE = 1 << 17,
83 };
84 DECLARE_ENUM_AS_BIT_SET(IndustryBehaviour)
85
86
87 enum IndustryTileSpecialFlags {
88 INDTILE_SPECIAL_NONE = 0,
89 INDTILE_SPECIAL_NEXTFRAME_RANDOMBITS = 1 << 0,
90 };
91 DECLARE_ENUM_AS_BIT_SET(IndustryTileSpecialFlags)
92
93 struct IndustryTileTable {
94 TileIndexDiffC ti;
95 IndustryGfx gfx;
96 };
97
101 struct IndustrySpec {
102 const IndustryTileTable * const *table;
103 byte num_table;
104 uint8 cost_multiplier;
105 uint32 removal_cost_multiplier;
106 uint32 prospecting_chance;
107 IndustryType conflicting[3];
108 byte check_proc;
109 CargoID produced_cargo[2];
110 byte production_rate[2];
115 byte minimal_cargo;
116 CargoID accepts_cargo[3];
117 uint16 input_cargo_multiplier[3][2];
118 IndustryLifeType life_type;
119 byte climate_availability;
120 IndustryBehaviour behaviour;
121 byte map_colour;
122 StringID name;
123 StringID new_industry_text;
124 StringID closure_text;
125 StringID production_up_text;
126 StringID production_down_text;
127 StringID station_name;
128 byte appear_ingame[NUM_LANDSCAPE];
129 byte appear_creation[NUM_LANDSCAPE];
130 uint8 number_of_sounds;
131 const uint8 *random_sounds;
132 /* Newgrf data */
133 uint16 callback_mask;
134 uint8 cleanup_flag;
135 bool enabled;
136 GRFFileProps grf_prop;
137
138 bool IsRawIndustry() const;
139 bool IsProcessingIndustry() const;
140 Money GetConstructionCost() const;
141 Money GetRemovalCost() const;
142 bool UsesSmoothEconomy() const;
143 };
144
148 struct IndustryTileSpec {
149 CargoID accepts_cargo[3];
150 uint8 acceptance[3];
151 Slope slopes_refused;
152 byte anim_production;
153 byte anim_next;
154
158 bool anim_state;
159 /* Newgrf data */
160 uint8 callback_mask;
161 AnimationInfo animation;
162 IndustryTileSpecialFlags special_flags;
163 bool enabled;
164 GRFFileProps grf_prop;
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 */
INDUSTRYBEH_AIRPLANE_ATTACKS
can be exploded by a military airplane (oil refinery)
Definition: industrytype.h:75
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:31
GetIndustrySpec
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Array of industries data.
Definition: industry_cmd.cpp:116
IndustrySpec::enabled
bool enabled
entity still available (by default true).newgrf can disable it, though
Definition: industrytype.h:135
industry_type.h
Types related to the industry.
slope_type.h
Definitions of a slope.
IndustryConstructionType
IndustryConstructionType
How was the industry created.
Definition: industrytype.h:54
IndustrySpec::map_colour
byte map_colour
colour used for the small map
Definition: industrytype.h:121
ICT_SCENARIO_EDITOR
while editing a scenario
Definition: industrytype.h:58
ICT_UNKNOWN
in previous game version or without newindustries activated
Definition: industrytype.h:55
IndustrySpec::GetRemovalCost
Money GetRemovalCost() const
Get the cost for removing this industry Take note that the cost will always be zero for non-grf indus...
Definition: industry_cmd.cpp:2808
map_type.h
Types related to maps.
IndustrySpec::prospecting_chance
uint32 prospecting_chance
Chance prospecting succeeds.
Definition: industrytype.h:106
CHECK_OIL_RIG
Industries at sea should be positioned near edge of the map.
Definition: industrytype.h:49
CLEAN_RANDOMSOUNDS
Free the dynamically allocated sounds table.
Definition: industrytype.h:24
INVALID_INDUSTRYTILE
static const IndustryGfx INVALID_INDUSTRYTILE
one above amount is considered invalid
Definition: industry_type.h:36
INDUSTRYBEH_AI_AIRSHIP_ROUTES
ai will attempt to establish air/ship routes to this industry (oil rig)
Definition: industrytype.h:74
IndustrySpec::life_type
IndustryLifeType life_type
This is also known as Industry production flag, in newgrf specs.
Definition: industrytype.h:118
INDUSTRYBEH_PLANT_FIELDS
periodically plants fields around itself (temp and arctic farms)
Definition: industrytype.h:64
INDUSTRYBEH_DONT_INCR_PROD
do not increase production (oil wells) in the temperate climate
Definition: industrytype.h:71
newgrf_animation_type.h
Definitions related to NewGRF animation.
IndustrySpec::callback_mask
uint16 callback_mask
Bitmask of industry callbacks that have to be called.
Definition: industrytype.h:133
CHECK_NOTHING
Always succeeds.
Definition: industrytype.h:41
IndustrySpec::removal_cost_multiplier
uint32 removal_cost_multiplier
Base removal cost multiplier.
Definition: industrytype.h:105
ICT_MAP_GENERATION
during random map creation
Definition: industrytype.h:57
INDUSTRYBEH_CAN_SUBSIDENCE
can cause a subsidence (coal mine, shaft that collapses)
Definition: industrytype.h:77
INDUSTRYLIFE_PROCESSING
Like factories.
Definition: industrytype.h:33
GetIndustryTileSpec
const IndustryTileSpec * GetIndustryTileSpec(IndustryGfx gfx)
Array of industry tiles data.
Definition: industry_cmd.cpp:130
IndustrySpec::table
const IndustryTileTable *const * table
List of the tiles composing the industry.
Definition: industrytype.h:102
INDUSTRYBEH_ONLY_NEARTOWN
is always built near towns (toy shop)
Definition: industrytype.h:69
cargo_type.h
Types related to cargoes...
IndustrySpec::production_down_text
StringID production_down_text
Message appearing when the industry&#39;s production is decreasing.
Definition: industrytype.h:126
IndustrySpec::name
StringID name
Displayed name of the industry.
Definition: industrytype.h:122
INDUSTRYBEH_PROD_MULTI_HNDLING
Automatic production multiplier handling.
Definition: industrytype.h:79
IndustryTileSpec::special_flags
IndustryTileSpecialFlags special_flags
Bitmask of extra flags used by the tile.
Definition: industrytype.h:162
INDUSTRYBEH_ONLY_INTOWN
can only be built in towns (arctic/tropic banks, water tower)
Definition: industrytype.h:68
INDUSTRYBEH_NOBUILT_MAPCREATION
Do not force one instance of this type to appear on map generation.
Definition: industrytype.h:81
CHECK_FARM
Industry should be below snow-line in arctic.
Definition: industrytype.h:44
IndustryLifeType
IndustryLifeType
Available types of industry lifetimes.
Definition: industrytype.h:29
INDUSTRYBEH_CHOPPER_ATTACKS
can be exploded by a military helicopter (factory)
Definition: industrytype.h:76
GetTranslatedIndustryTileID
static IndustryGfx GetTranslatedIndustryTileID(IndustryGfx gfx)
Do industry gfx ID translation for NewGRFs.
Definition: industrytype.h:186
IndustrySpec::cleanup_flag
uint8 cleanup_flag
flags indicating which data should be freed upon cleaning up
Definition: industrytype.h:134
IndustryTileSpec::slopes_refused
Slope slopes_refused
slope pattern on which this tile cannot be built
Definition: industrytype.h:151
IndustrySpec::random_sounds
const uint8 * random_sounds
array of random sounds.
Definition: industrytype.h:131
INDUSTRYBEH_AFTER_1960
can only be built after 1960 (oil rigs)
Definition: industrytype.h:73
IndustrySpec::IsRawIndustry
bool IsRawIndustry() const
Is an industry with the spec a raw industry?
Definition: industry_cmd.cpp:2775
INDUSTRYLIFE_BLACK_HOLE
Like power plants and banks.
Definition: industrytype.h:30
ICT_NORMAL_GAMEPLAY
either by user or random creation process
Definition: industrytype.h:56
IndustrySpec::IsProcessingIndustry
bool IsProcessingIndustry() const
Is an industry with the spec a processing industry?
Definition: industry_cmd.cpp:2784
GRFFileProps
Data related to the handling of grf files.
Definition: newgrf_commons.h:325
ResetIndustries
void ResetIndustries()
This function initialize the spec arrays of both industry and industry tiles.
Definition: industry_cmd.cpp:72
IndustrySpec::UsesSmoothEconomy
bool UsesSmoothEconomy() const
Determines whether this industrytype uses smooth economy or whether it uses standard/newgrf productio...
Definition: industry_cmd.cpp:2817
IndustrySpec::new_industry_text
StringID new_industry_text
Message appearing when the industry is built.
Definition: industrytype.h:123
CHECK_END
End marker of the industry check procedures.
Definition: industrytype.h:50
IndustryTileSpec::anim_production
byte anim_production
Animation frame to start when goods are produced.
Definition: industrytype.h:152
CHECK_FOREST
Industry should be build above snow-line in arctic climate.
Definition: industrytype.h:42
NUM_INDUSTRYTILES
static const IndustryGfx NUM_INDUSTRYTILES
total number of industry tiles, new and old
Definition: industry_type.h:35
CHECK_WATER
Industry should be in the desert.
Definition: industrytype.h:46
IndustrySpec
Defines the data structure for constructing industry.
Definition: industrytype.h:101
IndustryTileSpec::enabled
bool enabled
entity still available (by default true).newgrf can disable it, though
Definition: industrytype.h:163
IndustryTileSpec::grf_prop
GRFFileProps grf_prop
properties related to the grf file
Definition: industrytype.h:164
CHECK_REFINERY
Industry should be positioned near edge of the map.
Definition: industrytype.h:43
IndustrySpec::GetConstructionCost
Money GetConstructionCost() const
Get the cost for constructing this industry.
Definition: industry_cmd.cpp:2795
IndustryTileTable
Definition: industrytype.h:93
IndustrySpec::behaviour
IndustryBehaviour behaviour
How this industry will behave, and how others entities can use it.
Definition: industrytype.h:120
IndustrySpec::grf_prop
GRFFileProps grf_prop
properties related to the grf file
Definition: industrytype.h:136
IndustrySpec::appear_ingame
byte appear_ingame[NUM_LANDSCAPE]
Probability of appearance in game.
Definition: industrytype.h:128
INDUSTRYBEH_CUT_TREES
cuts trees and produce first output cargo from them (lumber mill)
Definition: industrytype.h:65
IndustryCleanupType
IndustryCleanupType
Definition: industrytype.h:23
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
_sorted_industry_types
IndustryType _sorted_industry_types[NUM_INDUSTRYTYPES]
Industry types sorted by name.
Definition: industry_gui.cpp:160
CHECK_PLANTATION
Industry should NOT be in the desert.
Definition: industrytype.h:45
CHECK_LUMBERMILL
Industry should be in the rain forest.
Definition: industrytype.h:47
IndustrySpec::input_cargo_multiplier
uint16 input_cargo_multiplier[3][2]
Input cargo multipliers (multiply amount of incoming cargo for the produced cargoes) ...
Definition: industrytype.h:117
IndustryTileSpec::callback_mask
uint8 callback_mask
Bitmask of industry tile callbacks that have to be called.
Definition: industrytype.h:160
GRFFileProps::override
uint16 override
id of the entity been replaced by
Definition: newgrf_commons.h:333
TileIndexDiffC
A pair-construct of a TileIndexDiff.
Definition: map_type.h:58
IndustrySpec::num_table
byte num_table
Number of elements in the table.
Definition: industrytype.h:103
IndustryTileSpecialFlags
IndustryTileSpecialFlags
Flags for miscellaneous industry tile specialities.
Definition: industrytype.h:87
INDUSTRYBEH_BUILT_ONWATER
is built on water (oil rig)
Definition: industrytype.h:66
IndustrySpec::minimal_cargo
byte minimal_cargo
minimum amount of cargo transported to the stations.
Definition: industrytype.h:115
IndustrySpec::cost_multiplier
uint8 cost_multiplier
Base construction cost multiplier.
Definition: industrytype.h:104
IndustrySpec::appear_creation
byte appear_creation[NUM_LANDSCAPE]
Probability of appearance during map creation.
Definition: industrytype.h:129
landscape_type.h
Types related to the landscape.
IndustryTileSpec::animation
AnimationInfo animation
Information about the animation (is it looping, how many loops etc)
Definition: industrytype.h:161
NUM_INDUSTRYTYPES
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
IndustrySpec::closure_text
StringID closure_text
Message appearing when the industry closes.
Definition: industrytype.h:124
IndustryTileSpec::anim_next
byte anim_next
Next frame in an animation.
Definition: industrytype.h:153
CheckProc
CheckProc
Available procedures to check whether an industry may build at a given location.
Definition: industrytype.h:40
Slope
Slope
Enumeration for the slope-type.
Definition: slope_type.h:50
SortIndustryTypes
void SortIndustryTypes()
Initialize the list of sorted industry types.
Definition: industry_gui.cpp:182
IndustrySpec::climate_availability
byte climate_availability
Bitmask, giving landscape enums as bit position.
Definition: industrytype.h:119
IndustryBehaviour
IndustryBehaviour
Various industry behaviours mostly to represent original TTD specialities.
Definition: industrytype.h:62
INDTILE_SPECIAL_NEXTFRAME_RANDOMBITS
Callback 0x26 needs random bits.
Definition: industrytype.h:89
IndustrySpec::conflicting
IndustryType conflicting[3]
Industries this industry cannot be close to.
Definition: industrytype.h:107
INDUSTRYBEH_PLANT_ON_BUILT
Fields are planted around when built (all farms)
Definition: industrytype.h:70
INDUSTRYBEH_CANCLOSE_LASTINSTANCE
Allow closing down the last instance of this type.
Definition: industrytype.h:82
newgrf_commons.h
This file simplyfies and embeds a common mechanism of loading/saving and mapping of grf entities...
IndustrySpec::accepts_cargo
CargoID accepts_cargo[3]
3 accepted cargoes.
Definition: industrytype.h:116
AnimationInfo
Information about animation.
Definition: newgrf_animation_type.h:20
IndustrySpec::number_of_sounds
uint8 number_of_sounds
Number of sounds available in the sounds array.
Definition: industrytype.h:130
IndustrySpec::station_name
StringID station_name
Default name for nearby station.
Definition: industrytype.h:127
INDUSTRYLIFE_EXTRACTIVE
Like mines.
Definition: industrytype.h:31
IndustrySpec::production_up_text
StringID production_up_text
Message appearing when the industry&#39;s production is increasing.
Definition: industrytype.h:125
IndustrySpec::check_proc
byte check_proc
Index to a procedure to check for conflicting circumstances.
Definition: industrytype.h:108
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:22
CLEAN_TILELAYOUT
Free the dynamically allocated tile layout structure.
Definition: industrytype.h:25
IndustryTileSpec
Defines the data structure of each individual tile of an industry.
Definition: industrytype.h:148
INDUSTRYBEH_TOWN1200_MORE
can only be built in towns larger than 1200 inhabitants (temperate bank)
Definition: industrytype.h:67
CHECK_BUBBLEGEN
Industry should be in low land.
Definition: industrytype.h:48
INDUSTRYLIFE_ORGANIC
Like forests.
Definition: industrytype.h:32
INDUSTRYBEH_PRODCALLBACK_RANDOM
Production callback needs random bits in var 10.
Definition: industrytype.h:80
INDUSTRYBEH_BEFORE_1950
can only be built before 1950 (oil wells)
Definition: industrytype.h:72
OverflowSafeInt< int64, INT64_MAX, INT64_MIN >
IndustryTileSpec::anim_state
bool anim_state
When true, the tile has to be drawn using the animation state instead of the construction state...
Definition: industrytype.h:158