src/industry_cmd.cpp
changeset 6748 7579278d958f
parent 6743 e84a3b89d46b
child 6749 be85c217e87e
equal deleted inserted replaced
6747:5c696ce73fb3 6748:7579278d958f
  1468 	SET_EXPENSES_TYPE(EXPENSES_OTHER);
  1468 	SET_EXPENSES_TYPE(EXPENSES_OTHER);
  1469 
  1469 
  1470 	indspec = GetIndustrySpec(p1);
  1470 	indspec = GetIndustrySpec(p1);
  1471 
  1471 
  1472 	/* Check if the to-be built/founded industry is available for this climate. */
  1472 	/* Check if the to-be built/founded industry is available for this climate. */
  1473 	if (!HASBIT(indspec->climate_availability, _opt_ptr->landscape)) return CMD_ERROR;
  1473 	if (!indspec->enabled) {
       
  1474 		return CMD_ERROR;
       
  1475 	}
  1474 
  1476 
  1475 	/* If the patch for raw-material industries is not on, you cannot build raw-material industries.
  1477 	/* If the patch for raw-material industries is not on, you cannot build raw-material industries.
  1476 	 * Raw material industries are industries that do not accept cargo (at least for now)
  1478 	 * Raw material industries are industries that do not accept cargo (at least for now)
  1477 	 * Exclude the lumber mill (only "raw" industry that can be built) */
  1479 	 * Exclude the lumber mill (only "raw" industry that can be built) */
  1478 	if (!_patches.build_rawmaterial_ind &&
  1480 	if (!_patches.build_rawmaterial_ind &&
  1552 	IndustryType it;
  1554 	IndustryType it;
  1553 	const IndustrySpec *ind_spc;
  1555 	const IndustrySpec *ind_spc;
  1554 
  1556 
  1555 	/* Find the total amount of industries */
  1557 	/* Find the total amount of industries */
  1556 	for (it = IT_COAL_MINE; it < NUM_INDUSTRYTYPES; it++) {
  1558 	for (it = IT_COAL_MINE; it < NUM_INDUSTRYTYPES; it++) {
  1557 		int num;
       
  1558 
  1559 
  1559 		ind_spc = GetIndustrySpec(it);
  1560 		ind_spc = GetIndustrySpec(it);
  1560 		chance = ind_spc->appear_creation[_opt.landscape];
  1561 		if (ind_spc->enabled) {
  1561 
  1562 			chance = ind_spc->appear_creation[_opt.landscape];
  1562 		if (chance > 0) {
  1563 			if (chance > 0) {
  1563 			/* once the chance of appearance is determind, it have to be scaled by
  1564 				/* once the chance of appearance is determind, it have to be scaled by
  1564 			 * the difficulty level. The "chance" in question is more an index into
  1565 				 * the difficulty level. The "chance" in question is more an index into
  1565 			 * the _numof_industry_table,in fact */
  1566 				 * the _numof_industry_table,in fact */
  1566 			num = _numof_industry_table[_opt.diff.number_industries][chance];
  1567 				int num = _numof_industry_table[_opt.diff.number_industries][chance];
  1567 
  1568 
  1568 			/* These are always placed next to the coastline, so we scale by the perimeter instead. */
  1569 				/* These are always placed next to the coastline, so we scale by the perimeter instead. */
  1569 			num = (it == IT_OIL_REFINERY || it == IT_OIL_RIG) ? ScaleByMapSize1D(num) : ScaleByMapSize(num);
  1570 				num = (it == IT_OIL_REFINERY || it == IT_OIL_RIG) ? ScaleByMapSize1D(num) : ScaleByMapSize(num);
  1570 			i += num;
  1571 				i += num;
       
  1572 			}
  1571 		}
  1573 		}
  1572 	}
  1574 	}
  1573 
  1575 
  1574 	SetGeneratingWorldProgress(GWP_INDUSTRY, i);
  1576 	SetGeneratingWorldProgress(GWP_INDUSTRY, i);
  1575 
  1577 
  1577 		/* Once the number of industries has been determined, let's really create them.
  1579 		/* Once the number of industries has been determined, let's really create them.
  1578 		 * The test for chance allows us to try create industries that are available only
  1580 		 * The test for chance allows us to try create industries that are available only
  1579 		 * for this landscape.
  1581 		 * for this landscape.
  1580 		 * @todo :  Do we really have to pass chance as un-scaled value, since we've already
  1582 		 * @todo :  Do we really have to pass chance as un-scaled value, since we've already
  1581 		 *          processed that scaling above? No, don't think so.  Will find a way. */
  1583 		 *          processed that scaling above? No, don't think so.  Will find a way. */
  1582 		chance = GetIndustrySpec(it)->appear_creation[_opt.landscape];
  1584 		ind_spc = GetIndustrySpec(it);
  1583 		if (chance > 0) PlaceInitialIndustry(it, chance);
  1585 		if (ind_spc->enabled) {
       
  1586 			chance = ind_spc->appear_creation[_opt.landscape];
       
  1587 			if (chance > 0) PlaceInitialIndustry(it, chance);
       
  1588 		}
  1584 	};
  1589 	};
  1585 }
  1590 }
  1586 
  1591 
  1587 /* Change industry production or do closure */
  1592 /* Change industry production or do closure */
  1588 static void ExtChangeIndustryProduction(Industry *i)
  1593 static void ExtChangeIndustryProduction(Industry *i)