(svn r4347) CodeChange : Renamed IndustryType to IndustryLifeType. Cleanup step toward bringing accessors [G|S]etIndustrype

This commit is contained in:
belugas 2006-04-10 16:20:47 +00:00
parent a972760294
commit 8166a53179
2 changed files with 52 additions and 47 deletions

View File

@ -65,6 +65,8 @@ VARDEF int _total_industries; // For the AI: the amount of industries active
VARDEF uint16 *_industry_sort; VARDEF uint16 *_industry_sort;
VARDEF bool _industry_sort_dirty; VARDEF bool _industry_sort_dirty;
typedef uint8 IndustryType;
void DeleteIndustry(Industry *is); void DeleteIndustry(Industry *is);
enum { enum {
@ -107,4 +109,10 @@ enum {
IT_SUGAR_MINE = 36, IT_SUGAR_MINE = 36,
}; };
typedef enum IndustryLifeTypes {
INDUSTRYLIFE_NOT_CLOSABLE, ///< Industry can never close
INDUSTRYLIFE_PRODUCTION, ///< Industry can close and change of production
INDUSTRYLIFE_CLOSABLE, ///< Industry can only close (no production change)
} IndustryLifeType;
#endif /* INDUSTRY_H */ #endif /* INDUSTRY_H */

View File

@ -91,51 +91,46 @@ typedef struct IndustrySpec {
#include "table/industry_land.h" #include "table/industry_land.h"
#include "table/build_industry.h" #include "table/build_industry.h"
typedef enum IndustryType {
INDUSTRY_NOT_CLOSABLE, ///< Industry can never close
INDUSTRY_PRODUCTION, ///< Industry can close and change of production
INDUSTRY_CLOSABLE, ///< Industry can only close (no production change)
} IndustryType;
static const IndustryType _industry_close_mode[37] = { static const IndustryType _industry_close_mode[37] = {
/* COAL_MINE */ INDUSTRY_PRODUCTION, /* COAL_MINE */ INDUSTRYLIFE_PRODUCTION,
/* POWER_STATION */ INDUSTRY_NOT_CLOSABLE, /* POWER_STATION */ INDUSTRYLIFE_NOT_CLOSABLE,
/* SAWMILL */ INDUSTRY_CLOSABLE, /* SAWMILL */ INDUSTRYLIFE_CLOSABLE,
/* FOREST */ INDUSTRY_PRODUCTION, /* FOREST */ INDUSTRYLIFE_PRODUCTION,
/* OIL_REFINERY */ INDUSTRY_CLOSABLE, /* OIL_REFINERY */ INDUSTRYLIFE_CLOSABLE,
/* OIL_RIG */ INDUSTRY_PRODUCTION, /* OIL_RIG */ INDUSTRYLIFE_PRODUCTION,
/* FACTORY */ INDUSTRY_CLOSABLE, /* FACTORY */ INDUSTRYLIFE_CLOSABLE,
/* PRINTING_WORKS */ INDUSTRY_CLOSABLE, /* PRINTING_WORKS */ INDUSTRYLIFE_CLOSABLE,
/* STEEL_MILL */ INDUSTRY_CLOSABLE, /* STEEL_MILL */ INDUSTRYLIFE_CLOSABLE,
/* FARM */ INDUSTRY_PRODUCTION, /* FARM */ INDUSTRYLIFE_PRODUCTION,
/* COPPER_MINE */ INDUSTRY_PRODUCTION, /* COPPER_MINE */ INDUSTRYLIFE_PRODUCTION,
/* OIL_WELL */ INDUSTRY_PRODUCTION, /* OIL_WELL */ INDUSTRYLIFE_PRODUCTION,
/* BANK */ INDUSTRY_NOT_CLOSABLE, /* BANK */ INDUSTRYLIFE_NOT_CLOSABLE,
/* FOOD_PROCESS */ INDUSTRY_CLOSABLE, /* FOOD_PROCESS */ INDUSTRYLIFE_CLOSABLE,
/* PAPER_MILL */ INDUSTRY_CLOSABLE, /* PAPER_MILL */ INDUSTRYLIFE_CLOSABLE,
/* GOLD_MINE */ INDUSTRY_PRODUCTION, /* GOLD_MINE */ INDUSTRYLIFE_PRODUCTION,
/* BANK_2, */ INDUSTRY_NOT_CLOSABLE, /* BANK_2, */ INDUSTRYLIFE_NOT_CLOSABLE,
/* DIAMOND_MINE */ INDUSTRY_PRODUCTION, /* DIAMOND_MINE */ INDUSTRYLIFE_PRODUCTION,
/* IRON_MINE */ INDUSTRY_PRODUCTION, /* IRON_MINE */ INDUSTRYLIFE_PRODUCTION,
/* FRUIT_PLANTATION */ INDUSTRY_PRODUCTION, /* FRUIT_PLANTATION */ INDUSTRYLIFE_PRODUCTION,
/* RUBBER_PLANTATION */ INDUSTRY_PRODUCTION, /* RUBBER_PLANTATION */ INDUSTRYLIFE_PRODUCTION,
/* WATER_SUPPLY */ INDUSTRY_PRODUCTION, /* WATER_SUPPLY */ INDUSTRYLIFE_PRODUCTION,
/* WATER_TOWER */ INDUSTRY_NOT_CLOSABLE, /* WATER_TOWER */ INDUSTRYLIFE_NOT_CLOSABLE,
/* FACTORY_2 */ INDUSTRY_CLOSABLE, /* FACTORY_2 */ INDUSTRYLIFE_CLOSABLE,
/* FARM_2 */ INDUSTRY_PRODUCTION, /* FARM_2 */ INDUSTRYLIFE_PRODUCTION,
/* LUMBER_MILL */ INDUSTRY_CLOSABLE, /* LUMBER_MILL */ INDUSTRYLIFE_CLOSABLE,
/* COTTON_CANDY */ INDUSTRY_PRODUCTION, /* COTTON_CANDY */ INDUSTRYLIFE_PRODUCTION,
/* CANDY_FACTORY */ INDUSTRY_CLOSABLE, /* CANDY_FACTORY */ INDUSTRYLIFE_CLOSABLE,
/* BATTERY_FARM */ INDUSTRY_PRODUCTION, /* BATTERY_FARM */ INDUSTRYLIFE_PRODUCTION,
/* COLA_WELLS */ INDUSTRY_PRODUCTION, /* COLA_WELLS */ INDUSTRYLIFE_PRODUCTION,
/* TOY_SHOP */ INDUSTRY_NOT_CLOSABLE, /* TOY_SHOP */ INDUSTRYLIFE_NOT_CLOSABLE,
/* TOY_FACTORY */ INDUSTRY_CLOSABLE, /* TOY_FACTORY */ INDUSTRYLIFE_CLOSABLE,
/* PLASTIC_FOUNTAINS */ INDUSTRY_PRODUCTION, /* PLASTIC_FOUNTAINS */ INDUSTRYLIFE_PRODUCTION,
/* FIZZY_DRINK_FACTORY */INDUSTRY_CLOSABLE, /* FIZZY_DRINK_FACTORY */INDUSTRYLIFE_CLOSABLE,
/* BUBBLE_GENERATOR */ INDUSTRY_PRODUCTION, /* BUBBLE_GENERATOR */ INDUSTRYLIFE_PRODUCTION,
/* TOFFEE_QUARRY */ INDUSTRY_PRODUCTION, /* TOFFEE_QUARRY */ INDUSTRYLIFE_PRODUCTION,
/* SUGAR_MINE */ INDUSTRY_PRODUCTION /* SUGAR_MINE */ INDUSTRYLIFE_PRODUCTION
}; };
static const StringID _industry_prod_up_strings[] = { static const StringID _industry_prod_up_strings[] = {
@ -1648,16 +1643,17 @@ void GenerateIndustries(void)
} while ( (b+=2)[0] != 0); } while ( (b+=2)[0] != 0);
} }
/* Change industry production or do closure */
static void ExtChangeIndustryProduction(Industry *i) static void ExtChangeIndustryProduction(Industry *i)
{ {
bool closeit = true; bool closeit = true;
int j; int j;
switch (_industry_close_mode[i->type]) { switch (_industry_close_mode[i->type]) {
case INDUSTRY_NOT_CLOSABLE: case INDUSTRYLIFE_NOT_CLOSABLE:
return; return;
case INDUSTRY_CLOSABLE: case INDUSTRYLIFE_CLOSABLE:
if ((byte)(_cur_year - i->last_prod_year) < 5 || !CHANCE16(1, 180)) if ((byte)(_cur_year - i->last_prod_year) < 5 || !CHANCE16(1, 180))
closeit = false; closeit = false;
break; break;
@ -1701,6 +1697,7 @@ static void ExtChangeIndustryProduction(Industry *i)
break; break;
} }
/* If industry will be closed down, show this */
if (closeit) { if (closeit) {
i->prod_level = 0; i->prod_level = 0;
SetDParam(0, i->index); SetDParam(0, i->index);
@ -1799,10 +1796,10 @@ static void ChangeIndustryProduction(Industry *i)
int type = i->type; int type = i->type;
switch (_industry_close_mode[type]) { switch (_industry_close_mode[type]) {
case INDUSTRY_NOT_CLOSABLE: case INDUSTRYLIFE_NOT_CLOSABLE:
return; return;
case INDUSTRY_PRODUCTION: case INDUSTRYLIFE_PRODUCTION:
/* decrease or increase */ /* decrease or increase */
if (type == IT_OIL_WELL && _opt.landscape == LT_NORMAL) if (type == IT_OIL_WELL && _opt.landscape == LT_NORMAL)
only_decrease = true; only_decrease = true;
@ -1844,7 +1841,7 @@ static void ChangeIndustryProduction(Industry *i)
} }
break; break;
case INDUSTRY_CLOSABLE: case INDUSTRYLIFE_CLOSABLE:
/* maybe close */ /* maybe close */
if ( (byte)(_cur_year - i->last_prod_year) >= 5 && CHANCE16(1,2)) { if ( (byte)(_cur_year - i->last_prod_year) >= 5 && CHANCE16(1,2)) {
i->prod_level = 0; i->prod_level = 0;