mirror of https://github.com/OpenTTD/OpenTTD
(svn r20850) -Codechange: Add IndustrySpec::UsesSmoothEconomy() to deduplicate code.
parent
717fcd09c6
commit
b65f463e33
|
@ -1572,9 +1572,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
|
||||||
i->production_rate[1] = indspec->production_rate[1];
|
i->production_rate[1] = indspec->production_rate[1];
|
||||||
|
|
||||||
/* don't use smooth economy for industries using production related callbacks */
|
/* don't use smooth economy for industries using production related callbacks */
|
||||||
if (_settings_game.economy.smooth_economy &&
|
if (indspec->UsesSmoothEconomy()) {
|
||||||
!(HasBit(indspec->callback_mask, CBM_IND_PRODUCTION_256_TICKS) || HasBit(indspec->callback_mask, CBM_IND_PRODUCTION_CARGO_ARRIVAL)) && // production callbacks
|
|
||||||
!(HasBit(indspec->callback_mask, CBM_IND_MONTHLYPROD_CHANGE) || HasBit(indspec->callback_mask, CBM_IND_PRODUCTION_CHANGE))) { // production change callbacks
|
|
||||||
i->production_rate[0] = min((RandomRange(256) + 128) * i->production_rate[0] >> 8, 255);
|
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);
|
i->production_rate[1] = min((RandomRange(256) + 128) * i->production_rate[1] >> 8, 255);
|
||||||
}
|
}
|
||||||
|
@ -2232,9 +2230,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
|
||||||
bool suppress_message = false;
|
bool suppress_message = false;
|
||||||
bool recalculate_multipliers = false; ///< reinitialize production_rate to match prod_level
|
bool recalculate_multipliers = false; ///< reinitialize production_rate to match prod_level
|
||||||
/* don't use smooth economy for industries using production related callbacks */
|
/* don't use smooth economy for industries using production related callbacks */
|
||||||
bool smooth_economy = _settings_game.economy.smooth_economy &&
|
bool smooth_economy = indspec->UsesSmoothEconomy();
|
||||||
!(HasBit(indspec->callback_mask, CBM_IND_PRODUCTION_256_TICKS) || HasBit(indspec->callback_mask, CBM_IND_PRODUCTION_CARGO_ARRIVAL)) && // production callbacks
|
|
||||||
!(HasBit(indspec->callback_mask, CBM_IND_MONTHLYPROD_CHANGE) || HasBit(indspec->callback_mask, CBM_IND_PRODUCTION_CHANGE)); // production change callbacks
|
|
||||||
byte div = 0;
|
byte div = 0;
|
||||||
byte mul = 0;
|
byte mul = 0;
|
||||||
int8 increment = 0;
|
int8 increment = 0;
|
||||||
|
@ -2515,6 +2511,13 @@ Money IndustrySpec::GetRemovalCost() const
|
||||||
return (_price[PR_CLEAR_INDUSTRY] * this->removal_cost_multiplier) >> 8;
|
return (_price[PR_CLEAR_INDUSTRY] * this->removal_cost_multiplier) >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IndustrySpec::UsesSmoothEconomy() const
|
||||||
|
{
|
||||||
|
return _settings_game.economy.smooth_economy &&
|
||||||
|
!(HasBit(this->callback_mask, CBM_IND_PRODUCTION_256_TICKS) || HasBit(this->callback_mask, CBM_IND_PRODUCTION_CARGO_ARRIVAL)) && // production callbacks
|
||||||
|
!(HasBit(this->callback_mask, CBM_IND_MONTHLYPROD_CHANGE) || HasBit(this->callback_mask, CBM_IND_PRODUCTION_CHANGE)); // production change callbacks
|
||||||
|
}
|
||||||
|
|
||||||
static CommandCost TerraformTile_Industry(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
|
static CommandCost TerraformTile_Industry(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
|
||||||
{
|
{
|
||||||
if (AutoslopeEnabled()) {
|
if (AutoslopeEnabled()) {
|
||||||
|
|
|
@ -153,6 +153,12 @@ struct IndustrySpec {
|
||||||
* @return the cost (inflation corrected etc)
|
* @return the cost (inflation corrected etc)
|
||||||
*/
|
*/
|
||||||
Money GetRemovalCost() const;
|
Money GetRemovalCost() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether this industrytype uses smooth economy or whether it uses standard/newgrf production changes.
|
||||||
|
* @return true if smooth economy is used.
|
||||||
|
*/
|
||||||
|
bool UsesSmoothEconomy() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue