982 } |
982 } |
983 |
983 |
984 /* If we had shared orders, recover that */ |
984 /* If we had shared orders, recover that */ |
985 if (bak->clone != INVALID_VEHICLE) { |
985 if (bak->clone != INVALID_VEHICLE) { |
986 DoCommandP(0, v->index | (bak->clone << 16), 0, NULL, CMD_CLONE_ORDER); |
986 DoCommandP(0, v->index | (bak->clone << 16), 0, NULL, CMD_CLONE_ORDER); |
987 return; |
987 } else { |
988 } |
988 |
989 |
989 /* CMD_NO_TEST_IF_IN_NETWORK is used here, because CMD_INSERT_ORDER checks if the |
990 /* CMD_NO_TEST_IF_IN_NETWORK is used here, because CMD_INSERT_ORDER checks if the |
990 * order number is one more than the current amount of orders, and because |
991 * order number is one more than the current amount of orders, and because |
991 * in network the commands are queued before send, the second insert always |
992 * in network the commands are queued before send, the second insert always |
992 * fails in test mode. By bypassing the test-mode, that no longer is a problem. */ |
993 * fails in test mode. By bypassing the test-mode, that no longer is a problem. */ |
993 for (uint i = 0; bak->order[i].IsValid(); i++) { |
994 for (uint i = 0; bak->order[i].IsValid(); i++) { |
994 if (!DoCommandP(0, v->index + (i << 16), PackOrder(&bak->order[i]), NULL, |
995 if (!DoCommandP(0, v->index + (i << 16), PackOrder(&bak->order[i]), NULL, CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK)) |
995 CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK)) |
996 break; |
996 break; |
|
997 } |
997 } |
998 } |
998 |
999 |
999 /* Restore vehicle order-index and service interval */ |
1000 /* Restore vehicle order-index and service interval */ |
1000 DoCommandP(0, v->index, bak->orderindex | (bak->service_interval << 16) , NULL, CMD_RESTORE_ORDER_INDEX); |
1001 DoCommandP(0, v->index, bak->orderindex | (bak->service_interval << 16) , NULL, CMD_RESTORE_ORDER_INDEX); |
1001 } |
1002 } |