diff options
author | rubidium <rubidium@openttd.org> | 2008-07-20 07:41:43 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-07-20 07:41:43 +0000 |
commit | a6e314bbba071b8a8b12d13b8c1960903aae77f8 (patch) | |
tree | 0176bb93916d02a71d214b03389e84540c98c92c /src/timetable_cmd.cpp | |
parent | 7c3fc1308771e4f8ea89328b0323a75239515366 (diff) | |
download | openttd-a6e314bbba071b8a8b12d13b8c1960903aae77f8.tar.xz |
(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.
Diffstat (limited to 'src/timetable_cmd.cpp')
-rw-r--r-- | src/timetable_cmd.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp index 98c13a609..03217a809 100644 --- a/src/timetable_cmd.cpp +++ b/src/timetable_cmd.cpp @@ -68,16 +68,36 @@ CommandCost CmdChangeTimetable(TileIndex tile, uint32 flags, uint32 p1, uint32 p bool packed_time = HasBit(p1, 25); bool is_journey = HasBit(p1, 24) || packed_time; - if (!is_journey) { - if (!order->IsType(OT_GOTO_STATION) && !order->IsType(OT_CONDITIONAL)) return_cmd_error(STR_TIMETABLE_ONLY_WAIT_AT_STATIONS); - if (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) return_cmd_error(STR_TIMETABLE_NOT_STOPPING_HERE); + + uint16 wait_time = 0; + uint16 travel_time = 0; + if (packed_time) { + travel_time = GB(p2, 0, 16); + wait_time = GB(p2, 16, 16);; + } else if (is_journey) { + travel_time = GB(p2, 0, 16); } else { - if (order->IsType(OT_CONDITIONAL)) return CMD_ERROR; + wait_time = GB(p2, 0, 16); } + if (wait_time != 0) { + switch (order->GetType()) { + case OT_GOTO_STATION: + if (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) return_cmd_error(STR_TIMETABLE_NOT_STOPPING_HERE); + break; + + case OT_CONDITIONAL: + break; + + default: return_cmd_error(STR_TIMETABLE_ONLY_WAIT_AT_STATIONS); + } + } + + if (travel_time != 0 && order->IsType(OT_CONDITIONAL)) return CMD_ERROR; + if (flags & DC_EXEC) { - ChangeTimetable(v, order_number, GB(p2, 0, 16), is_journey); - if (packed_time) ChangeTimetable(v, order_number, GB(p2, 16, 16), false); + if (wait_time != 0) ChangeTimetable(v, order_number, wait_time, false); + if (travel_time != 0) ChangeTimetable(v, order_number, travel_time, true); } return CommandCost(); |