Changeset - r8919:cac9f783953d
[Not reviewed]
master
0 5 0
rubidium - 17 years ago 2008-04-13 16:54:19
rubidium@openttd.org
(svn r12689) -Feature: non-stop(or rather no non-stop) and via orders for road vehicles.
5 files changed with 29 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/openttd.cpp
Show inline comments
 
@@ -2451,7 +2451,12 @@ bool AfterLoadGame()
 
		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;
src/order_cmd.cpp
Show inline comments
 
@@ -358,7 +358,7 @@ CommandCost CmdInsertOrder(TileIndex til
 
			}
 

	
 
			/* 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 @@ CommandCost CmdInsertOrder(TileIndex til
 
				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 @@ CommandCost CmdModifyOrder(TileIndex til
 
		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;
src/order_gui.cpp
Show inline comments
 
@@ -237,7 +237,7 @@ static void DrawOrdersWindow(Window *w)
 
				(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 @@ static void DrawOrdersWindow(Window *w)
 
					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 @@ static Order GetOrderCmdFromTile(const V
 
			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 @@ static Order GetOrderCmdFromTile(const V
 
			(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 @@ void ShowOrdersWindow(const Vehicle *v)
 
	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) {
src/roadveh_cmd.cpp
Show inline comments
 
@@ -1708,7 +1708,7 @@ again:
 
	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 @@ again:
 
		/* 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 @@ again:
 

	
 
			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 @@ again:
 
		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++;
src/station_cmd.cpp
Show inline comments
 
@@ -2406,9 +2406,9 @@ static const byte _enter_station_speedta
 
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 @@ static VehicleEnterTileStatus VehicleEnt
 
				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;
 

	
0 comments (0 inline, 0 general)