|
@@ -83,16 +83,19 @@ enum IndustyBehaviour {
|
|
|
INDUSTRYBEH_CAN_SUBSIDENCE = 1 << 13, ///< can cause a subsidence (coal mine, shaft that collapses)
|
|
|
};
|
|
|
|
|
|
|
|
|
DECLARE_ENUM_AS_BIT_SET(IndustyBehaviour);
|
|
|
|
|
|
struct Industry;
|
|
|
DECLARE_OLD_POOL(Industry, Industry, 3, 8000)
|
|
|
|
|
|
/**
|
|
|
* Defines the internal data of a functionnal industry
|
|
|
*/
|
|
|
struct Industry {
|
|
|
struct Industry : PoolItem<Industry, IndustryID, &_Industry_pool> {
|
|
|
TileIndex xy; ///< coordinates of the primary tile the industry is built one
|
|
|
byte width;
|
|
|
byte height;
|
|
|
const Town *town; ///< Nearest town
|
|
|
uint16 produced_cargo_waiting[2]; ///< amount of cargo produced per cargo
|
|
|
uint16 incoming_cargo_waiting[3]; ///< incoming cargo waiting to be processed
|
|
@@ -108,18 +111,21 @@ struct Industry {
|
|
|
IndustryType type; ///< type of industry.
|
|
|
OwnerByte owner; ///< owner of the industry. Which SHOULD always be (imho) OWNER_NONE
|
|
|
byte random_color; ///< randomized colour of the industry, for display purpose
|
|
|
Year last_prod_year; ///< last year of production
|
|
|
byte was_cargo_delivered; ///< flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry
|
|
|
|
|
|
IndustryID index; ///< index of the industry in the pool of industries
|
|
|
|
|
|
OwnerByte founder; ///< Founder of the industry
|
|
|
Date construction_date; ///< Date of the construction of the industry
|
|
|
uint8 construction_type; ///< Way the industry was constructed (@see IndustryConstructionType)
|
|
|
Date last_cargo_accepted_at; ///< Last day cargo was accepted by this industry
|
|
|
|
|
|
Industry(TileIndex tile = 0) : xy(tile) {}
|
|
|
~Industry();
|
|
|
|
|
|
bool IsValid() const { return this->xy != 0; }
|
|
|
};
|
|
|
|
|
|
struct IndustryTileTable {
|
|
|
TileIndexDiffC ti;
|
|
|
IndustryGfx gfx;
|
|
|
};
|
|
@@ -213,32 +219,20 @@ void PlantRandomFarmField(const Industry
|
|
|
extern IndustrySpec _industry_specs[NUM_INDUSTRYTYPES];
|
|
|
extern IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES];
|
|
|
|
|
|
/* smallmap_gui.cpp */
|
|
|
void BuildIndustriesLegend();
|
|
|
|
|
|
DECLARE_OLD_POOL(Industry, Industry, 3, 8000)
|
|
|
|
|
|
/**
|
|
|
* Check if an Industry really exists.
|
|
|
* @param industry to check
|
|
|
* @return true if position is a valid one
|
|
|
*/
|
|
|
static inline bool IsValidIndustry(const Industry *industry)
|
|
|
{
|
|
|
return industry->xy != 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Check if an Industry exists whithin the pool of industries
|
|
|
* @param index of the desired industry
|
|
|
* @return true if it is inside the pool
|
|
|
*/
|
|
|
static inline bool IsValidIndustryID(IndustryID index)
|
|
|
{
|
|
|
return index < GetIndustryPoolSize() && IsValidIndustry(GetIndustry(index));
|
|
|
return index < GetIndustryPoolSize() && GetIndustry(index)->IsValid();
|
|
|
}
|
|
|
|
|
|
|
|
|
static inline IndustryID GetMaxIndustryIndex()
|
|
|
{
|
|
|
/* TODO - This isn't the real content of the function, but
|
|
@@ -315,21 +309,13 @@ static inline Industry *GetRandomIndustr
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return GetIndustry(index);
|
|
|
}
|
|
|
|
|
|
void DestroyIndustry(Industry *i);
|
|
|
|
|
|
static inline void DeleteIndustry(Industry *i)
|
|
|
{
|
|
|
DestroyIndustry(i);
|
|
|
i->xy = 0;
|
|
|
}
|
|
|
|
|
|
#define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = GetIndustry(start); i != NULL; i = (i->index + 1U < GetIndustryPoolSize()) ? GetIndustry(i->index + 1U) : NULL) if (IsValidIndustry(i))
|
|
|
#define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = GetIndustry(start); i != NULL; i = (i->index + 1U < GetIndustryPoolSize()) ? GetIndustry(i->index + 1U) : NULL) if (i->IsValid())
|
|
|
#define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0)
|
|
|
|
|
|
extern const Industry **_industry_sort;
|
|
|
extern bool _industry_sort_dirty;
|
|
|
|
|
|
static const uint8 IT_INVALID = 255;
|