Make auto TT separation rate a company setting.

Move auto TT by default setting to PLYX chunk.
This commit is contained in:
Jonathan G Rennison
2015-10-25 12:47:23 +00:00
parent a380573c32
commit 26d32269a3
8 changed files with 37 additions and 11 deletions

View File

@@ -1400,8 +1400,8 @@ STR_CONFIG_SETTING_TIMETABLE_IN_TICKS :Show timetable
STR_CONFIG_SETTING_TIMETABLE_IN_TICKS_HELPTEXT :Show travel times in time tables in game ticks instead of days STR_CONFIG_SETTING_TIMETABLE_IN_TICKS_HELPTEXT :Show travel times in time tables in game ticks instead of days
STR_CONFIG_SETTING_TIMETABLE_SEPARATION :Use timetable to ensure vehicle separation: {STRING2} STR_CONFIG_SETTING_TIMETABLE_SEPARATION :Use timetable to ensure vehicle separation: {STRING2}
STR_CONFIG_SETTING_TIMETABLE_SEPARATION_HELPTEXT :Select whether to ensure separation of vehicles when using automatic timetables STR_CONFIG_SETTING_TIMETABLE_SEPARATION_HELPTEXT :Select whether to ensure separation of vehicles when using automatic timetables
STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE :Vehicle separation factor: {STRING2} STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE :Auto timetable vehicle separation factor: {STRING2}
STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE_HELPTEXT :How much of the vehicle separation timetable change to apply at each step STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE_HELPTEXT :How much of the vehicle separation auto timetable change to apply at each step
STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE :Show arrival and departure in timetables: {STRING2} STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE :Show arrival and departure in timetables: {STRING2}
STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT :Display anticipated arrival and departure times in timetables STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT :Display anticipated arrival and departure times in timetables
STR_CONFIG_SETTING_QUICKGOTO :Quick creation of vehicle orders: {STRING2} STR_CONFIG_SETTING_QUICKGOTO :Quick creation of vehicle orders: {STRING2}

View File

@@ -312,7 +312,7 @@ static const SaveLoad _company_settings_desc[] = {
SLE_CONDVAR(Company, settings.vehicle.servint_roadveh, SLE_UINT16, 120, SL_MAX_VERSION), SLE_CONDVAR(Company, settings.vehicle.servint_roadveh, SLE_UINT16, 120, SL_MAX_VERSION),
SLE_CONDVAR(Company, settings.vehicle.servint_aircraft, SLE_UINT16, 120, SL_MAX_VERSION), SLE_CONDVAR(Company, settings.vehicle.servint_aircraft, SLE_UINT16, 120, SL_MAX_VERSION),
SLE_CONDVAR(Company, settings.vehicle.servint_ships, SLE_UINT16, 120, SL_MAX_VERSION), SLE_CONDVAR(Company, settings.vehicle.servint_ships, SLE_UINT16, 120, SL_MAX_VERSION),
SLE_CONDVAR_X(Company, settings.vehicle.auto_timetable_by_default, SLE_BOOL, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_AUTO_TIMETABLE, 2)), SLE_CONDVAR_X(Company, settings.vehicle.auto_timetable_by_default, SLE_BOOL, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_AUTO_TIMETABLE, 2, 2)),
SLE_CONDNULL(63, 2, 143), // old reserved space SLE_CONDNULL(63, 2, 143), // old reserved space
@@ -335,7 +335,7 @@ static const SaveLoad _company_settings_skip_desc[] = {
SLE_CONDNULL(2, 120, SL_MAX_VERSION), // settings.vehicle.servint_roadveh SLE_CONDNULL(2, 120, SL_MAX_VERSION), // settings.vehicle.servint_roadveh
SLE_CONDNULL(2, 120, SL_MAX_VERSION), // settings.vehicle.servint_aircraft SLE_CONDNULL(2, 120, SL_MAX_VERSION), // settings.vehicle.servint_aircraft
SLE_CONDNULL(2, 120, SL_MAX_VERSION), // settings.vehicle.servint_ships SLE_CONDNULL(2, 120, SL_MAX_VERSION), // settings.vehicle.servint_ships
SLE_CONDNULL_X(1, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_AUTO_TIMETABLE, 2)), // settings.vehicle.auto_timetable_by_default SLE_CONDNULL_X(1, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_AUTO_TIMETABLE, 2, 2)), // settings.vehicle.auto_timetable_by_default
SLE_CONDNULL(63, 2, 143), // old reserved space SLE_CONDNULL(63, 2, 143), // old reserved space
@@ -492,6 +492,11 @@ static void Load_PLYR()
SetDefaultCompanySettings(c->index); SetDefaultCompanySettings(c->index);
SaveLoad_PLYR(c); SaveLoad_PLYR(c);
_company_colours[index] = (Colours)c->colour; _company_colours[index] = (Colours)c->colour;
// setting moved from game settings to company settings
if (SlXvIsFeaturePresent(XSLFI_AUTO_TIMETABLE, 1, 2)) {
c->settings.auto_timetable_separation_rate = _settings_game.order.old_timetable_separation_rate;
}
} }
} }

View File

@@ -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 static const uint32 _sl_xv_slxi_chunk_version = 0; ///< current version os SLXI chunk
const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = { const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
{ XSLFI_AUTO_TIMETABLE, XSCF_NULL, 2, 2, "auto_timetables", NULL, NULL, NULL }, { XSLFI_AUTO_TIMETABLE, XSCF_NULL, 3, 3, "auto_timetables", NULL, NULL, NULL },
{ XSLFI_NULL, XSCF_NULL, 0, 0, NULL, NULL, NULL, NULL },// This is the end marker { XSLFI_NULL, XSCF_NULL, 0, 0, NULL, NULL, NULL, NULL },// This is the end marker
}; };

View File

@@ -1587,6 +1587,7 @@ static SettingsContainer &GetSettingsTree()
company->Add(new SettingEntry("vehicle.servint_ships")); company->Add(new SettingEntry("vehicle.servint_ships"));
company->Add(new SettingEntry("vehicle.servint_aircraft")); company->Add(new SettingEntry("vehicle.servint_aircraft"));
company->Add(new SettingEntry("vehicle.auto_timetable_by_default")); company->Add(new SettingEntry("vehicle.auto_timetable_by_default"));
company->Add(new SettingEntry("auto_timetable_separation_rate"));
} }
SettingsPage *accounting = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING)); SettingsPage *accounting = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING));
@@ -1629,7 +1630,6 @@ static SettingsContainer &GetSettingsTree()
vehicles->Add(new SettingEntry("order.serviceathelipad")); vehicles->Add(new SettingEntry("order.serviceathelipad"));
vehicles->Add(new SettingEntry("order.timetable_automated")); vehicles->Add(new SettingEntry("order.timetable_automated"));
vehicles->Add(new SettingEntry("order.timetable_separation")); vehicles->Add(new SettingEntry("order.timetable_separation"));
vehicles->Add(new SettingEntry("order.timetable_separation_rate"));
} }
SettingsPage *limitations = main->Add(new SettingsPage(STR_CONFIG_SETTING_LIMITATIONS)); SettingsPage *limitations = main->Add(new SettingsPage(STR_CONFIG_SETTING_LIMITATIONS));

View File

@@ -440,8 +440,9 @@ struct OrderSettings {
bool no_servicing_if_no_breakdowns; ///< don't send vehicles to depot when breakdowns are disabled bool no_servicing_if_no_breakdowns; ///< don't send vehicles to depot when breakdowns are disabled
bool timetable_automated; ///< whether to automatically manage timetables bool timetable_automated; ///< whether to automatically manage timetables
bool timetable_separation; ///< whether to perform automatic separation based on timetable bool timetable_separation; ///< whether to perform automatic separation based on timetable
uint8 timetable_separation_rate; ///< percentage of timetable separation change to apply
bool serviceathelipad; ///< service helicopters at helipads automatically (no need to send to depot) bool serviceathelipad; ///< service helicopters at helipads automatically (no need to send to depot)
uint8 old_timetable_separation_rate; ///< moved to company settings: percentage of timetable separation change to apply
}; };
/** Settings related to vehicles. */ /** Settings related to vehicles. */
@@ -539,6 +540,7 @@ struct CompanySettings {
uint32 engine_renew_money; ///< minimum amount of money before autorenew is used 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 bool renew_keep_length; ///< sell some wagons if after autoreplace the train is longer than before
VehicleDefaultSettings vehicle; ///< default settings for vehicles VehicleDefaultSettings vehicle; ///< default settings for vehicles
uint8 auto_timetable_separation_rate; ///< percentage of auto timetable separation change to apply
}; };
/** All settings together for the game. */ /** All settings together for the game. */

