Changeset - r16773:b3301f1d5bbb
[Not reviewed]
master
0 9 0
terkhen - 14 years ago 2010-12-14 21:26:03
terkhen@openttd.org
(svn r21516) -Codechange: Add IsGroundVehicle function to the Vehicle class.
9 files changed with 27 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/depot_gui.cpp
Show inline comments
 
@@ -305,7 +305,7 @@ struct DepotWindow : Window {
 
		}
 

	
 
		uint diff_x, diff_y;
 
		if (v->type == VEH_TRAIN || v->type == VEH_ROAD) {
 
		if (v->IsGroundVehicle()) {
 
			/* Arrange unitnumber and flag horizontally */
 
			diff_x = this->flag_width + WD_FRAMERECT_LEFT;
 
			diff_y = (this->resize.step_height - this->flag_height) / 2 - 2;
src/disaster_cmd.cpp
Show inline comments
 
@@ -506,7 +506,7 @@ static bool DisasterTick_Big_Ufo(Disaste
 

	
 
		Vehicle *target;
 
		FOR_ALL_VEHICLES(target) {
 
			if (target->type == VEH_TRAIN || target->type == VEH_ROAD) {
 
			if (target->IsGroundVehicle()) {
 
				if (Delta(target->x_pos, v->x_pos) + Delta(target->y_pos, v->y_pos) <= 12 * (int)TILE_SIZE) {
 
					target->breakdown_ctr = 5;
 
					target->breakdown_delay = 0xF0;
src/newgrf_engine.cpp
Show inline comments
 
@@ -611,7 +611,7 @@ static uint32 VehicleGetVariable(const R
 
			 * B - current wagon to next wagon, 0 if wagon is last
 
			 * T - previous wagon to next wagon, 0 in an S-bend
 
			 */
 
			if (v->type != VEH_TRAIN && v->type != VEH_ROAD) return 0;
 
			if (!v->IsGroundVehicle()) return 0;
 

	
 
			const Vehicle *u_p = v->Previous();
 
			const Vehicle *u_n = v->Next();
src/order_cmd.cpp
Show inline comments
 
@@ -485,8 +485,8 @@ CommandCost CmdInsertOrder(TileIndex til
 
				if (!CanVehicleUseStation(u, st)) return_cmd_error(STR_ERROR_CAN_T_ADD_ORDER_SHARED);
 
			}
 

	
 
			/* Non stop not allowed for non-trains. */
 
			if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN && v->type != VEH_ROAD) return CMD_ERROR;
 
			/* Non stop only allowed for ground vehicles. */
 
			if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && !v->IsGroundVehicle()) return CMD_ERROR;
 

	
 
			/* No load and no unload are mutual exclusive. */
 
			if ((new_order.GetLoadType() & OLFB_NO_LOAD) && (new_order.GetUnloadType() & OUFB_NO_UNLOAD)) return CMD_ERROR;
 
@@ -556,7 +556,7 @@ CommandCost CmdInsertOrder(TileIndex til
 
				}
 
			}
 

	
 
			if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN && v->type != VEH_ROAD) return CMD_ERROR;
 
			if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && !v->IsGroundVehicle()) return CMD_ERROR;
 
			if (new_order.GetDepotOrderType() & ~(ODTFB_PART_OF_ORDERS | ((new_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) != 0 ? ODTFB_SERVICE : 0))) return CMD_ERROR;
 
			if (new_order.GetDepotActionType() & ~(ODATFB_HALT | ODATFB_NEAREST_DEPOT)) return CMD_ERROR;
 
			if ((new_order.GetDepotOrderType() & ODTFB_SERVICE) && (new_order.GetDepotActionType() & ODATFB_HALT)) return CMD_ERROR;
 
@@ -973,7 +973,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 (!v->IsGroundVehicle()) 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
 
@@ -216,7 +216,7 @@ void DrawOrderString(const Vehicle *v, c
 
			OrderUnloadFlags unload = order->GetUnloadType();
 

	
 
			SetDParam(0, STR_ORDER_GO_TO_STATION);
 
			SetDParam(1, STR_ORDER_GO_TO + ((v->type == VEH_TRAIN || v->type == VEH_ROAD) ? order->GetNonStopType() : 0));
 
			SetDParam(1, STR_ORDER_GO_TO + (v->IsGroundVehicle() ? order->GetNonStopType() : 0));
 
			SetDParam(2, order->GetDestination());
 

	
 
			if (timetable) {
 
@@ -382,7 +382,7 @@ static Order GetOrderCmdFromTile(const V
 
			if (st->facilities & facil) {
 
				order.MakeGoToStation(st_index);
 
				if (_ctrl_pressed) order.SetLoadType(OLF_FULL_LOAD_ANY);
 
				if (_settings_client.gui.new_nonstop && (v->type == VEH_TRAIN || v->type == VEH_ROAD)) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 
				if (_settings_client.gui.new_nonstop && v->IsGroundVehicle()) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 
				order.SetStopLocation(v->type == VEH_TRAIN ? (OrderStopLocation)(_settings_client.gui.stop_location) : OSL_PLATFORM_FAR_END);
 
				return order;
 
			}
 
@@ -572,7 +572,7 @@ private:
 
		order.next = NULL;
 
		order.index = 0;
 
		order.MakeGoToDepot(0, ODTFB_PART_OF_ORDERS,
 
				_settings_client.gui.new_nonstop && (this->vehicle->type == VEH_TRAIN || this->vehicle->type == VEH_ROAD) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
 
				_settings_client.gui.new_nonstop && this->vehicle->IsGroundVehicle() ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
 
		order.SetDepotActionType(ODATFB_NEAREST_DEPOT);
 

	
 
		DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER));
 
@@ -647,7 +647,7 @@ private:
 
	 */
 
	void OrderClick_Nonstop(int non_stop)
 
	{
 
		if (this->vehicle->type != VEH_TRAIN && this->vehicle->type != VEH_ROAD) return;
 
		if (!this->vehicle->IsGroundVehicle()) return;
 

	
 
		VehicleOrderID sel_ord = this->OrderGetSel();
 
		const Order *order = this->vehicle->GetOrder(sel_ord);
 
@@ -1605,6 +1605,6 @@ void ShowOrdersWindow(const Vehicle *v)
 
	if (v->owner != _local_company) {
 
		new OrdersWindow(&_other_orders_desc, v);
 
	} else {
 
		new OrdersWindow((v->type == VEH_TRAIN || v->type == VEH_ROAD) ? &_orders_train_desc : &_orders_desc, v);
 
		new OrdersWindow(v->IsGroundVehicle() ? &_orders_train_desc : &_orders_desc, v);
 
	}
 
}
src/pathfinder/npf/npf.cpp
Show inline comments
 
@@ -1101,7 +1101,7 @@ static void NPFFillWithOrderData(NPFFind
 
	 * So only for train orders to stations we fill fstd->station_index, for all
 
	 * others only dest_coords */
 
	if (v->type != VEH_SHIP && (v->current_order.IsType(OT_GOTO_STATION) || v->current_order.IsType(OT_GOTO_WAYPOINT))) {
 
		assert(v->type == VEH_TRAIN || v->type == VEH_ROAD);
 
		assert(v->IsGroundVehicle());
 
		fstd->station_index = v->current_order.GetDestination();
 
		fstd->station_type = (v->type == VEH_TRAIN) ? (v->current_order.IsType(OT_GOTO_STATION) ? STATION_RAIL : STATION_WAYPOINT) : (RoadVehicle::From(v)->IsBus() ? STATION_BUS : STATION_TRUCK);
 
		fstd->not_articulated = v->type == VEH_ROAD && !RoadVehicle::From(v)->HasArticulatedPart();
src/saveload/afterload.cpp
Show inline comments
 
@@ -1025,7 +1025,7 @@ bool AfterLoadGame()
 
		}
 

	
 
		FOR_ALL_VEHICLES(v) {
 
			if (v->type != VEH_TRAIN && v->type != VEH_ROAD) continue;
 
			if (!v->IsGroundVehicle()) continue;
 
			if (IsBridgeTile(v->tile)) {
 
				DiagDirection dir = GetTunnelBridgeDirection(v->tile);
 

	
src/vehicle_base.h
Show inline comments
 
@@ -360,6 +360,15 @@ public:
 
	}
 

	
 
	/**
 
	 * Check if the vehicle is a ground vehicle.
 
	 * @return True iff the vehicle is a train or a road vehicle.
 
	 */
 
	FORCEINLINE bool IsGroundVehicle() const
 
	{
 
		return this->type == VEH_TRAIN || this->type == VEH_ROAD;
 
	}
 

	
 
	/**
 
	 * Gets the speed in km-ish/h that can be sent into SetDParam for string processing.
 
	 * @return the vehicle's speed
 
	 */
src/vehicle_gui.cpp
Show inline comments
 
@@ -435,7 +435,7 @@ struct RefitWindow : public Window {
 
				}
 
				current_index++;
 
			}
 
		} while ((v->type == VEH_TRAIN || v->type == VEH_ROAD) && (v = v->Next()) != NULL);
 
		} while (v->IsGroundVehicle() && (v = v->Next()) != NULL);
 

	
 
		int scroll_size = 0;
 
		for (uint i = 0; i < NUM_CARGO; i++) {
 
@@ -2033,7 +2033,7 @@ static bool IsVehicleRefitable(const Veh
 

	
 
	do {
 
		if (IsEngineRefittable(v->engine_type)) return true;
 
	} while ((v->type == VEH_TRAIN || v->type == VEH_ROAD) && (v = v->Next()) != NULL);
 
	} while (v->IsGroundVehicle() && (v = v->Next()) != NULL);
 

	
 
	return false;
 
}
 
@@ -2311,7 +2311,7 @@ public:
 
										CcCloneVehicle);
 
				break;
 
			case VVW_WIDGET_TURN_AROUND: // turn around
 
				assert(v->type == VEH_TRAIN || v->type == VEH_ROAD);
 
				assert(v->IsGroundVehicle());
 
				DoCommandP(v->tile, v->index, 0,
 
										_vehicle_command_translation_table[VCT_CMD_TURN_AROUND][v->type]);
 
				break;
 
@@ -2345,7 +2345,7 @@ public:
 
			this->SetWidgetDirty(VVW_WIDGET_SELECT_DEPOT_CLONE);
 
		}
 
		/* The same system applies to widget VVW_WIDGET_REFIT_VEH and VVW_WIDGET_TURN_AROUND.*/
 
		if (v->type == VEH_ROAD || v->type == VEH_TRAIN) {
 
		if (v->IsGroundVehicle()) {
 
			PlaneSelections plane = veh_stopped ? SEL_RT_REFIT : SEL_RT_TURN_AROUND;
 
			NWidgetStacked *nwi = this->GetWidget<NWidgetStacked>(VVW_WIDGET_SELECT_REFIT_TURN);
 
			if (nwi->shown_plane + SEL_RT_BASEPLANE != plane) {
0 comments (0 inline, 0 general)