changeset 14482:e012e349cd77 draft

(svn r19051) -Codechange: Variable scope.
author frosch <frosch@openttd.org>
date Sat, 06 Feb 2010 20:50:50 +0000
parents a6bae4e80e37
children 20fa7b6c0bf0
files src/industry_cmd.cpp
diffstat 1 files changed, 7 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1802,21 +1802,16 @@
  * It will scale the amount of industries by map size as well as difficulty level */
 void GenerateIndustries()
 {
-	uint i = 0;
-	uint8 chance;
-	IndustryType it;
-	const IndustrySpec *ind_spc;
-
+	uint total_amount = 0;
 	uint industry_counts[NUM_INDUSTRYTYPES];
 	memset(industry_counts, 0, sizeof(industry_counts));
 
 	/* Find the total amount of industries */
 	if (_settings_game.difficulty.number_industries > 0) {
-		for (it = 0; it < NUM_INDUSTRYTYPES; it++) {
+		for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) {
+			const IndustrySpec *ind_spc = GetIndustrySpec(it);
 
-			ind_spc = GetIndustrySpec(it);
-
-			chance = ind_spc->appear_creation[_settings_game.game_creation.landscape];
+			uint8 chance = ind_spc->appear_creation[_settings_game.game_creation.landscape];
 			if (ind_spc->enabled && chance > 0 && ind_spc->num_table > 0 && CheckIfCallBackAllowsAvailability(it, IACT_MAPGENERATION)) {
 				/* once the chance of appearance is determind, it have to be scaled by
 				 * the difficulty level. The "chance" in question is more an index into
@@ -1826,15 +1821,15 @@
 				/* These are always placed next to the coastline, so we scale by the perimeter instead. */
 				num = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(num) : ScaleByMapSize(num);
 				industry_counts[it] = num;
-				i += num;
+				total_amount += num;
 			}
 		}
 	}
 
-	SetGeneratingWorldProgress(GWP_INDUSTRY, i);
+	SetGeneratingWorldProgress(GWP_INDUSTRY, total_amount);
 
 	if (_settings_game.difficulty.number_industries > 0) {
-		for (it = 0; it < NUM_INDUSTRYTYPES; it++) {
+		for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) {
 			/* Once the number of industries has been determined, let's really create them. */
 			if (industry_counts[it] > 0) PlaceInitialIndustry(it, industry_counts[it]);
 		}