View File

@@ -142,6 +142,22 @@ guiflags = SGF_PER_COMPANY
def = false def = false
str = STR_CONFIG_SETTING_AUTO_TIMETABLE_BY_DEFAULT str = STR_CONFIG_SETTING_AUTO_TIMETABLE_BY_DEFAULT
strhelp = STR_CONFIG_SETTING_AUTO_TIMETABLE_BY_DEFAULT_HELPTEXT strhelp = STR_CONFIG_SETTING_AUTO_TIMETABLE_BY_DEFAULT_HELPTEXT
patxname = ""vehicle.auto_timetable_by_default""
[SDT_VAR]
base = CompanySettings
var = auto_timetable_separation_rate
type = SLE_UINT8
guiflags = SGF_PER_COMPANY
def = 100
min = 0
max = 100
interval = 10
str = STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE
strhelp = STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE_HELPTEXT
strval = STR_CONFIG_SETTING_PERCENTAGE
cat = SC_EXPERT
patxname = ""auto_timetable_separation_rate""
[SDT_END] [SDT_END]

View File

@@ -353,7 +353,7 @@ patxname = ""auto_timetables.order.timetable_separation""
[SDT_VAR] [SDT_VAR]
base = GameSettings base = GameSettings
var = order.timetable_separation_rate var = order.old_timetable_separation_rate
type = SLE_UINT8 type = SLE_UINT8
def = 100 def = 100
min = 0 min = 0
@@ -363,7 +363,7 @@ str = STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE
strhelp = STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE_HELPTEXT strhelp = STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE_HELPTEXT
strval = STR_CONFIG_SETTING_PERCENTAGE strval = STR_CONFIG_SETTING_PERCENTAGE
cat = SC_EXPERT cat = SC_EXPERT
extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_AUTO_TIMETABLE) extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_AUTO_TIMETABLE, 1, 2)
patxname = ""auto_timetables.order.timetable_separation_rate"" patxname = ""auto_timetables.order.timetable_separation_rate""
; There are only 21 predefined town_name values (0-20), but you can have more with newgrf action F so allow ; There are only 21 predefined town_name values (0-20), but you can have more with newgrf action F so allow

View File

@@ -17,6 +17,7 @@
#include "vehicle_base.h" #include "vehicle_base.h"
#include "settings_type.h" #include "settings_type.h"
#include "cmd_helper.h" #include "cmd_helper.h"
#include "company_base.h"
#include "core/sort_func.hpp" #include "core/sort_func.hpp"
#include "table/strings.h" #include "table/strings.h"
@@ -549,9 +550,11 @@ void UpdateSeparationOrder(Vehicle *v_start)
int separation_ahead = SeparationBetween(v, v->AheadSeparation()); int separation_ahead = SeparationBetween(v, v->AheadSeparation());
int separation_behind = SeparationBetween(v->BehindSeparation(), v); int separation_behind = SeparationBetween(v->BehindSeparation(), v);
if (separation_ahead != -1 && separation_behind != -1) { if (separation_ahead != -1 && separation_behind != -1) {
Company *owner = Company::GetIfValid(v->owner);
uint8 timetable_separation_rate = owner ? owner->settings.auto_timetable_separation_rate : 100;
int new_lateness = (separation_ahead - separation_behind) / 2; int new_lateness = (separation_ahead - separation_behind) / 2;
v->lateness_counter = (new_lateness * _settings_game.order.timetable_separation_rate + v->lateness_counter = (new_lateness * timetable_separation_rate +
v->lateness_counter * (100 - _settings_game.order.timetable_separation_rate)) / 100; v->lateness_counter * (100 - timetable_separation_rate)) / 100;
} }
v = v->AheadSeparation(); v = v->AheadSeparation();
} while (v != v_start); } while (v != v_start);