(svn r2107) - Codechange: Cleanup (well, mostly tidyup) ExtChangeIndustryProduction(). These randoms are strange.
This commit is contained in:
		| @@ -1686,26 +1686,28 @@ static void ExtChangeIndustryProduction(Industry *i) | ||||
| 			break; | ||||
|  | ||||
| 		default: /* INDUSTRY_PRODUCTION */ | ||||
| 			for (j=0; j != 2 && i->produced_cargo[j]!=255; j++){ | ||||
| 				uint32 r; | ||||
| 				int change,percent,old; | ||||
| 			for (j = 0; j < 2 && i->produced_cargo[j] != 255; j++){ | ||||
| 				uint32 r = Random(); | ||||
| 				int old, new, percent; | ||||
| 				int mag; | ||||
|  | ||||
| 				change = old = i->production_rate[j]; | ||||
| 				if (CHANCE16R(20,1024,r))change -= ((RandomRange(50) + 10)*old) >> 8; | ||||
| 				if (CHANCE16I(20+(i->pct_transported[j]*20>>8),1024,r>>16)) change += ((RandomRange(50) + 10)*old) >> 8; | ||||
| 				new = old = i->production_rate[j]; | ||||
| 				if (CHANCE16I(20, 1024, r)) | ||||
| 					new -= ((RandomRange(50) + 10) * old) >> 8; | ||||
| 				if (CHANCE16I(20 + (i->pct_transported[j] * 20 >> 8), 1024, r >> 16)) | ||||
| 					new += ((RandomRange(50) + 10) * old) >> 8; | ||||
|  | ||||
| 				// make sure it doesn't exceed 255 or goes below 0 | ||||
| 				change = clamp(change, 0, 255); | ||||
| 				if (change == old) { | ||||
| 				new = clamp(new, 0, 255); | ||||
| 				if (new == old) { | ||||
| 					closeit = false; | ||||
| 					continue; | ||||
| 				} | ||||
|  | ||||
| 				percent = change*100/old - 100; | ||||
| 				i->production_rate[j] = change; | ||||
| 				percent = new * 100 / old - 100; | ||||
| 				i->production_rate[j] = new; | ||||
|  | ||||
| 				if (change >= _industry_spec[i->type].production_rate[j]/4) | ||||
| 				if (new >= _industry_spec[i->type].production_rate[j] / 4) | ||||
| 					closeit = false; | ||||
|  | ||||
| 				mag = abs(percent); | ||||
| @@ -1726,7 +1728,9 @@ static void ExtChangeIndustryProduction(Industry *i) | ||||
| 		i->prod_level = 0; | ||||
| 		SetDParam(1, i->type + STR_4802_COAL_MINE); | ||||
| 		SetDParam(0, i->town->index); | ||||
| 		AddNewsItem(_industry_close_strings[i->type], NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_TILE, NT_ECONOMY, 0), i->xy + TILE_XY(1,1), 0); | ||||
| 		AddNewsItem(_industry_close_strings[i->type], | ||||
| 		            NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_TILE, NT_ECONOMY, 0), | ||||
| 		            i->xy + TILE_XY(1,1), 0); | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 pasky
					pasky