Skip to content

Commit

Permalink
Merge branch 'auto_timetables-sx' into jgrpp
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/lang/english.txt
#	src/saveload/afterload.cpp
#	src/saveload/extended_ver_sl.cpp
#	src/settings_gui.cpp
#	src/settings_type.h
#	src/table/company_settings.ini
#	src/vehicle.cpp
  • Loading branch information
JGRennison committed May 8, 2016
2 parents 04b188b + d59252d commit 4c5173b
Show file tree
Hide file tree
Showing 21 changed files with 140 additions and 59 deletions.
4 changes: 2 additions & 2 deletions src/aircraft_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, const Engine *
v->vehicle_flags = 0;
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
v->SetServiceIntervalIsPercent(Company::Get(_current_company)->settings.vehicle.servint_ispercent);
SB(v->vehicle_flags, VF_AUTOMATE_TIMETABLE, 1,
_settings_game.order.timetable_automated && Company::Get(_current_company)->settings.vehicle.auto_timetable_by_default);
SB(v->vehicle_flags, VF_AUTOMATE_TIMETABLE, 1, Company::Get(_current_company)->settings.vehicle.auto_timetable_by_default);
SB(v->vehicle_flags, VF_TIMETABLE_SEPARATION, 1, Company::Get(_current_company)->settings.vehicle.auto_separation_by_default);

v->InvalidateNewGRFCacheOfChain();

Expand Down
2 changes: 2 additions & 0 deletions src/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ CommandProc CmdBulkChangeTimetable;
CommandProc CmdSetVehicleOnTime;
CommandProc CmdAutofillTimetable;
CommandProc CmdAutomateTimetable;
CommandProc CmdTimetableSeparation;
CommandProc CmdSetTimetableStart;

