mirror of https://github.com/OpenTTD/OpenTTD
(svn r2107) - Codechange: Cleanup (well, mostly tidyup) ExtChangeIndustryProduction(). These randoms are strange.
parent
508738f836
commit
e7937998d6
|
@ -1686,26 +1686,28 @@ static void ExtChangeIndustryProduction(Industry *i)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* INDUSTRY_PRODUCTION */
|
default: /* INDUSTRY_PRODUCTION */
|
||||||
for (j=0; j != 2 && i->produced_cargo[j]!=255; j++){
|
for (j = 0; j < 2 && i->produced_cargo[j] != 255; j++){
|
||||||
uint32 r;
|
uint32 r = Random();
|
||||||
int change,percent,old;
|
int old, new, percent;
|
||||||
int mag;
|
int mag;
|
||||||
|
|
||||||
change = old = i->production_rate[j];
|
new = old = i->production_rate[j];
|
||||||
if (CHANCE16R(20,1024,r))change -= ((RandomRange(50) + 10)*old) >> 8;
|
if (CHANCE16I(20, 1024, r))
|
||||||
if (CHANCE16I(20+(i->pct_transported[j]*20>>8),1024,r>>16)) change += ((RandomRange(50) + 10)*old) >> 8;
|
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
|
// make sure it doesn't exceed 255 or goes below 0
|
||||||
change = clamp(change, 0, 255);
|
new = clamp(new, 0, 255);
|
||||||
if (change == old) {
|
if (new == old) {
|
||||||
closeit = false;
|
closeit = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
percent = change*100/old - 100;
|
percent = new * 100 / old - 100;
|
||||||
i->production_rate[j] = change;
|
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;
|
closeit = false;
|
||||||
|
|
||||||
mag = abs(percent);
|
mag = abs(percent);
|
||||||
|
@ -1726,7 +1728,9 @@ static void ExtChangeIndustryProduction(Industry *i)
|
||||||
i->prod_level = 0;
|
i->prod_level = 0;
|
||||||
SetDParam(1, i->type + STR_4802_COAL_MINE);
|
SetDParam(1, i->type + STR_4802_COAL_MINE);
|
||||||
SetDParam(0, i->town->index);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue