Rescale town cargo adj setting by 10x, for finer adjustment.
Use DECIMAL1 instead of an integer.
This commit is contained in:
@@ -1666,6 +1666,7 @@ STR_CONFIG_SETTING_TOWN_FOUNDING_FORBIDDEN :Forbidden
|
||||
STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED :Allowed
|
||||
STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED_CUSTOM_LAYOUT :Allowed, custom town layout
|
||||
STR_CONFIG_SETTING_TOWN_CARGO_FACTOR :Town cargo generation factor (less < 0 < more): {STRING2}
|
||||
STR_CONFIG_SETTING_TOWN_CARGO_FACTOR_HELPTEXT :Passenger, mail, and other town cargo production is scaled by approximately 2^factor (exponential)
|
||||
|
||||
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT :In game placement of trees: {STRING2}
|
||||
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_HELPTEXT :Control random appearance of trees during the game. This might affect industries which rely on tree growth, for example lumber mills
|
||||
|
@@ -3307,6 +3307,11 @@ bool AfterLoadGame()
|
||||
FOR_ALL_VEHICLES(v) SB(v->vehicle_flags, VF_TIMETABLE_SEPARATION, 1, _settings_game.order.old_timetable_separation);
|
||||
}
|
||||
|
||||
/* Set lifetime vehicle profit to 0 if lifetime profit feature is missing */
|
||||
if (!SlXvIsFeaturePresent(XSLFI_TOWN_CARGO_ADJ, 2)) {
|
||||
_settings_game.economy.town_cargo_scale_factor = _settings_game.economy.old_town_cargo_factor * 10;
|
||||
}
|
||||
|
||||
/* Road stops is 'only' updating some caches */
|
||||
AfterLoadRoadStops();
|
||||
AfterLoadLabelMaps();
|
||||
|
@@ -53,7 +53,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
||||
{ XSLFI_ADJACENT_CROSSINGS, XSCF_NULL, 1, 1, "adjacent_crossings", NULL, NULL, NULL },
|
||||
{ XSLFI_DEPARTURE_BOARDS, XSCF_IGNORABLE_UNKNOWN, 1, 1, "departure_boards", NULL, NULL, NULL },
|
||||
{ XSLFI_TIMETABLES_START_TICKS, XSCF_NULL, 2, 2, "timetable_start_ticks", NULL, NULL, NULL },
|
||||
{ XSLFI_TOWN_CARGO_ADJ, XSCF_IGNORABLE_UNKNOWN, 1, 1, "town_cargo_adj", NULL, NULL, NULL },
|
||||
{ XSLFI_TOWN_CARGO_ADJ, XSCF_IGNORABLE_UNKNOWN, 2, 2, "town_cargo_adj", NULL, NULL, NULL },
|
||||
{ XSLFI_SIG_TUNNEL_BRIDGE, XSCF_NULL, 4, 4, "signal_tunnel_bridge", NULL, NULL, "XBSS" },
|
||||
{ XSLFI_IMPROVED_BREAKDOWNS, XSCF_NULL, 4, 4, "improved_breakdowns", NULL, NULL, NULL },
|
||||
{ XSLFI_TT_WAIT_IN_DEPOT, XSCF_NULL, 1, 1, "tt_wait_in_depot", NULL, NULL, NULL },
|
||||
|
@@ -1765,7 +1765,7 @@ static SettingsContainer &GetSettingsTree()
|
||||
towns->Add(new SettingEntry("economy.allow_town_roads"));
|
||||
towns->Add(new SettingEntry("economy.allow_town_level_crossings"));
|
||||
towns->Add(new SettingEntry("economy.found_town"));
|
||||
towns->Add(new SettingEntry("economy.town_cargo_factor"));
|
||||
towns->Add(new SettingEntry("economy.town_cargo_scale_factor"));
|
||||
towns->Add(new SettingEntry("economy.random_road_reconstruction"));
|
||||
}
|
||||
|
||||
|
@@ -544,7 +544,8 @@ struct EconomySettings {
|
||||
uint sharing_fee[4]; ///< fees for infrastructure sharing for rail/road/water/air
|
||||
bool sharing_payment_in_debt; ///< allow fee payment for companies with more loan than money (switch off to prevent MP exploits)
|
||||
bool allow_town_level_crossings; ///< towns are allowed to build level crossings
|
||||
int8 town_cargo_factor; ///< power-of-two multiplier for town (passenger, mail) generation. May be negative.
|
||||
int8 old_town_cargo_factor; ///< old power-of-two multiplier for town (passenger, mail) generation. May be negative.
|
||||
int16 town_cargo_scale_factor; ///< scaled power-of-two multiplier for town (passenger, mail) generation. May be negative.
|
||||
bool infrastructure_maintenance; ///< enable monthly maintenance fee for owner infrastructure
|
||||
uint8 day_length_factor; ///< factor which the length of day is multiplied
|
||||
uint16 random_road_reconstruction; ///< chance out of 1000 per tile loop for towns to start random road re-construction
|
||||
|
@@ -677,7 +677,7 @@ str = STR_CONFIG_SETTING_ALLOW_TOWN_ROADS
|
||||
strhelp = STR_CONFIG_SETTING_ALLOW_TOWN_ROADS_HELPTEXT
|
||||
|
||||
[SDT_XREF]
|
||||
xref = ""economy.town_cargo_factor""
|
||||
xref = ""economy.old_town_cargo_factor""
|
||||
extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_SPRINGPP)
|
||||
|
||||
[SDT_VAR]
|
||||
@@ -852,17 +852,31 @@ strhelp = STR_CONFIG_SETTING_SHORT_PATH_SATURATION_HELPTEXT
|
||||
|
||||
[SDT_VAR]
|
||||
base = GameSettings
|
||||
var = economy.town_cargo_factor
|
||||
var = economy.old_town_cargo_factor
|
||||
type = SLE_INT8
|
||||
from = 160
|
||||
def = 0
|
||||
min = -16
|
||||
max = +8
|
||||
interval = 1
|
||||
str = STR_CONFIG_SETTING_TOWN_CARGO_FACTOR
|
||||
strval = STR_JUST_INT
|
||||
extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_TOWN_CARGO_ADJ, 1, 1)
|
||||
patxname = ""town_cargo_adj.economy.town_cargo_factor""
|
||||
|
||||
[SDT_VAR]
|
||||
base = GameSettings
|
||||
var = economy.town_cargo_scale_factor
|
||||
type = SLE_INT16
|
||||
guiflags = SGF_DECIMAL1
|
||||
def = 0
|
||||
min = -160
|
||||
max = +80
|
||||
interval = 1
|
||||
str = STR_CONFIG_SETTING_TOWN_CARGO_FACTOR
|
||||
strval = STR_JUST_DECIMAL1
|
||||
strhelp = STR_CONFIG_SETTING_TOWN_CARGO_FACTOR_HELPTEXT
|
||||
patxname = ""town_cargo_adj.economy.town_cargo_scale_factor""
|
||||
|
||||
; Vehicles
|
||||
|
||||
[SDT_VAR]
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user