File diff r4923:676aae12fd77 → r4924:047938e059a9
industry_cmd.c
Show inline comments
 
@@ -50,52 +50,12 @@ static void IndustryPoolNewBlock(uint st
 
	for (i = GetIndustry(start_item); i != NULL; i = (i->index + 1 < GetIndustryPoolSize()) ? GetIndustry(i->index + 1) : NULL) i->index = start_item++;
 
}
 

	
 
/* Initialize the industry-pool */
 
MemoryPool _industry_pool = { "Industry", INDUSTRY_POOL_MAX_BLOCKS, INDUSTRY_POOL_BLOCK_SIZE_BITS, sizeof(Industry), &IndustryPoolNewBlock, NULL, 0, 0, NULL };
 

	
 
static const IndustryType _industry_close_mode[IT_END] = {
 
	/* COAL_MINE */          INDUSTRYLIFE_PRODUCTION,
 
	/* POWER_STATION */      INDUSTRYLIFE_NOT_CLOSABLE,
 
	/* SAWMILL */            INDUSTRYLIFE_CLOSABLE,
 
	/* FOREST */             INDUSTRYLIFE_PRODUCTION,
 
	/* OIL_REFINERY */       INDUSTRYLIFE_CLOSABLE,
 
	/* OIL_RIG */            INDUSTRYLIFE_PRODUCTION,
 
	/* FACTORY */            INDUSTRYLIFE_CLOSABLE,
 
	/* PRINTING_WORKS */     INDUSTRYLIFE_CLOSABLE,
 
	/* STEEL_MILL */         INDUSTRYLIFE_CLOSABLE,
 
	/* FARM */               INDUSTRYLIFE_PRODUCTION,
 
	/* COPPER_MINE */        INDUSTRYLIFE_PRODUCTION,
 
	/* OIL_WELL */           INDUSTRYLIFE_PRODUCTION,
 
	/* BANK */               INDUSTRYLIFE_NOT_CLOSABLE,
 
	/* FOOD_PROCESS */       INDUSTRYLIFE_CLOSABLE,
 
	/* PAPER_MILL */         INDUSTRYLIFE_CLOSABLE,
 
	/* GOLD_MINE */          INDUSTRYLIFE_PRODUCTION,
 
	/* BANK_2,  */           INDUSTRYLIFE_NOT_CLOSABLE,
 
	/* DIAMOND_MINE */       INDUSTRYLIFE_PRODUCTION,
 
	/* IRON_MINE */          INDUSTRYLIFE_PRODUCTION,
 
	/* FRUIT_PLANTATION */   INDUSTRYLIFE_PRODUCTION,
 
	/* RUBBER_PLANTATION */  INDUSTRYLIFE_PRODUCTION,
 
	/* WATER_SUPPLY */       INDUSTRYLIFE_PRODUCTION,
 
	/* WATER_TOWER */        INDUSTRYLIFE_NOT_CLOSABLE,
 
	/* FACTORY_2 */          INDUSTRYLIFE_CLOSABLE,
 
	/* FARM_2 */             INDUSTRYLIFE_PRODUCTION,
 
	/* LUMBER_MILL */        INDUSTRYLIFE_CLOSABLE,
 
	/* COTTON_CANDY */       INDUSTRYLIFE_PRODUCTION,
 
	/* CANDY_FACTORY */      INDUSTRYLIFE_CLOSABLE,
 
	/* BATTERY_FARM */       INDUSTRYLIFE_PRODUCTION,
 
	/* COLA_WELLS */         INDUSTRYLIFE_PRODUCTION,
 
	/* TOY_SHOP */           INDUSTRYLIFE_NOT_CLOSABLE,
 
	/* TOY_FACTORY */        INDUSTRYLIFE_CLOSABLE,
 
	/* PLASTIC_FOUNTAINS */  INDUSTRYLIFE_PRODUCTION,
 
	/* FIZZY_DRINK_FACTORY */INDUSTRYLIFE_CLOSABLE,
 
	/* BUBBLE_GENERATOR */   INDUSTRYLIFE_PRODUCTION,
 
	/* TOFFEE_QUARRY */      INDUSTRYLIFE_PRODUCTION,
 
	/* SUGAR_MINE */         INDUSTRYLIFE_PRODUCTION
 
};
 

	
 
/**
 
 * Retrieve the type for this industry.  Although it is accessed by a tile,
 
 * it will return the general type of industry, and not the sprite index
 
 * as would do GetIndustryGfx.
 
 * The same information can be accessed by looking at Industry->type
 
 * @param tile that is queried
 
@@ -1660,13 +1620,13 @@ void GenerateIndustries(void)
 
static void ExtChangeIndustryProduction(Industry *i)
 
{
 
	bool closeit = true;
 
	int j;
 
	const IndustrySpec *indspec = GetIndustrySpec(i->type);
 

	
 
	switch (_industry_close_mode[i->type]) {
 
	switch (indspec->life_type) {
 
		case INDUSTRYLIFE_NOT_CLOSABLE:
 
			return;
 

	
 
		case INDUSTRYLIFE_CLOSABLE:
 
			if ((byte)(_cur_year - i->last_prod_year) < 5 || !CHANCE16(1, 180))
 
				closeit = false;
 
@@ -1807,13 +1767,13 @@ static void ChangeIndustryProduction(Ind
 
{
 
	bool only_decrease = false;
 
	StringID str = STR_NULL;
 
	int type = i->type;
 
	const IndustrySpec *indspec = GetIndustrySpec(type);
 

	
 
	switch (_industry_close_mode[type]) {
 
	switch (indspec->life_type) {
 
		case INDUSTRYLIFE_NOT_CLOSABLE:
 
			return;
 

	
 
		case INDUSTRYLIFE_PRODUCTION:
 
			/* decrease or increase */
 
			if (type == IT_OIL_WELL && _opt.landscape == LT_NORMAL)