1281 /* Restore vehicle order-index and service interval */ |
1281 /* Restore vehicle order-index and service interval */ |
1282 DoCommandP(0, v->index, bak->orderindex | (bak->service_interval << 16) , NULL, CMD_RESTORE_ORDER_INDEX); |
1282 DoCommandP(0, v->index, bak->orderindex | (bak->service_interval << 16) , NULL, CMD_RESTORE_ORDER_INDEX); |
1283 |
1283 |
1284 /* Restore vehicle group */ |
1284 /* Restore vehicle group */ |
1285 DoCommandP(0, bak->group, v->index, NULL, CMD_ADD_VEHICLE_GROUP); |
1285 DoCommandP(0, bak->group, v->index, NULL, CMD_ADD_VEHICLE_GROUP); |
|
1286 } |
|
1287 |
|
1288 /** Restores vehicle orders that was previously backed up by BackupVehicleOrders() |
|
1289 * This will restore to the point where it was at the time of the backup meaning |
|
1290 * it will presume the same order indexes can be used. |
|
1291 * This is needed when restoring a backed up vehicle |
|
1292 * @param v The vehicle that should gain the orders |
|
1293 * @param bak the backup of the orders |
|
1294 */ |
|
1295 void RestoreVehicleOrdersBruteForce(Vehicle *v, const BackuppedOrders *bak) |
|
1296 { |
|
1297 if (bak->name != NULL) { |
|
1298 /* Restore the name. */ |
|
1299 v->name = strdup(bak->name); |
|
1300 } |
|
1301 |
|
1302 /* If we had shared orders, recover that */ |
|
1303 if (bak->clone != INVALID_VEHICLE) { |
|
1304 /* We will place it at the same location in the linked list as it previously was. */ |
|
1305 if (v->prev_shared != NULL) { |
|
1306 assert(v->prev_shared->next_shared == v->next_shared); |
|
1307 v->prev_shared->next_shared = v; |
|
1308 } |
|
1309 if (v->next_shared != NULL) { |
|
1310 assert(v->next_shared->prev_shared == v->prev_shared); |
|
1311 v->next_shared->prev_shared = v; |
|
1312 } |
|
1313 } else { |
|
1314 /* Restore the orders at the indexes they originally were. */ |
|
1315 for (Order *order = bak->order; order->IsValid(); order++) { |
|
1316 Order *dst = GetOrder(order->index); |
|
1317 /* Since we are restoring something we removed a moment ago all the orders should be free. */ |
|
1318 assert(!dst->IsValid()); |
|
1319 memcpy(dst, order, sizeof(Order)); |
|
1320 } |
|
1321 } |
1286 } |
1322 } |
1287 |
1323 |
1288 /** Restore the current order-index of a vehicle and sets service-interval. |
1324 /** Restore the current order-index of a vehicle and sets service-interval. |
1289 * @param tile unused |
1325 * @param tile unused |
1290 * @param flags operation to perform |
1326 * @param flags operation to perform |