industry.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef INDUSTRY_H
00013 #define INDUSTRY_H
00014
00015 #include "core/pool_type.hpp"
00016 #include "newgrf_storage.h"
00017 #include "subsidy_type.h"
00018 #include "industry_map.h"
00019 #include "tilearea_type.h"
00020
00021
00022 typedef Pool<Industry, IndustryID, 64, 64000> IndustryPool;
00023 extern IndustryPool _industry_pool;
00024
00028 struct Industry : IndustryPool::PoolItem<&_industry_pool> {
00029 typedef PersistentStorageArray<int32, 16> PersistentStorage;
00030
00031 TileArea location;
00032 const Town *town;
00033 CargoID produced_cargo[2];
00034 uint16 produced_cargo_waiting[2];
00035 uint16 incoming_cargo_waiting[3];
00036 byte production_rate[2];
00037 byte prod_level;
00038 CargoID accepts_cargo[3];
00039 uint16 this_month_production[2];
00040 uint16 this_month_transported[2];
00041 byte last_month_pct_transported[2];
00042 uint16 last_month_production[2];
00043 uint16 last_month_transported[2];
00044 uint16 counter;
00045
00046 IndustryType type;
00047 OwnerByte owner;
00048 byte random_colour;
00049 Year last_prod_year;
00050 byte was_cargo_delivered;
00051
00052 PartOfSubsidyByte part_of_subsidy;
00053
00054 OwnerByte founder;
00055 Date construction_date;
00056 uint8 construction_type;
00057 Date last_cargo_accepted_at;
00058 byte selected_layout;
00059
00060 byte random_triggers;
00061 uint16 random;
00062
00063 PersistentStorage psa;
00064
00065 Industry(TileIndex tile = INVALID_TILE) : location(tile, 0, 0) {}
00066 ~Industry();
00067
00074 static FORCEINLINE Industry *GetByTile(TileIndex tile)
00075 {
00076 return Industry::Get(GetIndustryIndex(tile));
00077 }
00078
00079 static Industry *GetRandom();
00080 static void PostDestructor(size_t index);
00081 };
00082
00083 void PlantRandomFarmField(const Industry *i);
00084
00085 void ReleaseDisastersTargetingIndustry(IndustryID);
00086
00087
00088 void SetIndustryDailyChanges();
00089
00090 #define FOR_ALL_INDUSTRIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Industry, industry_index, var, start)
00091 #define FOR_ALL_INDUSTRIES(var) FOR_ALL_INDUSTRIES_FROM(var, 0)
00092
00093 #endif