Merge branch 'auto_timetables-sx' into jgrpp

Conflicts:
	src/vehicle.cpp
pull/6/merge
Jonathan G Rennison 9 years ago
commit cd23d17745

@ -369,7 +369,7 @@ static const Command _command_proc_table[] = {
DEF_CMD(CmdChangeTimetable, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_CHANGE_TIMETABLE DEF_CMD(CmdChangeTimetable, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_CHANGE_TIMETABLE
DEF_CMD(CmdSetVehicleOnTime, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_VEHICLE_ON_TIME DEF_CMD(CmdSetVehicleOnTime, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_VEHICLE_ON_TIME
DEF_CMD(CmdAutofillTimetable, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_AUTOFILL_TIMETABLE DEF_CMD(CmdAutofillTimetable, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_AUTOFILL_TIMETABLE
DEF_CMD(CmdAutomateTimetable, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_AUTOMATE_TIMETABLE] DEF_CMD(CmdAutomateTimetable, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_AUTOMATE_TIMETABLE
DEF_CMD(CmdSetTimetableStart, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_TIMETABLE_START DEF_CMD(CmdSetTimetableStart, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_TIMETABLE_START
DEF_CMD(CmdOpenCloseAirport, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_OPEN_CLOSE_AIRPORT DEF_CMD(CmdOpenCloseAirport, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_OPEN_CLOSE_AIRPORT

@ -4424,7 +4424,7 @@ STR_TIMETABLE_AUTOFILL :{BLACK}Autofill
STR_TIMETABLE_AUTOFILL_TOOLTIP :{BLACK}Fill the timetable automatically with the values from the next journey (Ctrl+Click to try to keep waiting times) STR_TIMETABLE_AUTOFILL_TOOLTIP :{BLACK}Fill the timetable automatically with the values from the next journey (Ctrl+Click to try to keep waiting times)
STR_TIMETABLE_AUTOMATE :{BLACK}Automate STR_TIMETABLE_AUTOMATE :{BLACK}Automate
STR_TIMETABLE_AUTOMATE_TOOLTIP :{BLACK}Manage the timetables automatically by updating the values for each journey 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_EXPECTED :{BLACK}Expected STR_TIMETABLE_EXPECTED :{BLACK}Expected
STR_TIMETABLE_SCHEDULED :{BLACK}Scheduled STR_TIMETABLE_SCHEDULED :{BLACK}Scheduled

@ -1220,7 +1220,7 @@ CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
InvalidateVehicleOrder(v, VIWD_MODIFY_ORDERS); InvalidateVehicleOrder(v, VIWD_MODIFY_ORDERS);
if (_settings_game.order.timetable_separation) v->ClearSeparation(); v->ClearSeparation();
if (_settings_game.order.timetable_separation) ClrBit(v->vehicle_flags, VF_TIMETABLE_STARTED); if (_settings_game.order.timetable_separation) ClrBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
} }
@ -1716,7 +1716,7 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
SetBit(dst->vehicle_flags, VF_AUTOMATE_TIMETABLE); SetBit(dst->vehicle_flags, VF_AUTOMATE_TIMETABLE);
} }
if (_settings_game.order.timetable_separation) dst->ClearSeparation(); dst->ClearSeparation();
if (_settings_game.order.timetable_separation) ClrBit(dst->vehicle_flags, VF_TIMETABLE_STARTED); if (_settings_game.order.timetable_separation) ClrBit(dst->vehicle_flags, VF_TIMETABLE_STARTED);
InvalidateVehicleOrder(dst, VIWD_REMOVE_ALL_ORDERS); InvalidateVehicleOrder(dst, VIWD_REMOVE_ALL_ORDERS);

@ -268,9 +268,9 @@ static int CDECL VehicleTimetableSorter(Vehicle * const *ap, Vehicle * const *bp
* Set the start date of the timetable. * Set the start date of the timetable.
* @param tile Not used. * @param tile Not used.
* @param flags Operation to perform. * @param flags Operation to perform.
* @param p2 Various bitstuffed elements * @param p1 Various bitstuffed elements
* - p2 = (bit 0-19) - Vehicle ID. * - p1 = (bit 0-19) - Vehicle ID.
* - p2 = (bit 20) - Set to 1 to set timetable start for all vehicles sharing this order * - p1 = (bit 20) - Set to 1 to set timetable start for all vehicles sharing this order
* @param p2 The timetable start date. * @param p2 The timetable start date.
* @param text Not used. * @param text Not used.
* @return The error or cost of the operation. * @return The error or cost of the operation.
@ -442,8 +442,8 @@ CommandCost CmdAutomateTimetable(TileIndex index, DoCommandFlag flags, uint32 p1
OrderList *orders = v2->orders.list; OrderList *orders = v2->orders.list;
if (orders != NULL) { if (orders != NULL) {
for (int i = 0; i < orders->GetNumOrders(); i++) { for (int i = 0; i < orders->GetNumOrders(); i++) {
ChangeTimetable(v2, i, 0, MTF_WAIT_TIME, true); ChangeTimetable(v2, i, 0, MTF_WAIT_TIME, false);
ChangeTimetable(v2, i, 0, MTF_TRAVEL_TIME, true); ChangeTimetable(v2, i, 0, MTF_TRAVEL_TIME, false);
} }
} }
} }
@ -603,7 +603,7 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling)
/* Start automated timetables at first opportunity */ /* Start automated timetables at first opportunity */
if (!HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED) && HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)) { if (!HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED) && HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)) {
if (_settings_game.order.timetable_separation) v->ClearSeparation(); v->ClearSeparation();
SetBit(v->vehicle_flags, VF_TIMETABLE_STARTED); SetBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
v->lateness_counter = 0; v->lateness_counter = 0;
if (_settings_game.order.timetable_separation) UpdateSeparationOrder(v); if (_settings_game.order.timetable_separation) UpdateSeparationOrder(v);
@ -696,7 +696,7 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling)
* Otherwise we risk trains blocking 1-lane stations for long times. */ * Otherwise we risk trains blocking 1-lane stations for long times. */
ChangeTimetable(v, v->cur_real_order_index, 0, travelling ? MTF_TRAVEL_TIME : MTF_WAIT_TIME, true); ChangeTimetable(v, v->cur_real_order_index, 0, travelling ? MTF_TRAVEL_TIME : MTF_WAIT_TIME, true);
for (Vehicle *v2 = v->FirstShared(); v2 != NULL; v2 = v2->NextShared()) { for (Vehicle *v2 = v->FirstShared(); v2 != NULL; v2 = v2->NextShared()) {
if (_settings_game.order.timetable_separation) v2->ClearSeparation(); v2->ClearSeparation();
ClrBit(v2->vehicle_flags, VF_TIMETABLE_STARTED); ClrBit(v2->vehicle_flags, VF_TIMETABLE_STARTED);
SetWindowDirty(WC_VEHICLE_TIMETABLE, v2->index); SetWindowDirty(WC_VEHICLE_TIMETABLE, v2->index);
} }

@ -650,7 +650,7 @@ struct TimetableWindow : Window {
case WID_VT_AUTOMATE: { case WID_VT_AUTOMATE: {
uint32 p2 = 0; uint32 p2 = 0;
if (!HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)) SetBit(p2, 0); if (!HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)) SetBit(p2, 0);
if (!_ctrl_pressed) SetBit(p2, 1); if (_ctrl_pressed) SetBit(p2, 1);
DoCommandP(0, v->index, p2, CMD_AUTOMATE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE)); DoCommandP(0, v->index, p2, CMD_AUTOMATE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
break; break;
} }

@ -265,8 +265,8 @@ uint Vehicle::Crash(bool flooded)
v->MarkAllViewportsDirty(); v->MarkAllViewportsDirty();
} }
this->ClearSeparation();
if (_settings_game.order.timetable_separation) { if (_settings_game.order.timetable_separation) {
this->ClearSeparation();
ClrBit(this->vehicle_flags, VF_TIMETABLE_STARTED); ClrBit(this->vehicle_flags, VF_TIMETABLE_STARTED);
} }
@ -2618,8 +2618,8 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command)
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
if (!(this->current_order.GetDepotOrderType() & ODTFB_BREAKDOWN)) this->current_order.SetDepotOrderType(ODTF_MANUAL); if (!(this->current_order.GetDepotOrderType() & ODTFB_BREAKDOWN)) this->current_order.SetDepotOrderType(ODTF_MANUAL);
this->current_order.SetDepotActionType(halt_in_depot ? ODATF_SERVICE_ONLY : ODATFB_HALT); this->current_order.SetDepotActionType(halt_in_depot ? ODATF_SERVICE_ONLY : ODATFB_HALT);
this->ClearSeparation();
if (_settings_game.order.timetable_separation) { if (_settings_game.order.timetable_separation) {
this->ClearSeparation();
ClrBit(this->vehicle_flags, VF_TIMETABLE_STARTED); ClrBit(this->vehicle_flags, VF_TIMETABLE_STARTED);
} }
SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP); SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP);
@ -2642,8 +2642,8 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command)
if (this->current_order.GetDepotOrderType() & ODTFB_BREAKDOWN) { if (this->current_order.GetDepotOrderType() & ODTFB_BREAKDOWN) {
this->current_order.SetDepotActionType(this->current_order.GetDepotActionType() == ODATFB_HALT ? ODATF_SERVICE_ONLY : ODATFB_HALT); this->current_order.SetDepotActionType(this->current_order.GetDepotActionType() == ODATFB_HALT ? ODATF_SERVICE_ONLY : ODATFB_HALT);
} else { } else {
this->ClearSeparation();
if (_settings_game.order.timetable_separation) { if (_settings_game.order.timetable_separation) {
this->ClearSeparation();
ClrBit(this->vehicle_flags, VF_TIMETABLE_STARTED); ClrBit(this->vehicle_flags, VF_TIMETABLE_STARTED);
} }
@ -3102,7 +3102,7 @@ void Vehicle::RemoveFromShared()
this->next_shared = NULL; this->next_shared = NULL;
this->previous_shared = NULL; this->previous_shared = NULL;
if (_settings_game.order.timetable_separation) this->ClearSeparation(); this->ClearSeparation();
if (_settings_game.order.timetable_separation) ClrBit(this->vehicle_flags, VF_TIMETABLE_STARTED); if (_settings_game.order.timetable_separation) ClrBit(this->vehicle_flags, VF_TIMETABLE_STARTED);
} }

@ -606,7 +606,7 @@ CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
if (v->IsStoppedInDepot() && (flags & DC_AUTOREPLACE) == 0) DeleteVehicleNews(p1, STR_NEWS_TRAIN_IS_WAITING + v->type); if (v->IsStoppedInDepot() && (flags & DC_AUTOREPLACE) == 0) DeleteVehicleNews(p1, STR_NEWS_TRAIN_IS_WAITING + v->type);
if (_settings_game.order.timetable_separation) v->ClearSeparation(); v->ClearSeparation();
if (_settings_game.order.timetable_separation) ClrBit(v->vehicle_flags, VF_TIMETABLE_STARTED); if (_settings_game.order.timetable_separation) ClrBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
v->vehstatus ^= VS_STOPPED; v->vehstatus ^= VS_STOPPED;

Loading…
Cancel
Save