diff options
-rw-r--r-- | lang/english.txt | 1 | ||||
-rw-r--r-- | roadveh_cmd.c | 32 | ||||
-rw-r--r-- | roadveh_gui.c | 2 |
3 files changed, 23 insertions, 12 deletions
diff --git a/lang/english.txt b/lang/english.txt index 86a7b85f3..5347a46a8 100644 --- a/lang/english.txt +++ b/lang/english.txt @@ -2465,6 +2465,7 @@ STR_8860_RELIABILITY_BREAKDOWNS :{BLACK}Reliabil STR_8861_STOPPED :{RED}Stopped STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL :{WHITE}Can't make train pass signal at danger... STR_8863_CRASHED :{RED}Crashed! +STR_8864_WAIT_FOR_SLOT :{YELLOW}Waiting for a free stop STR_8865_NAME_TRAIN :{WHITE}Name train STR_8866_CAN_T_NAME_TRAIN :{WHITE}Can't name train... diff --git a/roadveh_cmd.c b/roadveh_cmd.c index 676ea0d9b..070695f6b 100644 --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -380,6 +380,8 @@ int32 CmdSendRoadVehToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (dep == NULL) return_cmd_error(STR_9019_UNABLE_TO_FIND_LOCAL_DEPOT); if (flags & DC_EXEC) { + ClearSlot(v); + v->vehstatus &= ~VS_WAIT_FOR_SLOT; v->current_order.type = OT_GOTO_DEPOT; v->current_order.flags = OF_NON_STOP | OF_HALT_IN_DEPOT; v->current_order.station = dep->index; @@ -405,7 +407,7 @@ int32 CmdTurnRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (v->type != VEH_Road || !CheckOwnership(v->owner)) return CMD_ERROR; - if (v->vehstatus & (VS_HIDDEN | VS_STOPPED) || + if (v->vehstatus & (VS_HIDDEN | VS_STOPPED | VS_WAIT_FOR_SLOT) || v->u.road.crashed_ctr != 0 || v->breakdown_ctr != 0 || v->u.road.overtaking != 0 || @@ -538,6 +540,7 @@ static void RoadVehCrash(Vehicle *v) v->u.road.crashed_ctr++; v->vehstatus |= VS_CRASHED; + ClearSlot(v); InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); @@ -629,6 +632,7 @@ static void ProcessRoadVehOrder(Vehicle *v) v->current_order.flags = 0; v->dest_tile = 0; ClearSlot(v); + v->vehstatus &= ~VS_WAIT_FOR_SLOT; return; } @@ -640,6 +644,8 @@ static void ProcessRoadVehOrder(Vehicle *v) v->current_order = *order; v->dest_tile = 0; + /* We have changed the destination STATION, so resume movement */ + v->vehstatus &= ~VS_WAIT_FOR_SLOT; if (order->type == OT_GOTO_STATION) { const Station* st = GetStation(order->station); @@ -900,7 +906,7 @@ static void RoadVehCheckOvertake(Vehicle *v, Vehicle *u) od.u = u; if (u->max_speed >= v->max_speed && - !(u->vehstatus & VS_STOPPED) && + !(u->vehstatus & (VS_STOPPED | VS_WAIT_FOR_SLOT)) && u->cur_speed != 0) { return; } @@ -922,7 +928,7 @@ static void RoadVehCheckOvertake(Vehicle *v, Vehicle *u) od.tile = v->tile + TileOffsByDir(DirToDiagDir(v->direction)); if (FindRoadVehToOvertake(&od)) return; - if (od.u->cur_speed == 0 || od.u->vehstatus&VS_STOPPED) { + if (od.u->cur_speed == 0 || od.u->vehstatus& (VS_STOPPED | VS_WAIT_FOR_SLOT)) { v->u.road.overtaking_ctr = 0x11; v->u.road.overtaking = 0x10; } else { @@ -1185,7 +1191,7 @@ static void RoadVehController(Vehicle *v) v->breakdown_ctr--; } - if (v->vehstatus & VS_STOPPED) return; + if (v->vehstatus & (VS_STOPPED | VS_WAIT_FOR_SLOT)) return; ProcessRoadVehOrder(v); HandleRoadVehLoading(v); @@ -1448,6 +1454,7 @@ again: v->current_order.type = OT_NOTHING; v->current_order.flags = 0; ClearSlot(v); + v->vehstatus &= ~VS_WAIT_FOR_SLOT; } SETBIT(rs->status, 7); @@ -1553,7 +1560,7 @@ static void CheckIfRoadVehNeedsService(Vehicle *v) if (_patches.servint_roadveh == 0) return; if (!VehicleNeedsService(v)) return; - if (v->vehstatus & VS_STOPPED) return; + if (v->vehstatus & (VS_STOPPED | VS_WAIT_FOR_SLOT)) return; if (_patches.gotodepot && VehicleHasDepotOrders(v)) return; // Don't interfere with a depot visit scheduled by the user, or a @@ -1610,11 +1617,14 @@ void OnNewDay_RoadVeh(Vehicle *v) ClearSlot(v); } + if (v->vehstatus & VS_STOPPED) return; + /* update destination */ if (v->current_order.type == OT_GOTO_STATION && v->u.road.slot == NULL && - !(v->vehstatus & VS_CRASHED) && - !((v->vehstatus & (VS_STOPPED | VS_WAIT_FOR_SLOT)) == VS_STOPPED)) { + !IsLevelCrossing(v->tile) && + v->u.road.overtaking == 0 && + !(v->vehstatus & VS_CRASHED)) { RoadStopType type = (v->cargo_type == CT_PASSENGERS) ? RS_BUS : RS_TRUCK; RoadStop *rs; uint mindist = 0xFFFFFFFF; @@ -1667,14 +1677,14 @@ void OnNewDay_RoadVeh(Vehicle *v) v->u.road.slot_age = 14; v->u.road.slotindex = new_slot; - if (v->vehstatus & VS_STOPPED) { + if (v->vehstatus & VS_WAIT_FOR_SLOT) { DEBUG(ms, 4) ("Multistop: ---- stopped vehicle got a slot. resuming movement"); - v->vehstatus &= ~(VS_STOPPED | VS_WAIT_FOR_SLOT); + v->vehstatus &= ~VS_WAIT_FOR_SLOT; InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); } } else { DEBUG(ms, 2) ("Multistop -- No free slot at station. Waiting"); - v->vehstatus |= (VS_STOPPED | VS_WAIT_FOR_SLOT); + v->vehstatus |= VS_WAIT_FOR_SLOT; InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); } } else { @@ -1687,8 +1697,6 @@ void OnNewDay_RoadVeh(Vehicle *v) } } - if (v->vehstatus & VS_STOPPED) return; - cost = RoadVehInfo(v->engine_type)->running_cost * _price.roadveh_running / 364; v->profit_this_year -= cost >> 8; diff --git a/roadveh_gui.c b/roadveh_gui.c index 0d5344495..32f53d364 100644 --- a/roadveh_gui.c +++ b/roadveh_gui.c @@ -247,6 +247,8 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e) str = STR_885C_BROKEN_DOWN; } else if (v->vehstatus & VS_STOPPED) { str = STR_8861_STOPPED; + } else if (v->vehstatus & VS_WAIT_FOR_SLOT) { + str = STR_8864_WAIT_FOR_SLOT; } else { switch (v->current_order.type) { case OT_GOTO_STATION: { |