Changeset - r7676:78bb28e9c02b
[Not reviewed]
master
0 1 0
glx - 17 years ago 2007-10-05 17:53:45
glx@openttd.org
(svn r11207) -Fix [FS#1301]: don't use smooth_economy for industries using production callbacks as they may have no production for more than a month
1 file changed with 7 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -1441,7 +1441,8 @@ static void DoCreateNewIndustry(Industry
 
	i->production_rate[0] = indspec->production_rate[0];
 
	i->production_rate[1] = indspec->production_rate[1];
 

	
 
	if (_patches.smooth_economy) {
 
	/* don't use smooth economy for industries using production callbacks */
 
	if (_patches.smooth_economy  && !(HASBIT(indspec->callback_flags, CBM_IND_PRODUCTION_256_TICKS) || HASBIT(indspec->callback_flags, CBM_IND_PRODUCTION_CARGO_ARRIVAL))) {
 
		i->production_rate[0] = min((RandomRange(256) + 128) * i->production_rate[0] >> 8 , 255);
 
		i->production_rate[1] = min((RandomRange(256) + 128) * i->production_rate[1] >> 8 , 255);
 
	}
 
@@ -1862,6 +1863,8 @@ static void ChangeIndustryProduction(Ind
 
	const IndustrySpec *indspec = GetIndustrySpec(i->type);
 
	bool standard = true;
 
	bool suppress_message = false;
 
	/* don't use smooth economy for industries using production callbacks */
 
	bool smooth_economy = _patches.smooth_economy && !(HASBIT(indspec->callback_flags, CBM_IND_PRODUCTION_256_TICKS) || HASBIT(indspec->callback_flags, CBM_IND_PRODUCTION_CARGO_ARRIVAL));
 
	byte div = 0;
 
	byte mul = 0;
 

	
 
@@ -1888,7 +1891,7 @@ static void ChangeIndustryProduction(Ind
 
		}
 
	}
 

	
 
	if (standard && monthly != _patches.smooth_economy) return;
 
	if (standard && monthly != smooth_economy) return;
 

	
 
	if (standard && indspec->life_type == INDUSTRYLIFE_BLACK_HOLE) return;
 

	
 
@@ -1896,7 +1899,7 @@ static void ChangeIndustryProduction(Ind
 
		/* decrease or increase */
 
		bool only_decrease = (indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD) && _opt.landscape == LT_TEMPERATE;
 

	
 
		if (_patches.smooth_economy) {
 
		if (smooth_economy) {
 
			closeit = true;
 
			for (byte j = 0; j < 2 && i->produced_cargo[j] != CT_INVALID; j++){
 
				uint32 r = Random();
 
@@ -1949,7 +1952,7 @@ static void ChangeIndustryProduction(Ind
 
	}
 

	
 
	if (standard && indspec->life_type & INDUSTRYLIFE_PROCESSING) {
 
		if ( (byte)(_cur_year - i->last_prod_year) >= 5 && CHANCE16(1, _patches.smooth_economy ? 180 : 2)) {
 
		if ( (byte)(_cur_year - i->last_prod_year) >= 5 && CHANCE16(1, smooth_economy ? 180 : 2)) {
 
			closeit = true;
 
		}
 
	}
0 comments (0 inline, 0 general)