当前位置: 首页>>代码示例>>C++>>正文


C++ Order::GetTimetabledTravel方法代码示例

本文整理汇总了C++中Order::GetTimetabledTravel方法的典型用法代码示例。如果您正苦于以下问题:C++ Order::GetTimetabledTravel方法的具体用法?C++ Order::GetTimetabledTravel怎么用?C++ Order::GetTimetabledTravel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Order的用法示例。


在下文中一共展示了Order::GetTimetabledTravel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ChangeTimetable

/**
 * Change/update a particular timetable entry.
 * @param v            The vehicle to change the timetable of.
 * @param order_number The index of the timetable in the order list.
 * @param val          The new data of the timetable entry.
 * @param mtf          Which part of the timetable entry to change.
 * @param timetabled   If the new value is explicitly timetabled.
 */
static void ChangeTimetable(Vehicle *v, VehicleOrderID order_number, uint16 val, ModifyTimetableFlags mtf, bool timetabled)
{
    Order *order = v->GetOrder(order_number);
    int total_delta = 0;
    int timetable_delta = 0;

    switch (mtf) {
    case MTF_WAIT_TIME:
        total_delta = val - order->GetWaitTime();
        timetable_delta = (timetabled ? val : 0) - order->GetTimetabledWait();
        order->SetWaitTime(val);
        order->SetWaitTimetabled(timetabled);
        break;

    case MTF_TRAVEL_TIME:
        total_delta = val - order->GetTravelTime();
        timetable_delta = (timetabled ? val : 0) - order->GetTimetabledTravel();
        order->SetTravelTime(val);
        order->SetTravelTimetabled(timetabled);
        break;

    case MTF_TRAVEL_SPEED:
        order->SetMaxSpeed(val);
        break;

    default:
        NOT_REACHED();
    }
    v->orders.list->UpdateTotalDuration(total_delta);
    v->orders.list->UpdateTimetableDuration(timetable_delta);

    for (v = v->FirstShared(); v != NULL; v = v->NextShared()) {
        if (v->cur_real_order_index == order_number && v->current_order.Equals(*order)) {
            switch (mtf) {
            case MTF_WAIT_TIME:
                v->current_order.SetWaitTime(val);
                v->current_order.SetWaitTimetabled(timetabled);
                break;

            case MTF_TRAVEL_TIME:
                v->current_order.SetTravelTime(val);
                v->current_order.SetTravelTimetabled(timetabled);
                break;

            case MTF_TRAVEL_SPEED:
                v->current_order.SetMaxSpeed(val);
                break;

            default:
                NOT_REACHED();
            }
        }
        SetWindowDirty(WC_VEHICLE_TIMETABLE, v->index);
    }
}
开发者ID:J0anJosep,项目名称:OpenTTD,代码行数:63,代码来源:timetable_cmd.cpp


注:本文中的Order::GetTimetabledTravel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。