src/industry_cmd.cpp
changeset 7834 00abd0f1ea03
parent 7833 f3a0c16d84ea
child 7886 b02aa3532d1d
equal deleted inserted replaced
7833:f3a0c16d84ea 7834:00abd0f1ea03
  1610 	const IndustrySpec *indspec = GetIndustrySpec(type);
  1610 	const IndustrySpec *indspec = GetIndustrySpec(type);
  1611 
  1611 
  1612 	return CreateNewIndustryHelper(tile, type, DC_EXEC, indspec, RandomRange(indspec->num_table));
  1612 	return CreateNewIndustryHelper(tile, type, DC_EXEC, indspec, RandomRange(indspec->num_table));
  1613 }
  1613 }
  1614 
  1614 
  1615 static const byte _numof_industry_table[5][11] = {
  1615 enum {
       
  1616 	NB_NUMOFINDUSTRY = 11,
       
  1617 	NB_DIFFICULTY_LEVEL = 5,
       
  1618 };
       
  1619 
       
  1620 static const byte _numof_industry_table[NB_DIFFICULTY_LEVEL][NB_NUMOFINDUSTRY] = {
  1616 	/* difficulty settings for number of industries */
  1621 	/* difficulty settings for number of industries */
  1617 	{0, 0, 0, 0, 0, 0, 0, 0,  0,  0,  0},   //none
  1622 	{0, 0, 0, 0, 0, 0, 0, 0,  0,  0,  0},   //none
  1618 	{0, 1, 1, 1, 1, 1, 1, 1,  1,  1,  1},   //very low
  1623 	{0, 1, 1, 1, 1, 1, 1, 1,  1,  1,  1},   //very low
  1619 	{0, 1, 1, 1, 2, 2, 3, 3,  4,  4,  5},   //low
  1624 	{0, 1, 1, 1, 2, 2, 3, 3,  4,  4,  5},   //low
  1620 	{0, 1, 2, 3, 4, 5, 6, 7,  8,  9, 10},   //normal
  1625 	{0, 1, 2, 3, 4, 5, 6, 7,  8,  9, 10},   //normal
  1625  * of random industries during game creation
  1630  * of random industries during game creation
  1626  * @param type IndustryType of the desired industry
  1631  * @param type IndustryType of the desired industry
  1627  * @param amount of industries that need to be built */
  1632  * @param amount of industries that need to be built */
  1628 static void PlaceInitialIndustry(IndustryType type, int amount)
  1633 static void PlaceInitialIndustry(IndustryType type, int amount)
  1629 {
  1634 {
  1630 	int num = _numof_industry_table[_opt.diff.number_industries][amount];
  1635 	/* We need to bypass the amount given in parameter if it exceeds the maximum dimension of the
       
  1636 	 * _numof_industry_table.  newgrf can specify a big amount */
       
  1637 	int num = (amount > NB_NUMOFINDUSTRY) ? amount : _numof_industry_table[_opt.diff.number_industries][amount];
  1631 	const IndustrySpec *ind_spc = GetIndustrySpec(type);
  1638 	const IndustrySpec *ind_spc = GetIndustrySpec(type);
  1632 
  1639 
  1633 	/* These are always placed next to the coastline, so we scale by the perimeter instead. */
  1640 	/* These are always placed next to the coastline, so we scale by the perimeter instead. */
  1634 	num = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(num) : ScaleByMapSize(num);
  1641 	num = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(num) : ScaleByMapSize(num);
  1635 
  1642 
  1674 			chance = ind_spc->appear_creation[_opt.landscape];
  1681 			chance = ind_spc->appear_creation[_opt.landscape];
  1675 			if (ind_spc->enabled && chance > 0) {
  1682 			if (ind_spc->enabled && chance > 0) {
  1676 				/* once the chance of appearance is determind, it have to be scaled by
  1683 				/* once the chance of appearance is determind, it have to be scaled by
  1677 				 * the difficulty level. The "chance" in question is more an index into
  1684 				 * the difficulty level. The "chance" in question is more an index into
  1678 				 * the _numof_industry_table,in fact */
  1685 				 * the _numof_industry_table,in fact */
  1679 				int num = (chance < 11) ? chance : _numof_industry_table[_opt.diff.number_industries][chance];
  1686 				int num = (chance > NB_NUMOFINDUSTRY) ? chance : _numof_industry_table[_opt.diff.number_industries][chance];
  1680 
  1687 
  1681 				/* These are always placed next to the coastline, so we scale by the perimeter instead. */
  1688 				/* These are always placed next to the coastline, so we scale by the perimeter instead. */
  1682 				num = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(num) : ScaleByMapSize(num);
  1689 				num = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(num) : ScaleByMapSize(num);
  1683 				i += num;
  1690 				i += num;
  1684 			}
  1691 			}