CommandProc CmdOpenCloseAirport;
Expand Down Expand Up @@ -418,6 +419,7 @@ static const Command _command_proc_table[] = {
DEF_CMD(CmdSetVehicleOnTime, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_VEHICLE_ON_TIME
DEF_CMD(CmdAutofillTimetable, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_AUTOFILL_TIMETABLE
DEF_CMD(CmdAutomateTimetable, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_AUTOMATE_TIMETABLE
DEF_CMD(CmdTimetableSeparation, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_TIMETABLE_SEPARATION
DEF_CMD(CmdSetTimetableStart, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_TIMETABLE_START

DEF_CMD(CmdOpenCloseAirport, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_OPEN_CLOSE_AIRPORT
Expand Down
1 change: 1 addition & 0 deletions src/command_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ enum Commands {
CMD_SET_VEHICLE_ON_TIME, ///< set the vehicle on time feature (timetable)
CMD_AUTOFILL_TIMETABLE, ///< autofill the timetable
CMD_AUTOMATE_TIMETABLE, ///< automate the timetable
CMD_TIMETABLE_SEPARATION, ///< auto timetable separation
CMD_SET_TIMETABLE_START, ///< set the date that a timetable should start

CMD_OPEN_CLOSE_AIRPORT, ///< open/close an airport to incoming aircraft
Expand Down
13 changes: 9 additions & 4 deletions src/lang/english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1446,8 +1446,10 @@ STR_CONFIG_SETTING_ADVANCED_VEHICLE_LISTS :Use groups in v
STR_CONFIG_SETTING_ADVANCED_VEHICLE_LISTS_HELPTEXT :Enable usage of the advanced vehicle lists for grouping vehicles
STR_CONFIG_SETTING_LOADING_INDICATORS :Use loading indicators: {STRING2}
STR_CONFIG_SETTING_LOADING_INDICATORS_HELPTEXT :Select whether loading indicators are displayed above loading or unloading vehicles
STR_CONFIG_SETTING_TIMETABLE_AUTOMATED :Automatically manage timetables: {STRING2}
STR_CONFIG_SETTING_TIMETABLE_AUTOMATED_HELPTEXT :Whether to enable automatic timetables
STR_CONFIG_SETTING_AUTO_TIMETABLE_BY_DEFAULT :Use automatic timetables by default: {STRING2}
STR_CONFIG_SETTING_AUTO_TIMETABLE_BY_DEFAULT_HELPTEXT :Choose whether automatic timetables should by automatically enabled for new vehicles
STR_CONFIG_SETTING_TIMETABLE_SEPARATION_BY_DEFAULT :Use timetable to ensure vehicle separation by default: {STRING2}
STR_CONFIG_SETTING_TIMETABLE_SEPARATION_BY_DEFAULT_HELPTEXT :Choose whether to ensure separation of vehicles should by automatically enabled for new vehicles
STR_CONFIG_SETTING_TIMETABLE_IN_TICKS :Show timetable in ticks rather than days: {STRING2}
STR_CONFIG_SETTING_TIMETABLE_IN_TICKS_HELPTEXT :Show travel times in time tables in game ticks instead of days
STR_CONFIG_SETTING_TIMETABLE_LEFTOVER_TICKS :Show leftover ticks in timetable: {STRING2}
Expand All @@ -1472,6 +1474,8 @@ STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE :Auto timetable
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_HELPTEXT :Display anticipated arrival and departure times in timetables
STR_CONFIG_SETTING_TIMETABLE_AUTOFILL_ROUNDING_TICKS :Round up auto-filled timetable times to multiples of this many ticks: {STRING2}
STR_CONFIG_SETTING_TIMETABLE_AUTOFILL_ROUNDING_TICKS_HELPTEXT :Timetable times adjusted by timetable automation are not rounded. A day at a a day length of 1 is 74 ticks.
STR_CONFIG_SETTING_QUICKGOTO :Quick creation of vehicle orders: {STRING2}
STR_CONFIG_SETTING_QUICKGOTO_HELPTEXT :Pre-select the 'goto cursor' when opening the orders window
STR_CONFIG_SETTING_DEFAULT_RAIL_TYPE :Default rail type (after new game/game load): {STRING2}
Expand Down Expand Up @@ -1566,8 +1570,6 @@ STR_CONFIG_SETTING_SERVINT_AIRCRAFT :Default service
STR_CONFIG_SETTING_SERVINT_AIRCRAFT_HELPTEXT :Set the default service interval for new aircraft, if no explicit service interval is set for the vehicle
STR_CONFIG_SETTING_SERVINT_SHIPS :Default service interval for ships: {STRING2}
STR_CONFIG_SETTING_SERVINT_SHIPS_HELPTEXT :Set the default service interval for new ships, if no explicit service interval is set for the vehicle
STR_CONFIG_SETTING_AUTO_TIMETABLE_BY_DEFAULT :Use automatic timetables by default
STR_CONFIG_SETTING_AUTO_TIMETABLE_BY_DEFAULT_HELPTEXT :Choose whether automatic timetables should by automatically enabled for new vehicles
STR_CONFIG_SETTING_NOSERVICE :Disable servicing when breakdowns set to none: {STRING2}
STR_CONFIG_SETTING_NOSERVICE_HELPTEXT :When enabled, vehicles do not get serviced if they cannot break down
STR_CONFIG_SETTING_WAGONSPEEDLIMITS :Enable wagon speed limits: {STRING2}
Expand Down Expand Up @@ -4489,6 +4491,9 @@ STR_TIMETABLE_AUTOFILL_TOOLTIP :{BLACK}Fill the
STR_TIMETABLE_AUTOMATE :{BLACK}Automate
STR_TIMETABLE_AUTOMATE_TOOLTIP :{BLACK}Manage the timetables automatically by updating the values for each journey (Ctrl+Click when disabling to keep the current timetable)

STR_TIMETABLE_AUTO_SEPARATION :{BLACK}Auto Separation
STR_TIMETABLE_AUTO_SEPARATION_TOOLTIP :{BLACK}Automatically adjust timetable start times to ensure vehicle separation

STR_TIMETABLE_EXPECTED :{BLACK}Expected
STR_TIMETABLE_SCHEDULED :{BLACK}Scheduled
STR_TIMETABLE_EXPECTED_TOOLTIP :{BLACK}Switch between expected and scheduled
Expand Down
16 changes: 14 additions & 2 deletions src/order_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
InvalidateVehicleOrder(v, VIWD_MODIFY_ORDERS);

v->ClearSeparation();
if (_settings_game.order.timetable_separation) ClrBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
if (HasBit(v->vehicle_flags, VF_TIMETABLE_SEPARATION)) ClrBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
}

/* We have an aircraft/ship, they have a mini-schedule, so update them all */
Expand Down Expand Up @@ -1717,11 +1717,17 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
} else {
ClrBit(dst->vehicle_flags, VF_AUTOMATE_TIMETABLE);
}
/* Set auto separation bit if target has it. */
if (HasBit(src->vehicle_flags, VF_TIMETABLE_SEPARATION)) {
SetBit(dst->vehicle_flags, VF_TIMETABLE_SEPARATION);
} else {
ClrBit(dst->vehicle_flags, VF_TIMETABLE_SEPARATION);
}
ClrBit(dst->vehicle_flags, VF_AUTOFILL_TIMETABLE);
ClrBit(dst->vehicle_flags, VF_AUTOFILL_PRES_WAIT_TIME);

dst->ClearSeparation();
if (_settings_game.order.timetable_separation) ClrBit(dst->vehicle_flags, VF_TIMETABLE_STARTED);
if (HasBit(dst->vehicle_flags, VF_TIMETABLE_SEPARATION)) ClrBit(dst->vehicle_flags, VF_TIMETABLE_STARTED);

InvalidateVehicleOrder(dst, VIWD_REMOVE_ALL_ORDERS);
InvalidateVehicleOrder(src, VIWD_MODIFY_ORDERS);
Expand Down Expand Up @@ -1795,6 +1801,12 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
} else {
ClrBit(dst->vehicle_flags, VF_AUTOMATE_TIMETABLE);
}
/* Set auto separation bit if target has it. */
if (HasBit(src->vehicle_flags, VF_TIMETABLE_SEPARATION)) {
SetBit(dst->vehicle_flags, VF_TIMETABLE_SEPARATION);
} else {
ClrBit(dst->vehicle_flags, VF_TIMETABLE_SEPARATION);
}

InvalidateVehicleOrder(dst, VIWD_REMOVE_ALL_ORDERS);

Expand Down
4 changes: 2 additions & 2 deletions src/roadveh_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ CommandCost CmdBuildRoadVehicle(TileIndex tile, DoCommandFlag flags, const Engin

if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
v->SetServiceIntervalIsPercent(Company::Get(_current_company)->settings.vehicle.servint_ispercent);
SB(v->vehicle_flags, VF_AUTOMATE_TIMETABLE, 1,
_settings_game.order.timetable_automated && Company::Get(_current_company)->settings.vehicle.auto_timetable_by_default);
SB(v->vehicle_flags, VF_AUTOMATE_TIMETABLE, 1, Company::Get(_current_company)->settings.vehicle.auto_timetable_by_default);
SB(v->vehicle_flags, VF_TIMETABLE_SEPARATION, 1, Company::Get(_current_company)->settings.vehicle.auto_separation_by_default);

AddArticulatedParts(v);
v->InvalidateNewGRFCacheOfChain();
Expand Down
5 changes: 5 additions & 0 deletions src/saveload/afterload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,11 @@ bool AfterLoadGame()
}
}

if (SlXvIsFeaturePresent(XSLFI_AUTO_TIMETABLE, 1, 3)) {
Vehicle *v;
FOR_ALL_VEHICLES(v) SB(v->vehicle_flags, VF_TIMETABLE_SEPARATION, 1, _settings_game.order.old_timetable_separation);
}

/* Road stops is 'only' updating some caches */
AfterLoadRoadStops();
AfterLoadLabelMaps();
Expand Down
5 changes: 4 additions & 1 deletion src/saveload/company_sl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,13 @@ static void Load_PLYR()
SaveLoad_PLYR(c);
_company_colours[index] = (Colours)c->colour;

// setting moved from game settings to company settings
// settings 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;
}
if (SlXvIsFeaturePresent(XSLFI_AUTO_TIMETABLE, 1, 3)) {
c->settings.vehicle.auto_separation_by_default = _settings_game.order.old_timetable_separation;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/saveload/extended_ver_sl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
{ XSLFI_SIG_TUNNEL_BRIDGE, XSCF_NULL, 2, 2, "signal_tunnel_bridge", NULL, NULL, NULL },
{ XSLFI_IMPROVED_BREAKDOWNS, XSCF_NULL, 3, 3, "improved_breakdowns", NULL, NULL, NULL },
{ XSLFI_TT_WAIT_IN_DEPOT, XSCF_NULL, 1, 1, "tt_wait_in_depot", NULL, NULL, NULL },
{ XSLFI_AUTO_TIMETABLE, XSCF_NULL, 3, 3, "auto_timetables", NULL, NULL, NULL },
{ XSLFI_AUTO_TIMETABLE, XSCF_NULL, 4, 4, "auto_timetables", 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_INFRA_SHARING, XSCF_NULL, 1, 1, "infra_sharing", NULL, NULL, NULL },
Expand Down
4 changes: 2 additions & 2 deletions src/settings_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,9 @@ static SettingsContainer &GetSettingsTree()
company->Add(new SettingEntry("vehicle.servint_ships"));
company->Add(new SettingEntry("vehicle.servint_aircraft"));
company->Add(new SettingEntry("vehicle.auto_timetable_by_default"));
company->Add(new SettingEntry("vehicle.auto_separation_by_default"));
company->Add(new SettingEntry("auto_timetable_separation_rate"));
company->Add(new SettingEntry("timetable_autofill_rounding"));
company->Add(new SettingEntry("order_occupancy_smoothness"));
company->Add(new SettingEntry("company.infra_others_buy_in_depot[0]"));
company->Add(new SettingEntry("company.infra_others_buy_in_depot[1]"));
Expand Down Expand Up @@ -1688,8 +1690,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.timetable_automated"));
vehicles->Add(new SettingEntry("order.timetable_separation"));
vehicles->Add(new SettingEntry("vehicle.adjacent_crossings"));
}

Expand Down
5 changes: 3 additions & 2 deletions src/settings_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,10 @@ struct OrderSettings {
bool gradual_loading; ///< load vehicles gradually
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 timetable_automated; ///< whether to automatically manage timetables
bool timetable_separation; ///< whether to perform automatic separation based on timetable
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
bool old_timetable_separation; ///< moved to company settings: whether to perform automatic separation based on timetable
uint8 old_timetable_separation_rate; ///< moved to company settings: percentage of timetable separation change to apply
};

Expand Down Expand Up @@ -588,6 +587,7 @@ struct VehicleDefaultSettings {
uint16 servint_aircraft; ///< service interval for aircraft
uint16 servint_ships; ///< service interval for ships
bool auto_timetable_by_default; ///< use automatic timetables by default
bool auto_separation_by_default; ///< use automatic timetable separation by default
};

/** Settings that can be set per company. */
Expand All @@ -600,6 +600,7 @@ struct CompanySettings {
uint8 order_occupancy_smoothness; ///< percentage smoothness of occupancy measurement changes
uint8 auto_timetable_separation_rate; ///< percentage of auto timetable separation change to apply
bool infra_others_buy_in_depot[4]; ///< other companies can buy/autorenew in this companies depots (where infra sharing enabled)
uint16 timetable_autofill_rounding; ///< round up timetable times to be a multiple of this number of ticks
};

/** All settings together for the game. */
Expand Down
4 changes: 2 additions & 2 deletions src/ship_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,8 @@ CommandCost CmdBuildShip(TileIndex tile, DoCommandFlag flags, const Engine *e, u

if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
v->SetServiceIntervalIsPercent(Company::Get(_current_company)->settings.vehicle.servint_ispercent);
SB(v->vehicle_flags, VF_AUTOMATE_TIMETABLE, 1,
_settings_game.order.timetable_automated && Company::Get(_current_company)->settings.vehicle.auto_timetable_by_default);
SB(v->vehicle_flags, VF_AUTOMATE_TIMETABLE, 1, Company::Get(_current_company)->settings.vehicle.auto_timetable_by_default);
SB(v->vehicle_flags, VF_TIMETABLE_SEPARATION, 1, Company::Get(_current_company)->settings.vehicle.auto_separation_by_default);

v->InvalidateNewGRFCacheOfChain();

Expand Down
24 changes: 24 additions & 0 deletions src/table/company_settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ str = STR_CONFIG_SETTING_AUTO_TIMETABLE_BY_DEFAULT
strhelp = STR_CONFIG_SETTING_AUTO_TIMETABLE_BY_DEFAULT_HELPTEXT
patxname = ""vehicle.auto_timetable_by_default""

[SDT_BOOL]
base = CompanySettings
var = vehicle.auto_separation_by_default
guiflags = SGF_PER_COMPANY
def = true
str = STR_CONFIG_SETTING_TIMETABLE_SEPARATION_BY_DEFAULT
strhelp = STR_CONFIG_SETTING_TIMETABLE_SEPARATION_BY_DEFAULT_HELPTEXT
patxname = ""vehicle.auto_separation_by_default""

[SDT_VAR]
base = CompanySettings
var = auto_timetable_separation_rate
Expand All @@ -165,6 +174,21 @@ strval = STR_CONFIG_SETTING_PERCENTAGE
cat = SC_EXPERT
patxname = ""auto_timetable_separation_rate""

[SDT_VAR]
base = CompanySettings
var = timetable_autofill_rounding
type = SLE_UINT16
guiflags = SGF_PER_COMPANY
def = 74
min = 1
max = 1000
interval = 10
str = STR_CONFIG_SETTING_TIMETABLE_AUTOFILL_ROUNDING_TICKS
strhelp = STR_CONFIG_SETTING_TIMETABLE_AUTOFILL_ROUNDING_TICKS_HELPTEXT
strval = STR_JUST_INT
cat = SC_EXPERT
patxname = ""timetable_autofill_rounding""

[SDT_VAR]
base = CompanySettings
var = order_occupancy_smoothness
Expand Down
16 changes: 2 additions & 14 deletions src/table/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -349,22 +349,10 @@ extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_SPRINGPP)
[SDT_BOOL]
base = GameSettings
var = order.timetable_automated
var = order.old_timetable_separation
def = true
str = STR_CONFIG_SETTING_TIMETABLE_AUTOMATED
strhelp = STR_CONFIG_SETTING_TIMETABLE_AUTOMATED_HELPTEXT
cat = SC_EXPERT
extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_AUTO_TIMETABLE)
patxname = ""auto_timetables.order.timetable_automated""
[SDT_BOOL]
base = GameSettings
var = order.timetable_separation
def = true
str = STR_CONFIG_SETTING_TIMETABLE_SEPARATION
strhelp = STR_CONFIG_SETTING_TIMETABLE_SEPARATION_HELPTEXT
cat = SC_EXPERT
extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_AUTO_TIMETABLE)
extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_AUTO_TIMETABLE, 1, 3)
patxname = ""auto_timetables.order.timetable_separation""
[SDT_VAR]
Expand Down
Loading

0 comments on commit 4c5173b

Please sign in to comment.