Mercurial > hg > openttd
changeset 8919:f15d5f7bf51b draft
(svn r12689) -Feature: non-stop(or rather no non-stop) and via orders for road vehicles.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sun, 13 Apr 2008 16:54:19 +0000 |
parents | 64cb6c5091c6 |
children | b0c0088d17d2 |
files | src/openttd.cpp src/order_cmd.cpp src/order_gui.cpp src/roadveh_cmd.cpp src/station_cmd.cpp |
diffstat | 5 files changed, 29 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -2451,7 +2451,12 @@ FOR_ALL_ORDERS(order) order->ConvertFromOldSavegame(); Vehicle *v; - FOR_ALL_VEHICLES(v) v->current_order.ConvertFromOldSavegame(); + FOR_ALL_VEHICLES(v) { + v->current_order.ConvertFromOldSavegame(); + if (v->type == VEH_ROAD && v->IsPrimaryVehicle() && v->prev_shared == NULL) { + FOR_VEHICLE_ORDERS(v, order) order->SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS); + } + } } else if (CheckSavegameVersion(94)) { /* Unload and transfer are now mutual exclusive. */ Order *order;
--- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -358,7 +358,7 @@ } /* Non stop not allowed for non-trains. */ - if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN) return CMD_ERROR; + if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN && v->type != VEH_ROAD) return CMD_ERROR; /* Full load and unload are mutual exclusive. */ if ((new_order.GetLoadType() & OLFB_FULL_LOAD) && (new_order.GetUnloadType() & OUFB_UNLOAD)) return CMD_ERROR; @@ -412,7 +412,7 @@ if (!IsPlayerBuildableVehicleType(v)) return CMD_ERROR; } - if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN) return CMD_ERROR; + if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN && v->type != VEH_ROAD) return CMD_ERROR; if (new_order.GetDepotOrderType() & ~ODTFB_PART_OF_ORDERS) return CMD_ERROR; if (new_order.GetDepotActionType() & ~ODATFB_NEAREST_DEPOT) return CMD_ERROR; break; @@ -869,6 +869,7 @@ default: NOT_REACHED(); case MOF_NON_STOP: + if (v->type != VEH_TRAIN && v->type != VEH_ROAD) return CMD_ERROR; if (data >= ONSF_END) return CMD_ERROR; if (data == order->GetNonStopType()) return CMD_ERROR; break;
--- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -237,7 +237,7 @@ (uint)v->num_orders + ((shared_orders || v->num_orders != 0) ? 1 : 0) <= (uint)WP(w, order_d).sel); /* non-stop only for trains */ - w->SetWidgetDisabledState(ORDER_WIDGET_NON_STOP, v->type != VEH_TRAIN || order == NULL); + w->SetWidgetDisabledState(ORDER_WIDGET_NON_STOP, (v->type != VEH_TRAIN && v->type != VEH_ROAD) || order == NULL); w->SetWidgetDisabledState(ORDER_WIDGET_FULL_LOAD, order == NULL || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // full load w->SetWidgetDisabledState(ORDER_WIDGET_UNLOAD, order == NULL || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // unload /* Disable list of vehicles with the same shared orders if there is no list */ @@ -325,7 +325,7 @@ OrderUnloadFlags unload = order->GetUnloadType(); SetDParam(1, STR_GO_TO_STATION); - SetDParam(2, STR_ORDER_GO_TO + (v->type == VEH_TRAIN ? order->GetNonStopType() : 0)); + SetDParam(2, STR_ORDER_GO_TO + ((v->type == VEH_TRAIN || v->type == VEH_ROAD) ? order->GetNonStopType() : 0)); SetDParam(3, order->GetDestination()); SetDParam(4, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) ? STR_EMPTY : _station_load_types[unload][load]); } break; @@ -431,6 +431,7 @@ case MP_ROAD: if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_player)) { order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS); + if (_patches.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS); return order; } break; @@ -481,7 +482,7 @@ (facil = FACIL_TRUCK_STOP, 1); if (st->facilities & facil) { order.MakeGoToStation(st_index); - if (_patches.new_nonstop && v->type == VEH_TRAIN) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS); + if (_patches.new_nonstop && (v->type == VEH_TRAIN || v->type == VEH_ROAD)) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS); return order; } } @@ -1169,7 +1170,7 @@ if (v->owner != _local_player) { w = AllocateWindowDescFront(&_other_orders_desc, veh); } else { - w = AllocateWindowDescFront((v->type == VEH_TRAIN) ? &_orders_train_desc : &_orders_desc, veh); + w = AllocateWindowDescFront((v->type == VEH_TRAIN || v->type == VEH_ROAD) ? &_orders_train_desc : &_orders_desc, veh); } if (w != NULL) {
--- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -1708,7 +1708,7 @@ if (IsRoadVehFront(v) && ((IsInsideMM(v->u.road.state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END) && _road_veh_data_1[v->u.road.state - RVSB_IN_ROAD_STOP + (_opt.road_side << RVS_DRIVE_SIDE)] == v->u.road.frame) || (IsInsideMM(v->u.road.state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) && - v->current_order.GetDestination() == GetStationIndex(v->tile) && + v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile)) && GetRoadStopType(v->tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK) && v->u.road.frame == RVC_DRIVE_THROUGH_STOP_FRAME))) { @@ -1718,8 +1718,7 @@ /* Vehicle is at the stop position (at a bay) in a road stop. * Note, if vehicle is loading/unloading it has already been handled, * so if we get here the vehicle has just arrived or is just ready to leave. */ - if (!v->current_order.IsType(OT_LEAVESTATION) && - !v->current_order.IsType(OT_GOTO_DEPOT)) { + if (!v->current_order.IsType(OT_LEAVESTATION)) { /* Vehicle has arrived at a bay in a road stop */ if (IsDriveThroughStopTile(v->tile)) { @@ -1747,10 +1746,15 @@ rs->SetEntranceBusy(false); - v->last_station_visited = GetStationIndex(v->tile); + v->last_station_visited = st->index; - RoadVehArrivesAt(v, st); - v->BeginLoading(); + if (IsDriveThroughStopTile(v->tile) || v->current_order.GetDestination() == st->index) { + RoadVehArrivesAt(v, st); + v->BeginLoading(); + } else { + v->current_order.MakeLeaveStation(); + InvalidateVehicleOrder(v); + } return false; } @@ -1806,6 +1810,8 @@ return false; } + if (v->current_order.IsType(OT_LEAVESTATION) && IsDriveThroughStopTile(v->tile)) v->current_order.Free(); + /* Move to next frame unless vehicle arrived at a stop position * in a depot or entered a tunnel/bridge */ if (!HasBit(r, VETS_ENTERED_WORMHOLE)) v->u.road.frame++;
--- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2406,9 +2406,9 @@ static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y) { StationID station_id = GetStationIndex(tile); - if (!v->current_order.ShouldStopAtStation(v, station_id)) return VETSB_CONTINUE; if (v->type == VEH_TRAIN) { + if (!v->current_order.ShouldStopAtStation(v, station_id)) return VETSB_CONTINUE; if (IsRailwayStation(tile) && IsFrontEngine(v) && !IsCompatibleTrainStationTile(tile + TileOffsByDiagDir(DirToDiagDir(v->direction)), tile)) { DiagDirection dir = DirToDiagDir(v->direction); @@ -2436,6 +2436,8 @@ RoadStop *rs = GetRoadStopByTile(tile, GetRoadStopType(tile)); if (IsDriveThroughStopTile(tile)) { + if (!v->current_order.ShouldStopAtStation(v, station_id)) return VETSB_CONTINUE; + /* Vehicles entering a drive-through stop from the 'normal' side use first bay (bay 0). */ byte side = ((DirToDiagDir(v->direction) == ReverseDiagDir(GetRoadStopDir(tile))) == (v->u.road.overtaking == 0)) ? 0 : 1;