Move order occupancy smoothness to company settings.

pull/3/head
Jonathan G Rennison 9 years ago
parent 8001d86350
commit 6d263226d8

@ -2975,6 +2975,14 @@ bool AfterLoadGame()
FOR_ALL_STATIONS(st) UpdateStationAcceptance(st, false);
}
// setting moved from game settings to company settings
if (SlXvIsFeaturePresent(XSLFI_ORDER_OCCUPANCY, 1, 1)) {
Company *c;
FOR_ALL_COMPANIES(c) {
c->settings.order_occupancy_smoothness = _settings_game.order.old_occupancy_smoothness;
}
}
/* Road stops is 'only' updating some caches */
AfterLoadRoadStops();
AfterLoadLabelMaps();

@ -45,7 +45,7 @@ std::vector<uint32> _sl_xv_discardable_chunk_ids; ///< list of chunks
static const uint32 _sl_xv_slxi_chunk_version = 0; ///< current version os SLXI chunk
const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
{ XSLFI_ORDER_OCCUPANCY, XSCF_NULL, 1, 1, "order_occupancy", NULL, NULL, NULL },
{ XSLFI_ORDER_OCCUPANCY, XSCF_NULL, 2, 2, "order_occupancy", NULL, NULL, NULL },
{ XSLFI_NULL, XSCF_NULL, 0, 0, NULL, NULL, NULL, NULL },// This is the end marker
};

@ -1586,6 +1586,7 @@ static SettingsContainer &GetSettingsTree()
company->Add(new SettingEntry("vehicle.servint_roadveh"));
company->Add(new SettingEntry("vehicle.servint_ships"));
company->Add(new SettingEntry("vehicle.servint_aircraft"));
company->Add(new SettingEntry("order_occupancy_smoothness"));
}
SettingsPage *accounting = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING));
@ -1626,7 +1627,6 @@ static SettingsContainer &GetSettingsTree()
vehicles->Add(new SettingEntry("order.no_servicing_if_no_breakdowns"));
vehicles->Add(new SettingEntry("order.serviceathelipad"));
vehicles->Add(new SettingEntry("order.occupancy_smoothness"));
}
SettingsPage *limitations = main->Add(new SettingsPage(STR_CONFIG_SETTING_LIMITATIONS));

@ -439,7 +439,8 @@ struct OrderSettings {
bool selectgoods; ///< only send the goods to station if a train has been there
bool no_servicing_if_no_breakdowns; ///< don't send vehicles to depot when breakdowns are disabled
bool serviceathelipad; ///< service helicopters at helipads automatically (no need to send to depot)
uint8 occupancy_smoothness; ///< percentage smoothness of occupancy measurement changes
uint8 old_occupancy_smoothness; ///< moved to company settings: percentage smoothness of occupancy measurement changes
};
/** Settings related to vehicles. */
@ -536,6 +537,7 @@ struct CompanySettings {
uint32 engine_renew_money; ///< minimum amount of money before autorenew is used
bool renew_keep_length; ///< sell some wagons if after autoreplace the train is longer than before
VehicleDefaultSettings vehicle; ///< default settings for vehicles
uint8 order_occupancy_smoothness; ///< percentage smoothness of occupancy measurement changes
};
/** All settings together for the game. */

@ -135,6 +135,22 @@ strhelp = STR_CONFIG_SETTING_SERVINT_AIRCRAFT_HELPTEXT
strval = STR_CONFIG_SETTING_SERVINT_VALUE
proc = UpdateIntervalAircraft
[SDT_VAR]
base = CompanySettings
var = order_occupancy_smoothness
type = SLE_UINT8
guiflags = SGF_PER_COMPANY
def = 75
min = 0
max = 100
interval = 10
str = STR_CONFIG_OCCUPANCY_SMOOTHNESS
strhelp = STR_CONFIG_OCCUPANCY_SMOOTHNESS_HELPTEXT
strval = STR_CONFIG_SETTING_PERCENTAGE
cat = SC_EXPERT
patxname = ""order_occupancy_smoothness""
[SDT_END]

@ -2149,7 +2149,7 @@ cat = SC_EXPERT
[SDT_VAR]
base = GameSettings
var = order.occupancy_smoothness
var = order.old_occupancy_smoothness
type = SLE_UINT8
def = 75
min = 0
@ -2159,7 +2159,7 @@ str = STR_CONFIG_OCCUPANCY_SMOOTHNESS
strhelp = STR_CONFIG_OCCUPANCY_SMOOTHNESS_HELPTEXT
strval = STR_CONFIG_SETTING_PERCENTAGE
cat = SC_EXPERT
extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_ORDER_OCCUPANCY)
extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_ORDER_OCCUPANCY, 1, 1)
patxname = ""order_occupancy.order.occupancy_smoothness""
##

@ -2123,9 +2123,11 @@ void Vehicle::LeaveStation()
if (old_occupancy == 0) {
new_occupancy = current_occupancy;
} else {
Company *owner = Company::GetIfValid(this->owner);
uint8 occupancy_smoothness = owner ? owner->settings.order_occupancy_smoothness : 0;
// Exponential weighted moving average using occupancy_smoothness
new_occupancy = (old_occupancy - 1) * _settings_game.order.occupancy_smoothness;
new_occupancy += current_occupancy * (100 - _settings_game.order.occupancy_smoothness);
new_occupancy = (old_occupancy - 1) * occupancy_smoothness;
new_occupancy += current_occupancy * (100 - occupancy_smoothness);
new_occupancy += 50; // round to nearest integer percent, rather than just floor
new_occupancy /= 100;
}

Loading…
Cancel
Save