mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r21156) -Codechange: Introduce EconomyIsInRecession().
This commit is contained in:
parent
aea8274dba
commit
43f807a918
|
@ -710,7 +710,7 @@ static void HandleEconomyFluctuations()
|
||||||
if (_settings_game.difficulty.economy != 0) {
|
if (_settings_game.difficulty.economy != 0) {
|
||||||
/* When economy is Fluctuating, decrease counter */
|
/* When economy is Fluctuating, decrease counter */
|
||||||
_economy.fluct--;
|
_economy.fluct--;
|
||||||
} else if (_economy.fluct <= 0) {
|
} else if (EconomyIsInRecession()) {
|
||||||
/* When it's Steady and we are in recession, end it now */
|
/* When it's Steady and we are in recession, end it now */
|
||||||
_economy.fluct = -12;
|
_economy.fluct = -12;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -42,4 +42,13 @@ void InitializeEconomy();
|
||||||
void RecomputePrices();
|
void RecomputePrices();
|
||||||
void AddInflation(bool check_year = true);
|
void AddInflation(bool check_year = true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the economy in recession?
|
||||||
|
* @return \c True if economy is in recession, \c false otherwise.
|
||||||
|
*/
|
||||||
|
static inline bool EconomyIsInRecession()
|
||||||
|
{
|
||||||
|
return _economy.fluct <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* ECONOMY_FUNC_H */
|
#endif /* ECONOMY_FUNC_H */
|
||||||
|
|
|
@ -497,7 +497,7 @@ static void TransportIndustryGoods(TileIndex tile)
|
||||||
i->produced_cargo_waiting[j] -= cw;
|
i->produced_cargo_waiting[j] -= cw;
|
||||||
|
|
||||||
/* fluctuating economy? */
|
/* fluctuating economy? */
|
||||||
if (_economy.fluct <= 0) cw = (cw + 1) / 2;
|
if (EconomyIsInRecession()) cw = (cw + 1) / 2;
|
||||||
|
|
||||||
i->this_month_production[j] += cw;
|
i->this_month_production[j] += cw;
|
||||||
|
|
||||||
|
|
|
@ -508,7 +508,7 @@ static void TileLoop_Object(TileIndex tile)
|
||||||
/* Top town buildings generate 250, so the top HQ type makes 256. */
|
/* Top town buildings generate 250, so the top HQ type makes 256. */
|
||||||
if (GB(r, 0, 8) < (256 / 4 / (6 - level))) {
|
if (GB(r, 0, 8) < (256 / 4 / (6 - level))) {
|
||||||
uint amt = GB(r, 0, 8) / 8 / 4 + 1;
|
uint amt = GB(r, 0, 8) / 8 / 4 + 1;
|
||||||
if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
|
if (EconomyIsInRecession()) amt = (amt + 1) >> 1;
|
||||||
MoveGoodsToStation(CT_PASSENGERS, amt, ST_HEADQUARTERS, GetTileOwner(tile), stations.GetStations());
|
MoveGoodsToStation(CT_PASSENGERS, amt, ST_HEADQUARTERS, GetTileOwner(tile), stations.GetStations());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,7 +517,7 @@ static void TileLoop_Object(TileIndex tile)
|
||||||
* equations. */
|
* equations. */
|
||||||
if (GB(r, 8, 8) < (196 / 4 / (6 - level))) {
|
if (GB(r, 8, 8) < (196 / 4 / (6 - level))) {
|
||||||
uint amt = GB(r, 8, 8) / 8 / 4 + 1;
|
uint amt = GB(r, 8, 8) / 8 / 4 + 1;
|
||||||
if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
|
if (EconomyIsInRecession()) amt = (amt + 1) >> 1;
|
||||||
MoveGoodsToStation(CT_MAIL, amt, ST_HEADQUARTERS, GetTileOwner(tile), stations.GetStations());
|
MoveGoodsToStation(CT_MAIL, amt, ST_HEADQUARTERS, GetTileOwner(tile), stations.GetStations());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -497,7 +497,7 @@ static void TileLoop_Town(TileIndex tile)
|
||||||
if (GB(r, 0, 8) < hs->population) {
|
if (GB(r, 0, 8) < hs->population) {
|
||||||
uint amt = GB(r, 0, 8) / 8 + 1;
|
uint amt = GB(r, 0, 8) / 8 + 1;
|
||||||
|
|
||||||
if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
|
if (EconomyIsInRecession()) amt = (amt + 1) >> 1;
|
||||||
t->new_max_pass += amt;
|
t->new_max_pass += amt;
|
||||||
t->new_act_pass += MoveGoodsToStation(CT_PASSENGERS, amt, ST_TOWN, t->index, stations.GetStations());
|
t->new_act_pass += MoveGoodsToStation(CT_PASSENGERS, amt, ST_TOWN, t->index, stations.GetStations());
|
||||||
}
|
}
|
||||||
|
@ -505,7 +505,7 @@ static void TileLoop_Town(TileIndex tile)
|
||||||
if (GB(r, 8, 8) < hs->mail_generation) {
|
if (GB(r, 8, 8) < hs->mail_generation) {
|
||||||
uint amt = GB(r, 8, 8) / 8 + 1;
|
uint amt = GB(r, 8, 8) / 8 + 1;
|
||||||
|
|
||||||
if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
|
if (EconomyIsInRecession()) amt = (amt + 1) >> 1;
|
||||||
t->new_max_mail += amt;
|
t->new_max_mail += amt;
|
||||||
t->new_act_mail += MoveGoodsToStation(CT_MAIL, amt, ST_TOWN, t->index, stations.GetStations());
|
t->new_act_mail += MoveGoodsToStation(CT_MAIL, amt, ST_TOWN, t->index, stations.GetStations());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue