mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-04 06:00:15 +00:00
Merge branch 'town_cargo_adj-sx' into jgrpp
This commit is contained in:
commit
3b42e299aa
@ -569,14 +569,15 @@ static void MakeTownHouseBigger(TileIndex tile)
|
||||
* @param ct type of cargo to generate, usually CT_PASSENGERS or CT_MAIL
|
||||
* @param amount how many units of cargo
|
||||
* @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
|
||||
int cf = _settings_game.economy.town_cargo_factor;
|
||||
|
||||
// when the economy flunctuates, everyone wants to stay at home
|
||||
if (EconomyIsInRecession()) {
|
||||
if (economy_adjust && EconomyIsInRecession()) {
|
||||
amount = (amount + 1) >> 1;
|
||||
}
|
||||
|
||||
@ -598,20 +599,20 @@ static void TownGenerateCargo (Town *t, CargoID ct, uint amount, StationFinder &
|
||||
assert(amount > 0);
|
||||
|
||||
// calculate for town stats
|
||||
const CargoSpec *cs = CargoSpec::Get(ct);
|
||||
switch (cs->town_effect) {
|
||||
case TE_PASSENGERS:
|
||||
t->supplied[CT_PASSENGERS].new_max += amount;
|
||||
t->supplied[CT_PASSENGERS].new_act += MoveGoodsToStation(CT_PASSENGERS, amount, ST_TOWN, t->index, stations.GetStations());
|
||||
|
||||
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;
|
||||
|
||||
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:
|
||||
default: {
|
||||
const CargoSpec *cs = CargoSpec::Get(ct);
|
||||
t->supplied[cs->Index()].new_max += amount;
|
||||
t->supplied[cs->Index()].new_act += MoveGoodsToStation(ct, amount, ST_TOWN, t->index, stations.GetStations());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -663,19 +664,19 @@ static void TileLoop_Town(TileIndex tile)
|
||||
if (amt == 0) continue;
|
||||
|
||||
// XXX: no economy flunctuation for GRF cargos?
|
||||
TownGenerateCargo(t, cargo, amt, stations);
|
||||
TownGenerateCargo(t, cargo, amt, stations, false);
|
||||
}
|
||||
} else {
|
||||
if (GB(r, 0, 8) < hs->population) {
|
||||
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) {
|
||||
uint amt = GB(r, 8, 8) / 8 + 1;
|
||||
|
||||
TownGenerateCargo(t, CT_MAIL, amt, stations);
|
||||
TownGenerateCargo(t, CT_MAIL, amt, stations, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user