src/timetable_cmd.cpp
branchnoai
changeset 9724 b39bc69bb2f2
parent 9723 eee46cb39750
child 9800 ab08ca2a2018
equal deleted inserted replaced
9723:eee46cb39750 9724:b39bc69bb2f2
     3 /** @file timetable_cmd.cpp */
     3 /** @file timetable_cmd.cpp */
     4 
     4 
     5 #include "stdafx.h"
     5 #include "stdafx.h"
     6 #include "openttd.h"
     6 #include "openttd.h"
     7 #include "variables.h"
     7 #include "variables.h"
     8 #include "table/strings.h"
       
     9 #include "command_func.h"
     8 #include "command_func.h"
    10 #include "player.h"
       
    11 #include "functions.h"
     9 #include "functions.h"
    12 #include "window_func.h"
    10 #include "window_func.h"
    13 #include "vehicle_func.h"
    11 #include "vehicle_func.h"
    14 #include "vehicle_base.h"
    12 #include "vehicle_base.h"
       
    13 #include "settings_type.h"
    15 
    14 
       
    15 #include "table/strings.h"
    16 
    16 
    17 static void ChangeTimetable(Vehicle *v, VehicleOrderID order_number, uint16 time, bool is_journey)
    17 static void ChangeTimetable(Vehicle *v, VehicleOrderID order_number, uint16 time, bool is_journey)
    18 {
    18 {
    19 	Order *order = GetVehicleOrder(v, order_number);
    19 	Order *order = GetVehicleOrder(v, order_number);
    20 
    20 
    22 		order->travel_time = time;
    22 		order->travel_time = time;
    23 	} else {
    23 	} else {
    24 		order->wait_time = time;
    24 		order->wait_time = time;
    25 	}
    25 	}
    26 
    26 
    27 	if (v->cur_order_index == order_number && HasBit(v->current_order.flags, OFB_PART_OF_ORDERS)) {
    27 	if (v->cur_order_index == order_number && HasBit(v->current_order.flags, OF_PART_OF_ORDERS)) {
    28 		if (is_journey) {
    28 		if (is_journey) {
    29 			v->current_order.travel_time = time;
    29 			v->current_order.travel_time = time;
    30 		} else {
    30 		} else {
    31 			v->current_order.wait_time = time;
    31 			v->current_order.wait_time = time;
    32 		}
    32 		}
    63 	if (order == NULL) return CMD_ERROR;
    63 	if (order == NULL) return CMD_ERROR;
    64 
    64 
    65 	bool is_journey = HasBit(p1, 24);
    65 	bool is_journey = HasBit(p1, 24);
    66 	if (!is_journey) {
    66 	if (!is_journey) {
    67 		if (order->type != OT_GOTO_STATION) return_cmd_error(STR_TIMETABLE_ONLY_WAIT_AT_STATIONS);
    67 		if (order->type != OT_GOTO_STATION) return_cmd_error(STR_TIMETABLE_ONLY_WAIT_AT_STATIONS);
    68 		if (_patches.new_nonstop && (order->flags & OF_NON_STOP)) return_cmd_error(STR_TIMETABLE_NOT_STOPPING_HERE);
    68 		if (_patches.new_nonstop && (order->flags & OFB_NON_STOP)) return_cmd_error(STR_TIMETABLE_NOT_STOPPING_HERE);
    69 	}
    69 	}
    70 
    70 
    71 	if (flags & DC_EXEC) {
    71 	if (flags & DC_EXEC) {
    72 		ChangeTimetable(v, order_number, p2, is_journey);
    72 		ChangeTimetable(v, order_number, p2, is_journey);
    73 	}
    73 	}