Changeset - r8919:cac9f783953d
[Not reviewed]
master
0 5 0
rubidium - 16 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
 
@@ -2448,13 +2448,18 @@ bool AfterLoadGame()
 
	if (CheckSavegameVersion(93)) {
 
		/* Rework of orders. */
 
		Order *order;
 
		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;
 
		FOR_ALL_ORDERS(order) {
 
			if ((order->GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) {
 
				order->SetUnloadType(OUFB_TRANSFER);
src/order_cmd.cpp
Show inline comments
 
@@ -355,13 +355,13 @@ CommandCost CmdInsertOrder(TileIndex til
 
					break;
 

	
 
				default: return CMD_ERROR;
 
			}
 

	
 
			/* 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;
 

	
 
			/* Filter invalid load/unload types. */
 
			switch (new_order.GetLoadType()) {
 
@@ -409,13 +409,13 @@ CommandCost CmdInsertOrder(TileIndex til
 
					}
 
				}
 
			} else {
 
				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;
 
		}
 

	
 
		case OT_GOTO_WAYPOINT: {
 
@@ -866,12 +866,13 @@ CommandCost CmdModifyOrder(TileIndex til
 
	}
 

	
 
	switch (mof) {
 
		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;
 

	
 
		case MOF_UNLOAD:
 
			if ((data & ~(OUFB_UNLOAD | OUFB_TRANSFER | OUFB_NO_UNLOAD)) != 0) return CMD_ERROR;
src/order_gui.cpp
Show inline comments
 
@@ -234,13 +234,13 @@ static void DrawOrdersWindow(Window *w)
 

	
 
		/* delete */
 
		w->SetWidgetDisabledState(ORDER_WIDGET_DELETE,
 
				(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 */
 
		w->SetWidgetDisabledState(ORDER_WIDGET_SHARED_ORDER_LIST, !shared_orders || v->orders == NULL);
 
		w->SetWidgetDisabledState(ORDER_WIDGET_REFIT,     order == NULL); // Refit
 
		w->SetWidgetDisabledState(ORDER_WIDGET_SERVICE,   order == NULL); // Refit
 
@@ -322,13 +322,13 @@ static void DrawOrdersWindow(Window *w)
 

	
 
				case OT_GOTO_STATION: {
 
					OrderLoadFlags load = order->GetLoadType();
 
					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;
 

	
 
				case OT_GOTO_DEPOT:
 
					if (v->type == VEH_AIRCRAFT) {
 
@@ -428,12 +428,13 @@ static Order GetOrderCmdFromTile(const V
 
				}
 
				break;
 

	
 
			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;
 

	
 
			case MP_STATION:
 
				if (v->type != VEH_AIRCRAFT) break;
 
@@ -478,13 +479,13 @@ static Order GetOrderCmdFromTile(const V
 
			(facil = FACIL_TRAIN, v->type == VEH_TRAIN) ||
 
			(facil = FACIL_AIRPORT, v->type == VEH_AIRCRAFT) ||
 
			(facil = FACIL_BUS_STOP, v->type == VEH_ROAD && IsCargoInClass(v->cargo_type, CC_PASSENGERS)) ||
 
			(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;
 
			}
 
		}
 
	}
 

	
 
	/* not found */
 
@@ -1166,13 +1167,13 @@ void ShowOrdersWindow(const Vehicle *v)
 
	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
 
	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
 

	
 
	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) {
 
		w->caption_color = v->owner;
 
		w->vscroll.cap = 6;
 
		w->resize.step_height = 10;
src/roadveh_cmd.cpp
Show inline comments
 
@@ -1705,24 +1705,23 @@ again:
 
	 * and it's the correct type of stop (bus or truck) and the frame equals the stop frame...
 
	 * (the station test and stop type test ensure that other vehicles, using the road stop as
 
	 * a through route, do not stop) */
 
	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))) {
 

	
 
		RoadStop *rs = GetRoadStopByTile(v->tile, GetRoadStopType(v->tile));
 
		Station* st = GetStationByTile(v->tile);
 

	
 
		/* 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)) {
 
				TileIndex next_tile = TILE_ADD(v->tile, TileOffsByDir(v->direction));
 
				RoadStopType type = IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK;
 

	
 
@@ -1744,16 +1743,21 @@ 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;
 
		}
 

	
 
		/* Vehicle is ready to leave a bay in a road stop */
 
		if (!v->current_order.IsType(OT_GOTO_DEPOT)) {
 
@@ -1803,12 +1807,14 @@ again:
 
	r = VehicleEnterTile(v, v->tile, x, y);
 
	if (HasBit(r, VETS_CANNOT_ENTER)) {
 
		v->cur_speed = 0;
 
		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++;
 

	
 
	v->cur_image = v->GetImage(v->direction);
 
	v->UpdateDeltaXY(v->direction);
src/station_cmd.cpp
Show inline comments
 
@@ -2403,15 +2403,15 @@ static const byte _enter_station_speedta
 
	215, 195, 175, 155, 135, 115, 95, 75, 55, 35, 15, 0
 
};
 

	
 
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);
 

	
 
			x &= 0xF;
 
			y &= 0xF;
 
@@ -2433,12 +2433,14 @@ static VehicleEnterTileStatus VehicleEnt
 
		if (v->u.road.state < RVSB_IN_ROAD_STOP && !IsReversingRoadTrackdir((Trackdir)v->u.road.state) && v->u.road.frame == 0) {
 
			if (IsRoadStop(tile) && IsRoadVehFront(v)) {
 
				/* Attempt to allocate a parking bay in a road stop */
 
				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;
 

	
 
					if (!rs->IsFreeBay(side)) return VETSB_CANNOT_ENTER;
 

	
 
					/* Check if the vehicle is stopping at this road stop */
0 comments (0 inline, 0 general)