Rescale town cargo adj setting by 10x, for finer adjustment.

Use DECIMAL1 instead of an integer.
This commit is contained in:
Jonathan G Rennison
2016-11-25 23:24:41 +00:00
parent 842728bd17
commit ddae95addb
7 changed files with 40 additions and 8 deletions

View File

@@ -574,13 +574,24 @@ static void MakeTownHouseBigger(TileIndex tile)
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;
int factor = _settings_game.economy.town_cargo_scale_factor;
// when the economy flunctuates, everyone wants to stay at home
if (economy_adjust && EconomyIsInRecession()) {
amount = (amount + 1) >> 1;
}
factor += 200; // ensure factor is positive
assert(factor >= 0);
int cf = (factor / 10) - 20;
int fine = factor % 10;
if (fine != 0) {
// 2^0.1 << 16 to 2^0.9 << 16
const uint32 adj[9] = {70239, 75281, 80684, 86475, 92681, 99334, 106463, 114104, 122294};
uint64 scaled_amount = ((uint64) amount) * ((uint64) adj[fine - 1]);
amount = scaled_amount >> 16;
}
// apply custom factor?
if (cf < 0) {
// approx (amount / 2^cf)