Merge branch 'town_cargo_adj-sx' into jgrpp
This commit is contained in:
@@ -569,14 +569,15 @@ static void MakeTownHouseBigger(TileIndex tile)
|
|||||||
* @param ct type of cargo to generate, usually CT_PASSENGERS or CT_MAIL
|
* @param ct type of cargo to generate, usually CT_PASSENGERS or CT_MAIL
|
||||||
* @param amount how many units of cargo
|
* @param amount how many units of cargo
|
||||||
* @param stations available stations for this house
|
* @param stations available stations for this house
|
||||||
|
* @param economy_adjust true if amount should be reduced during recession
|
||||||
*/
|
*/
|
||||||
static void TownGenerateCargo (Town *t, CargoID ct, uint amount, StationFinder &stations)
|
static void TownGenerateCargo (Town *t, CargoID ct, uint amount, StationFinder &stations, bool economy_adjust)
|
||||||
{
|
{
|
||||||
// custom cargo generation factor
|
// custom cargo generation factor
|
||||||
int cf = _settings_game.economy.town_cargo_factor;
|
int cf = _settings_game.economy.town_cargo_factor;
|
||||||
|
|
||||||
// when the economy flunctuates, everyone wants to stay at home
|
// when the economy flunctuates, everyone wants to stay at home
|
||||||
if (EconomyIsInRecession()) {
|
if (economy_adjust && EconomyIsInRecession()) {
|
||||||
amount = (amount + 1) >> 1;
|
amount = (amount + 1) >> 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -598,21 +599,21 @@ static void TownGenerateCargo (Town *t, CargoID ct, uint amount, StationFinder &
|
|||||||
assert(amount > 0);
|
assert(amount > 0);
|
||||||
|
|
||||||
// calculate for town stats
|
// calculate for town stats
|
||||||
|
|
||||||
|
switch (ct) {
|
||||||
|
case CT_PASSENGERS:
|
||||||
|
case CT_MAIL:
|
||||||
|
t->supplied[ct].new_max += amount;
|
||||||
|
t->supplied[ct].new_act += MoveGoodsToStation(ct, amount, ST_TOWN, t->index, stations.GetStations());
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: {
|
||||||
const CargoSpec *cs = CargoSpec::Get(ct);
|
const CargoSpec *cs = CargoSpec::Get(ct);
|
||||||
switch (cs->town_effect) {
|
t->supplied[cs->Index()].new_max += amount;
|
||||||
case TE_PASSENGERS:
|
t->supplied[cs->Index()].new_act += MoveGoodsToStation(ct, amount, ST_TOWN, t->index, stations.GetStations());
|
||||||
t->supplied[CT_PASSENGERS].new_max += amount;
|
|
||||||
t->supplied[CT_PASSENGERS].new_act += MoveGoodsToStation(CT_PASSENGERS, amount, ST_TOWN, t->index, stations.GetStations());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TE_MAIL:
|
|
||||||
t->supplied[CT_MAIL].new_max += amount;
|
|
||||||
t->supplied[CT_MAIL].new_act += MoveGoodsToStation(CT_MAIL, amount, ST_TOWN, t->index, stations.GetStations());
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -663,19 +664,19 @@ static void TileLoop_Town(TileIndex tile)
|
|||||||
if (amt == 0) continue;
|
if (amt == 0) continue;
|
||||||
|
|
||||||
// XXX: no economy flunctuation for GRF cargos?
|
// XXX: no economy flunctuation for GRF cargos?
|
||||||
TownGenerateCargo(t, cargo, amt, stations);
|
TownGenerateCargo(t, cargo, amt, stations, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
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;
|
||||||
|
|
||||||
TownGenerateCargo(t, CT_PASSENGERS, amt, stations);
|
TownGenerateCargo(t, CT_PASSENGERS, amt, stations, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
TownGenerateCargo(t, CT_MAIL, amt, stations);
|
TownGenerateCargo(t, CT_MAIL, amt, stations, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user