(svn r13752) -Fix [FS#2130]: correctly restore conditional orders when they are put 'into' backup.

This commit is contained in:
rubidium
2008-07-20 07:41:43 +00:00
parent 67275acdff
commit 019cfc5ba8
4 changed files with 79 additions and 16 deletions

View File

@@ -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();