1332 |
1332 |
1333 /* 2.1 If the first wagon is sold, update the first-> pointers to NULL */ |
1333 /* 2.1 If the first wagon is sold, update the first-> pointers to NULL */ |
1334 for (Vehicle *tmp = first; tmp != NULL; tmp = tmp->next) tmp->first = NULL; |
1334 for (Vehicle *tmp = first; tmp != NULL; tmp = tmp->next) tmp->first = NULL; |
1335 |
1335 |
1336 /* 2.2 If there are wagons present after the deleted front engine, check |
1336 /* 2.2 If there are wagons present after the deleted front engine, check |
1337 * if the second wagon (which will be first) is an engine. If it is one, |
1337 * if the second wagon (which will be first) is an engine. If it is one, |
1338 * promote it as a new train, retaining the unitnumber, orders */ |
1338 * promote it as a new train, retaining the unitnumber, orders */ |
1339 if (new_f != NULL) { |
1339 if (new_f != NULL && IsTrainEngine(new_f)) { |
1340 if (IsTrainEngine(new_f)) { |
1340 switch_engine = true; |
1341 switch_engine = true; |
1341 /* Copy important data from the front engine */ |
1342 /* Copy important data from the front engine */ |
1342 new_f->unitnumber = first->unitnumber; |
1343 new_f->unitnumber = first->unitnumber; |
1343 new_f->current_order = first->current_order; |
1344 new_f->current_order = first->current_order; |
1344 new_f->cur_order_index = first->cur_order_index; |
1345 new_f->cur_order_index = first->cur_order_index; |
1345 new_f->orders = first->orders; |
1346 new_f->orders = first->orders; |
1346 new_f->num_orders = first->num_orders; |
1347 if (first->prev_shared != NULL) { |
1347 |
1348 first->prev_shared->next_shared = new_f; |
1348 if (first->prev_shared != NULL) { |
1349 new_f->prev_shared = first->prev_shared; |
1349 first->prev_shared->next_shared = new_f; |
1350 } |
1350 new_f->prev_shared = first->prev_shared; |
1351 |
|
1352 if (first->next_shared != NULL) { |
|
1353 first->next_shared->prev_shared = new_f; |
|
1354 new_f->next_shared = first->next_shared; |
|
1355 } |
|
1356 |
|
1357 new_f->num_orders = first->num_orders; |
|
1358 first->orders = NULL; // XXX - to not to delete the orders */ |
|
1359 if (IsLocalPlayer()) ShowTrainViewWindow(new_f); |
|
1360 } |
1351 } |
|
1352 |
|
1353 if (first->next_shared != NULL) { |
|
1354 first->next_shared->prev_shared = new_f; |
|
1355 new_f->next_shared = first->next_shared; |
|
1356 } |
|
1357 |
|
1358 /* |
|
1359 * Remove all order information from the front train, to |
|
1360 * prevent the order and the shared order list to be |
|
1361 * destroyed by Destroy/DeleteVehicle. |
|
1362 */ |
|
1363 first->orders = NULL; |
|
1364 first->prev_shared = NULL; |
|
1365 first->next_shared = NULL; |
|
1366 |
|
1367 if (IsLocalPlayer()) ShowTrainViewWindow(new_f); |
1361 } |
1368 } |
1362 } |
1369 } |
1363 |
1370 |
1364 /* 3. Delete the requested wagon */ |
1371 /* 3. Delete the requested wagon */ |
1365 cost -= v->value; |
1372 cost -= v->value; |
2156 /* We do not check for dest_coords if we have a station_index, |
2163 /* We do not check for dest_coords if we have a station_index, |
2157 * because in that case the dest_coords are just an |
2164 * because in that case the dest_coords are just an |
2158 * approximation of where the station is */ |
2165 * approximation of where the station is */ |
2159 // found station |
2166 // found station |
2160 ttfd->best_track = track; |
2167 ttfd->best_track = track; |
|
2168 ttfd->best_bird_dist = 0; |
2161 return true; |
2169 return true; |
2162 } else { |
2170 } else { |
2163 // didn't find station, keep track of the best path so far. |
2171 // didn't find station, keep track of the best path so far. |
2164 uint dist = DistanceManhattan(tile, ttfd->dest_coords); |
2172 uint dist = DistanceManhattan(tile, ttfd->dest_coords); |
2165 if (dist < ttfd->best_bird_dist) { |
2173 if (dist < ttfd->best_bird_dist) { |
3204 |
3212 |
3205 InvalidateWindow(WC_VEHICLE_VIEW, v->index); |
3213 InvalidateWindow(WC_VEHICLE_VIEW, v->index); |
3206 InvalidateWindow(WC_VEHICLE_DETAILS, v->index); |
3214 InvalidateWindow(WC_VEHICLE_DETAILS, v->index); |
3207 |
3215 |
3208 if (!PlayVehicleSound(v, VSE_BREAKDOWN)) { |
3216 if (!PlayVehicleSound(v, VSE_BREAKDOWN)) { |
3209 SndPlayVehicleFx((_opt.landscape != LT_CANDY) ? |
3217 SndPlayVehicleFx((_opt.landscape != LT_TOYLAND) ? |
3210 SND_10_TRAIN_BREAKDOWN : SND_3A_COMEDY_BREAKDOWN_2, v); |
3218 SND_10_TRAIN_BREAKDOWN : SND_3A_COMEDY_BREAKDOWN_2, v); |
3211 } |
3219 } |
3212 |
3220 |
3213 if (!(v->vehstatus & VS_HIDDEN)) { |
3221 if (!(v->vehstatus & VS_HIDDEN)) { |
3214 Vehicle *u = CreateEffectVehicleRel(v, 4, 4, 5, EV_BREAKDOWN_SMOKE); |
3222 Vehicle *u = CreateEffectVehicleRel(v, 4, 4, 5, EV_BREAKDOWN_SMOKE); |