industrytype.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef INDUSTRYTYPE_H
00013 #define INDUSTRYTYPE_H
00014
00015 #include "economy_type.h"
00016 #include "map_type.h"
00017 #include "slope_type.h"
00018 #include "industry_type.h"
00019 #include "landscape_type.h"
00020 #include "strings_type.h"
00021 #include "cargo_type.h"
00022
00023 enum {
00024 CLEAN_RANDOMSOUNDS,
00025 CLEAN_TILELAYOUT,
00026 };
00027
00029 enum IndustryLifeType {
00030 INDUSTRYLIFE_BLACK_HOLE = 0,
00031 INDUSTRYLIFE_EXTRACTIVE = 1 << 0,
00032 INDUSTRYLIFE_ORGANIC = 1 << 1,
00033 INDUSTRYLIFE_PROCESSING = 1 << 2,
00034 };
00035
00039 enum CheckProc {
00040 CHECK_NOTHING,
00041 CHECK_FOREST,
00042 CHECK_REFINERY,
00043 CHECK_FARM,
00044 CHECK_PLANTATION,
00045 CHECK_WATER,
00046 CHECK_LUMBERMILL,
00047 CHECK_BUBBLEGEN,
00048 CHECK_OIL_RIG,
00049 CHECK_END,
00050 };
00051
00053 enum IndustryConstructionType {
00054 ICT_UNKNOWN,
00055 ICT_NORMAL_GAMEPLAY,
00056 ICT_MAP_GENERATION,
00057 ICT_SCENARIO_EDITOR
00058 };
00059
00061 enum IndustryBehaviour {
00062 INDUSTRYBEH_NONE = 0,
00063 INDUSTRYBEH_PLANT_FIELDS = 1 << 0,
00064 INDUSTRYBEH_CUT_TREES = 1 << 1,
00065 INDUSTRYBEH_BUILT_ONWATER = 1 << 2,
00066 INDUSTRYBEH_TOWN1200_MORE = 1 << 3,
00067 INDUSTRYBEH_ONLY_INTOWN = 1 << 4,
00068 INDUSTRYBEH_ONLY_NEARTOWN = 1 << 5,
00069 INDUSTRYBEH_PLANT_ON_BUILT = 1 << 6,
00070 INDUSTRYBEH_DONT_INCR_PROD = 1 << 7,
00071 INDUSTRYBEH_BEFORE_1950 = 1 << 8,
00072 INDUSTRYBEH_AFTER_1960 = 1 << 9,
00073 INDUSTRYBEH_AI_AIRSHIP_ROUTES = 1 << 10,
00074 INDUSTRYBEH_AIRPLANE_ATTACKS = 1 << 11,
00075 INDUSTRYBEH_CHOPPER_ATTACKS = 1 << 12,
00076 INDUSTRYBEH_CAN_SUBSIDENCE = 1 << 13,
00077
00078 INDUSTRYBEH_PROD_MULTI_HNDLING = 1 << 14,
00079 INDUSTRYBEH_PRODCALLBACK_RANDOM = 1 << 15,
00080 INDUSTRYBEH_NOBUILT_MAPCREATION = 1 << 16,
00081 INDUSTRYBEH_CANCLOSE_LASTINSTANCE = 1 << 17,
00082 };
00083 DECLARE_ENUM_AS_BIT_SET(IndustryBehaviour);
00084
00086 enum IndustryTileSpecialFlags {
00087 INDTILE_SPECIAL_NONE = 0,
00088 INDTILE_SPECIAL_NEXTFRAME_RANDOMBITS = 1 << 0,
00089 };
00090 DECLARE_ENUM_AS_BIT_SET(IndustryTileSpecialFlags);
00091
00092 struct IndustryTileTable {
00093 TileIndexDiffC ti;
00094 IndustryGfx gfx;
00095 };
00096
00098 struct GRFFileProps {
00099 uint16 subst_id;
00100 uint16 local_id;
00101 struct SpriteGroup *spritegroup;
00102 const struct GRFFile *grffile;
00103 uint16 override;
00104 };
00105
00109 struct IndustrySpec {
00110 const IndustryTileTable * const *table;
00111 byte num_table;
00112 uint8 cost_multiplier;
00113 uint32 removal_cost_multiplier;
00114 uint32 prospecting_chance;
00115 IndustryType conflicting[3];
00116 byte check_proc;
00117 CargoID produced_cargo[2];
00118 byte production_rate[2];
00119 byte minimal_cargo;
00120
00121 CargoID accepts_cargo[3];
00122 uint16 input_cargo_multiplier[3][2];
00123 IndustryLifeType life_type;
00124 byte climate_availability;
00125 IndustryBehaviour behaviour;
00126 byte map_colour;
00127 StringID name;
00128 StringID new_industry_text;
00129 StringID closure_text;
00130 StringID production_up_text;
00131 StringID production_down_text;
00132 StringID station_name;
00133 byte appear_ingame[NUM_LANDSCAPE];
00134 byte appear_creation[NUM_LANDSCAPE];
00135 uint8 number_of_sounds;
00136 const uint8 *random_sounds;
00137
00138 uint16 callback_mask;
00139 uint8 cleanup_flag;
00140 bool enabled;
00141 struct GRFFileProps grf_prop;
00142
00147 bool IsRawIndustry() const;
00148
00153 Money GetConstructionCost() const;
00154
00161 Money GetRemovalCost() const;
00162 };
00163
00167 struct IndustryTileSpec {
00168 CargoID accepts_cargo[3];
00169 uint8 acceptance[3];
00170 Slope slopes_refused;
00171 byte anim_production;
00172 byte anim_next;
00173 bool anim_state;
00174
00175
00176 uint8 callback_mask;
00177 uint16 animation_info;
00178 uint8 animation_speed;
00179 uint8 animation_triggers;
00180 IndustryTileSpecialFlags special_flags;
00181 bool enabled;
00182 struct GRFFileProps grf_prop;
00183 };
00184
00185
00186 const IndustrySpec *GetIndustrySpec(IndustryType thistype);
00187 const IndustryTileSpec *GetIndustryTileSpec(IndustryGfx gfx);
00188 void ResetIndustries();
00189
00190
00191 extern IndustrySpec _industry_specs[NUM_INDUSTRYTYPES];
00192 extern IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES];
00193
00199 static inline IndustryGfx GetTranslatedIndustryTileID(IndustryGfx gfx)
00200 {
00201
00202
00203
00204
00205
00206 if (gfx != 0xFF) {
00207 assert(gfx < INVALID_INDUSTRYTILE);
00208 const IndustryTileSpec *it = &_industry_tile_specs[gfx];
00209 return it->grf_prop.override == INVALID_INDUSTRYTILE ? gfx : it->grf_prop.override;
00210 } else {
00211 return gfx;
00212 }
00213 }
00214
00215 extern uint16 _industry_counts[NUM_INDUSTRYTYPES];
00216
00220 static inline void IncIndustryTypeCount(IndustryType type)
00221 {
00222 assert(type < INVALID_INDUSTRYTYPE);
00223 _industry_counts[type]++;
00224 }
00225
00229 static inline void DecIndustryTypeCount(IndustryType type)
00230 {
00231 assert(type < INVALID_INDUSTRYTYPE);
00232 _industry_counts[type]--;
00233 }
00234
00238 static inline uint8 GetIndustryTypeCount(IndustryType type)
00239 {
00240 assert(type < INVALID_INDUSTRYTYPE);
00241 return min(_industry_counts[type], 0xFF);
00242 }
00243
00246 static inline void ResetIndustryCounts()
00247 {
00248 memset(&_industry_counts, 0, sizeof(_industry_counts));
00249 }
00250
00251 static const uint8 IT_INVALID = 255;
00252
00253 #endif