1341 |
1341 |
1342 /* 2.1 If the first wagon is sold, update the first-> pointers to NULL */ |
1342 /* 2.1 If the first wagon is sold, update the first-> pointers to NULL */ |
1343 for (tmp = first; tmp != NULL; tmp = tmp->next) tmp->first = NULL; |
1343 for (tmp = first; tmp != NULL; tmp = tmp->next) tmp->first = NULL; |
1344 |
1344 |
1345 /* 2.2 If there are wagons present after the deleted front engine, check |
1345 /* 2.2 If there are wagons present after the deleted front engine, check |
1346 * if the second wagon (which will be first) is an engine. If it is one, |
1346 * if the second wagon (which will be first) is an engine. If it is one, |
1347 * promote it as a new train, retaining the unitnumber, orders */ |
1347 * promote it as a new train, retaining the unitnumber, orders */ |
1348 if (new_f != NULL) { |
1348 if (new_f != NULL) { |
1349 if (IsTrainEngine(new_f)) { |
1349 if (IsTrainEngine(new_f)) { |
1350 switch_engine = true; |
1350 switch_engine = true; |
1351 /* Copy important data from the front engine */ |
1351 /* Copy important data from the front engine */ |
1352 new_f->unitnumber = first->unitnumber; |
1352 new_f->unitnumber = first->unitnumber; |
1900 ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, last->tile, trackdir_rev, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes, NPF_INFINITE_PENALTY); |
1900 ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, last->tile, trackdir_rev, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes, NPF_INFINITE_PENALTY); |
1901 if (ftd.best_bird_dist == 0) { |
1901 if (ftd.best_bird_dist == 0) { |
1902 /* Found target */ |
1902 /* Found target */ |
1903 tfdd.tile = ftd.node.tile; |
1903 tfdd.tile = ftd.node.tile; |
1904 /* Our caller expects a number of tiles, so we just approximate that |
1904 /* Our caller expects a number of tiles, so we just approximate that |
1905 * number by this. It might not be completely what we want, but it will |
1905 * number by this. It might not be completely what we want, but it will |
1906 * work for now :-) We can possibly change this when the old pathfinder |
1906 * work for now :-) We can possibly change this when the old pathfinder |
1907 * is removed. */ |
1907 * is removed. */ |
1908 tfdd.best_length = ftd.best_path_dist / NPF_TILE_LENGTH; |
1908 tfdd.best_length = ftd.best_path_dist / NPF_TILE_LENGTH; |
1909 if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) tfdd.reverse = true; |
1909 if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) tfdd.reverse = true; |
1910 } |
1910 } |
1911 } else { |
1911 } else { |
1912 // search in the forward direction first. |
1912 // search in the forward direction first. |
1958 if (v->vehstatus & VS_CRASHED) return CMD_ERROR; |
1958 if (v->vehstatus & VS_CRASHED) return CMD_ERROR; |
1959 |
1959 |
1960 if (v->current_order.type == OT_GOTO_DEPOT) { |
1960 if (v->current_order.type == OT_GOTO_DEPOT) { |
1961 if (!!(p2 & DEPOT_SERVICE) == HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) { |
1961 if (!!(p2 & DEPOT_SERVICE) == HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) { |
1962 /* We called with a different DEPOT_SERVICE setting. |
1962 /* We called with a different DEPOT_SERVICE setting. |
1963 * Now we change the setting to apply the new one and let the vehicle head for the same depot. |
1963 * Now we change the setting to apply the new one and let the vehicle head for the same depot. |
1964 * Note: the if is (true for requesting service == true for ordered to stop in depot) */ |
1964 * Note: the if is (true for requesting service == true for ordered to stop in depot) */ |
1965 if (flags & DC_EXEC) { |
1965 if (flags & DC_EXEC) { |
1966 TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT); |
1966 TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT); |
1967 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
1967 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
1968 } |
1968 } |
1969 return 0; |
1969 return 0; |