Merge branch 'auto_timetables-sx' into jgrpp

Conflicts:
	src/saveload/extended_ver_sl.cpp
	src/settings_gui.cpp
	src/settings_type.h
This commit is contained in:
Jonathan G Rennison
2015-10-25 21:50:14 +00:00
8 changed files with 36 additions and 11 deletions

View File

@@ -1453,8 +1453,8 @@ STR_CONFIG_SETTING_TIMETABLE_START_TEXT_ENTRY :Enter timetable
STR_CONFIG_SETTING_TIMETABLE_START_TEXT_ENTRY_HELPTEXT :Select whether timetable start times may be entered as text if time is being shown in minutes STR_CONFIG_SETTING_TIMETABLE_START_TEXT_ENTRY_HELPTEXT :Select whether timetable start times may be entered as text if time is being shown in minutes
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

@@ -313,7 +313,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
@@ -336,7 +336,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
@@ -493,6 +493,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

@@ -56,7 +56,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
{ XSLFI_SIG_TUNNEL_BRIDGE, XSCF_NULL, 1, 1, "signal_tunnel_bridge", NULL, NULL, NULL }, { XSLFI_SIG_TUNNEL_BRIDGE, XSCF_NULL, 1, 1, "signal_tunnel_bridge", NULL, NULL, NULL },
{ XSLFI_IMPROVED_BREAKDOWNS, XSCF_NULL, 1, 1, "improved_breakdowns", NULL, NULL, NULL }, { XSLFI_IMPROVED_BREAKDOWNS, XSCF_NULL, 1, 1, "improved_breakdowns", NULL, NULL, NULL },
{ XSLFI_TT_WAIT_IN_DEPOT, XSCF_NULL, 1, 1, "tt_wait_in_depot", NULL, NULL, NULL }, { XSLFI_TT_WAIT_IN_DEPOT, XSCF_NULL, 1, 1, "tt_wait_in_depot", NULL, NULL, NULL },
{ 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_VEHICLE_REPAIR_COST, XSCF_NULL, 1, 1, "vehicle_repair_cost", NULL, NULL, NULL }, { XSLFI_VEHICLE_REPAIR_COST, XSCF_NULL, 1, 1, "vehicle_repair_cost", NULL, NULL, NULL },
{ XSLFI_ENH_VIEWPORT_PLANS, XSCF_IGNORABLE_ALL, 1, 1, "enh_viewport_plans", NULL, NULL, "PLAN,PLLN" }, { XSLFI_ENH_VIEWPORT_PLANS, XSCF_IGNORABLE_ALL, 1, 1, "enh_viewport_plans", NULL, NULL, "PLAN,PLLN" },
{ XSLFI_INFRA_SHARING, XSCF_NULL, 1, 1, "infra_sharing", NULL, NULL, NULL }, { XSLFI_INFRA_SHARING, XSCF_NULL, 1, 1, "infra_sharing", NULL, NULL, NULL },

View File

@@ -1635,6 +1635,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"));
company->Add(new SettingEntry("order_occupancy_smoothness")); company->Add(new SettingEntry("order_occupancy_smoothness"));
} }
@@ -1679,7 +1680,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"));
vehicles->Add(new SettingEntry("vehicle.adjacent_crossings")); vehicles->Add(new SettingEntry("vehicle.adjacent_crossings"));
} }

View File

@@ -479,10 +479,10 @@ 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_occupancy_smoothness; ///< moved to company settings: percentage smoothness of occupancy measurement changes uint8 old_occupancy_smoothness; ///< moved to company settings: percentage smoothness of occupancy measurement changes
uint8 old_timetable_separation_rate; ///< moved to company settings: percentage of timetable separation change to apply
}; };
/** Settings related to vehicles. */ /** Settings related to vehicles. */
@@ -590,6 +590,7 @@ struct CompanySettings {
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 order_occupancy_smoothness; ///< percentage smoothness of occupancy measurement changes uint8 order_occupancy_smoothness; ///< percentage smoothness of occupancy measurement changes
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

@@ -148,6 +148,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_VAR] [SDT_VAR]
base = CompanySettings base = CompanySettings

View File

@@ -367,7 +367,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
@@ -377,7 +377,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 "settings_type.h" #include "settings_type.h"
@@ -558,9 +559,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);