|
|
@ -466,14 +466,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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -495,21 +496,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
|
|
|
|
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());
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case TE_MAIL:
|
|
|
|
switch (ct) {
|
|
|
|
t->supplied[CT_MAIL].new_max += amount;
|
|
|
|
case CT_PASSENGERS:
|
|
|
|
t->supplied[CT_MAIL].new_act += MoveGoodsToStation(CT_MAIL, amount, ST_TOWN, t->index, stations.GetStations());
|
|
|
|
case CT_MAIL:
|
|
|
|
|
|
|
|
t->supplied[ct].new_max += amount;
|
|
|
|
|
|
|
|
t->supplied[ct].new_act += MoveGoodsToStation(ct, amount, ST_TOWN, t->index, stations.GetStations());
|
|
|
|
break;
|
|
|
|
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;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -560,19 +561,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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|