378 |
378 |
379 dep = FindClosestRoadDepot(v); |
379 dep = FindClosestRoadDepot(v); |
380 if (dep == NULL) return_cmd_error(STR_9019_UNABLE_TO_FIND_LOCAL_DEPOT); |
380 if (dep == NULL) return_cmd_error(STR_9019_UNABLE_TO_FIND_LOCAL_DEPOT); |
381 |
381 |
382 if (flags & DC_EXEC) { |
382 if (flags & DC_EXEC) { |
|
383 ClearSlot(v); |
|
384 v->vehstatus &= ~VS_WAIT_FOR_SLOT; |
383 v->current_order.type = OT_GOTO_DEPOT; |
385 v->current_order.type = OT_GOTO_DEPOT; |
384 v->current_order.flags = OF_NON_STOP | OF_HALT_IN_DEPOT; |
386 v->current_order.flags = OF_NON_STOP | OF_HALT_IN_DEPOT; |
385 v->current_order.station = dep->index; |
387 v->current_order.station = dep->index; |
386 v->dest_tile = dep->xy; |
388 v->dest_tile = dep->xy; |
387 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
389 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
403 |
405 |
404 v = GetVehicle(p1); |
406 v = GetVehicle(p1); |
405 |
407 |
406 if (v->type != VEH_Road || !CheckOwnership(v->owner)) return CMD_ERROR; |
408 if (v->type != VEH_Road || !CheckOwnership(v->owner)) return CMD_ERROR; |
407 |
409 |
408 if (v->vehstatus & (VS_HIDDEN | VS_STOPPED) || |
410 if (v->vehstatus & (VS_HIDDEN | VS_STOPPED | VS_WAIT_FOR_SLOT) || |
409 v->u.road.crashed_ctr != 0 || |
411 v->u.road.crashed_ctr != 0 || |
410 v->breakdown_ctr != 0 || |
412 v->breakdown_ctr != 0 || |
411 v->u.road.overtaking != 0 || |
413 v->u.road.overtaking != 0 || |
412 v->cur_speed < 5) { |
414 v->cur_speed < 5) { |
413 return CMD_ERROR; |
415 return CMD_ERROR; |
536 { |
538 { |
537 uint16 pass; |
539 uint16 pass; |
538 |
540 |
539 v->u.road.crashed_ctr++; |
541 v->u.road.crashed_ctr++; |
540 v->vehstatus |= VS_CRASHED; |
542 v->vehstatus |= VS_CRASHED; |
|
543 ClearSlot(v); |
541 |
544 |
542 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
545 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
543 |
546 |
544 pass = 1; |
547 pass = 1; |
545 if (v->cargo_type == CT_PASSENGERS) pass += v->cargo_count; |
548 if (v->cargo_type == CT_PASSENGERS) pass += v->cargo_count; |
920 if (FindRoadVehToOvertake(&od)) return; |
926 if (FindRoadVehToOvertake(&od)) return; |
921 |
927 |
922 od.tile = v->tile + TileOffsByDir(DirToDiagDir(v->direction)); |
928 od.tile = v->tile + TileOffsByDir(DirToDiagDir(v->direction)); |
923 if (FindRoadVehToOvertake(&od)) return; |
929 if (FindRoadVehToOvertake(&od)) return; |
924 |
930 |
925 if (od.u->cur_speed == 0 || od.u->vehstatus&VS_STOPPED) { |
931 if (od.u->cur_speed == 0 || od.u->vehstatus& (VS_STOPPED | VS_WAIT_FOR_SLOT)) { |
926 v->u.road.overtaking_ctr = 0x11; |
932 v->u.road.overtaking_ctr = 0x11; |
927 v->u.road.overtaking = 0x10; |
933 v->u.road.overtaking = 0x10; |
928 } else { |
934 } else { |
929 // if (FindRoadVehToOvertake(&od)) return; |
935 // if (FindRoadVehToOvertake(&od)) return; |
930 v->u.road.overtaking_ctr = 0; |
936 v->u.road.overtaking_ctr = 0; |
1446 return; |
1452 return; |
1447 } |
1453 } |
1448 v->current_order.type = OT_NOTHING; |
1454 v->current_order.type = OT_NOTHING; |
1449 v->current_order.flags = 0; |
1455 v->current_order.flags = 0; |
1450 ClearSlot(v); |
1456 ClearSlot(v); |
|
1457 v->vehstatus &= ~VS_WAIT_FOR_SLOT; |
1451 } |
1458 } |
1452 SETBIT(rs->status, 7); |
1459 SETBIT(rs->status, 7); |
1453 |
1460 |
1454 if (rs == v->u.road.slot) { |
1461 if (rs == v->u.road.slot) { |
1455 //we have arrived at the correct station |
1462 //we have arrived at the correct station |
1551 { |
1558 { |
1552 const Depot* depot; |
1559 const Depot* depot; |
1553 |
1560 |
1554 if (_patches.servint_roadveh == 0) return; |
1561 if (_patches.servint_roadveh == 0) return; |
1555 if (!VehicleNeedsService(v)) return; |
1562 if (!VehicleNeedsService(v)) return; |
1556 if (v->vehstatus & VS_STOPPED) return; |
1563 if (v->vehstatus & (VS_STOPPED | VS_WAIT_FOR_SLOT)) return; |
1557 if (_patches.gotodepot && VehicleHasDepotOrders(v)) return; |
1564 if (_patches.gotodepot && VehicleHasDepotOrders(v)) return; |
1558 |
1565 |
1559 // Don't interfere with a depot visit scheduled by the user, or a |
1566 // Don't interfere with a depot visit scheduled by the user, or a |
1560 // depot visit by the order list. |
1567 // depot visit by the order list. |
1561 if (v->current_order.type == OT_GOTO_DEPOT && |
1568 if (v->current_order.type == OT_GOTO_DEPOT && |
1608 v->u.road.slotindex, v->unitnumber, v->index, v->u.road.slot->xy |
1615 v->u.road.slotindex, v->unitnumber, v->index, v->u.road.slot->xy |
1609 ); |
1616 ); |
1610 ClearSlot(v); |
1617 ClearSlot(v); |
1611 } |
1618 } |
1612 |
1619 |
|
1620 if (v->vehstatus & VS_STOPPED) return; |
|
1621 |
1613 /* update destination */ |
1622 /* update destination */ |
1614 if (v->current_order.type == OT_GOTO_STATION && |
1623 if (v->current_order.type == OT_GOTO_STATION && |
1615 v->u.road.slot == NULL && |
1624 v->u.road.slot == NULL && |
1616 !(v->vehstatus & VS_CRASHED) && |
1625 !IsLevelCrossing(v->tile) && |
1617 !((v->vehstatus & (VS_STOPPED | VS_WAIT_FOR_SLOT)) == VS_STOPPED)) { |
1626 v->u.road.overtaking == 0 && |
|
1627 !(v->vehstatus & VS_CRASHED)) { |
1618 RoadStopType type = (v->cargo_type == CT_PASSENGERS) ? RS_BUS : RS_TRUCK; |
1628 RoadStopType type = (v->cargo_type == CT_PASSENGERS) ? RS_BUS : RS_TRUCK; |
1619 RoadStop *rs; |
1629 RoadStop *rs; |
1620 uint mindist = 0xFFFFFFFF; |
1630 uint mindist = 0xFFFFFFFF; |
1621 int i; |
1631 int i; |
1622 RoadStop *nearest = NULL; |
1632 RoadStop *nearest = NULL; |
1665 v->u.road.slot = nearest; |
1675 v->u.road.slot = nearest; |
1666 v->dest_tile = nearest->xy; |
1676 v->dest_tile = nearest->xy; |
1667 v->u.road.slot_age = 14; |
1677 v->u.road.slot_age = 14; |
1668 v->u.road.slotindex = new_slot; |
1678 v->u.road.slotindex = new_slot; |
1669 |
1679 |
1670 if (v->vehstatus & VS_STOPPED) { |
1680 if (v->vehstatus & VS_WAIT_FOR_SLOT) { |
1671 DEBUG(ms, 4) ("Multistop: ---- stopped vehicle got a slot. resuming movement"); |
1681 DEBUG(ms, 4) ("Multistop: ---- stopped vehicle got a slot. resuming movement"); |
1672 v->vehstatus &= ~(VS_STOPPED | VS_WAIT_FOR_SLOT); |
1682 v->vehstatus &= ~VS_WAIT_FOR_SLOT; |
1673 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
1683 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
1674 } |
1684 } |
1675 } else { |
1685 } else { |
1676 DEBUG(ms, 2) ("Multistop -- No free slot at station. Waiting"); |
1686 DEBUG(ms, 2) ("Multistop -- No free slot at station. Waiting"); |
1677 v->vehstatus |= (VS_STOPPED | VS_WAIT_FOR_SLOT); |
1687 v->vehstatus |= VS_WAIT_FOR_SLOT; |
1678 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
1688 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
1679 } |
1689 } |
1680 } else { |
1690 } else { |
1681 DEBUG(ms, 5) ("Multistop: --- Distance from station too far. Postponing slotting for vehicle %d (index %d) at station %d, (0x%x)", |
1691 DEBUG(ms, 5) ("Multistop: --- Distance from station too far. Postponing slotting for vehicle %d (index %d) at station %d, (0x%x)", |
1682 v->unitnumber, v->index, st->index, st->xy); |
1692 v->unitnumber, v->index, st->index, st->xy); |
1685 DEBUG(ms, 4) ("Multistop: No road stop for vehicle %d (index %d) at station %d (0x%x)", |
1695 DEBUG(ms, 4) ("Multistop: No road stop for vehicle %d (index %d) at station %d (0x%x)", |
1686 v->unitnumber, v->index, st->index, st->xy); |
1696 v->unitnumber, v->index, st->index, st->xy); |
1687 } |
1697 } |
1688 } |
1698 } |
1689 |
1699 |
1690 if (v->vehstatus & VS_STOPPED) return; |
|
1691 |
|
1692 cost = RoadVehInfo(v->engine_type)->running_cost * _price.roadveh_running / 364; |
1700 cost = RoadVehInfo(v->engine_type)->running_cost * _price.roadveh_running / 364; |
1693 |
1701 |
1694 v->profit_this_year -= cost >> 8; |
1702 v->profit_this_year -= cost >> 8; |
1695 |
1703 |
1696 SET_EXPENSES_TYPE(EXPENSES_ROADVEH_RUN); |
1704 SET_EXPENSES_TYPE(EXPENSES_ROADVEH_RUN); |