Changeset - r13842:5f8f28d5f86b
[Not reviewed]
master
0 8 0
frosch - 15 years ago 2009-12-02 17:37:02
frosch@openttd.org
(svn r18381) -Codechange: Add RoadVehicle::IsBus() to simplify some stuff.
8 files changed with 25 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/network/network_server.cpp
Show inline comments
 
@@ -25,13 +25,13 @@
 
#include "../station_base.h"
 
#include "../genworld.h"
 
#include "../fileio_func.h"
 
#include "../company_func.h"
 
#include "../company_gui.h"
 
#include "../window_func.h"
 
#include "../cargotype.h"
 
#include "../roadveh.h"
 

	
 
#include "table/strings.h"
 

	
 
/* This file handles all the server-commands */
 

	
 
static void NetworkHandleCommandQueue(NetworkClientSocket *cs);
 
@@ -1365,13 +1365,13 @@ void NetworkPopulateCompanyStats(Network
 
	/* Go through all vehicles and count the type of vehicles */
 
	FOR_ALL_VEHICLES(v) {
 
		if (!Company::IsValidID(v->owner) || !v->IsPrimaryVehicle()) continue;
 
		byte type = 0;
 
		switch (v->type) {
 
			case VEH_TRAIN: type = 0; break;
 
			case VEH_ROAD: type = IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? 2 : 1; break;
 
			case VEH_ROAD: type = RoadVehicle::From(v)->IsBus() ? 2 : 1; break;
 
			case VEH_AIRCRAFT: type = 3; break;
 
			case VEH_SHIP: type = 4; break;
 
			default: continue;
 
		}
 
		stats[v->owner].num_vehicle[type]++;
 
	}
src/order_cmd.cpp
Show inline comments
 
@@ -12,13 +12,12 @@
 
#include "stdafx.h"
 
#include "debug.h"
 
#include "command_func.h"
 
#include "company_func.h"
 
#include "news_func.h"
 
#include "vehicle_gui.h"
 
#include "cargotype.h"
 
#include "strings_func.h"
 
#include "functions.h"
 
#include "window_func.h"
 
#include "timetable.h"
 
#include "vehicle_func.h"
 
#include "depot_base.h"
 
@@ -1137,13 +1136,13 @@ CommandCost CmdCloneOrder(TileIndex tile
 
			/* Sanity checks */
 
			if (src == NULL || !CheckOwnership(src->owner) || dst->type != src->type || dst == src) {
 
				return CMD_ERROR;
 
			}
 

	
 
			/* Trucks can't share orders with busses (and visa versa) */
 
			if (src->type == VEH_ROAD && IsCargoInClass(src->cargo_type, CC_PASSENGERS) != IsCargoInClass(dst->cargo_type, CC_PASSENGERS)) {
 
			if (src->type == VEH_ROAD && RoadVehicle::From(src)->IsBus() != RoadVehicle::From(dst)->IsBus()) {
 
				return CMD_ERROR;
 
			}
 

	
 
			/* Is the vehicle already in the shared list? */
 
			if (src->FirstShared() == dst->FirstShared()) return CMD_ERROR;
 

	
src/order_gui.cpp
Show inline comments
 
@@ -14,12 +14,13 @@
 
#include "command_func.h"
 
#include "viewport_func.h"
 
#include "gfx_func.h"
 
#include "depot_base.h"
 
#include "vehicle_base.h"
 
#include "vehicle_gui.h"
 
#include "roadveh.h"
 
#include "timetable.h"
 
#include "cargotype.h"
 
#include "strings_func.h"
 
#include "window_func.h"
 
#include "vehicle_func.h"
 
#include "company_func.h"
 
@@ -376,13 +377,13 @@ static Order GetOrderCmdFromTile(const V
 

	
 
		if (st->owner == _local_company || st->owner == OWNER_NONE) {
 
			byte facil;
 
			(facil = FACIL_DOCK, v->type == VEH_SHIP) ||
 
			(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_BUS_STOP, v->type == VEH_ROAD && RoadVehicle::From(v)->IsBus()) ||
 
			(facil = FACIL_TRUCK_STOP, 1);
 
			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);
 
				order.SetStopLocation(v->type == VEH_TRAIN ? (OrderStopLocation)(_settings_client.gui.stop_location) : OSL_PLATFORM_FAR_END);
src/pathfinder/yapf/yapf_road.cpp
Show inline comments
 
@@ -8,13 +8,12 @@
 
 */
 

	
 
/** @file yapf_road.cpp The road pathfinding. */
 

	
 
#include "../../stdafx.h"
 
#include "../../roadstop_base.h"
 
#include "../../cargotype.h"
 

	
 
#include "yapf.hpp"
 
#include "yapf_node_road.hpp"
 

	
 

	
 
template <class Types>
 
@@ -206,13 +205,13 @@ public:
 
	}
 

	
 
	void SetDestination(const RoadVehicle *v, StationID sid, TileIndex destTile)
 
	{
 
		m_dest_station = sid;
 
		m_destTile     = destTile;
 
		m_bus          = IsCargoInClass(v->cargo_type, CC_PASSENGERS);
 
		m_bus          = v->IsBus();
 
		m_non_artic    = !v->HasArticulatedPart();
 
	}
 

	
 
	/** Called by YAPF to detect if node ends in the desired destination */
 
	FORCEINLINE bool PfDetectDestination(Node& n)
 
	{
src/roadveh.h
Show inline comments
 
@@ -129,12 +129,14 @@ struct RoadVehicle : public SpecializedV
 
	void OnNewDay();
 
	Trackdir GetVehicleTrackdir() const;
 
	TileIndex GetOrderStationLocation(StationID station);
 
	bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
 
	void FindRoadStopSlot();
 

	
 
	bool IsBus() const;
 

	
 
	/**
 
	 * Check if vehicle is a front engine
 
	 * @return Returns true if vehicle is a front engine
 
	 */
 
	FORCEINLINE bool IsRoadVehFront() const { return this->subtype == RVST_FRONT; }
 

	
src/roadveh_cmd.cpp
Show inline comments
 
@@ -79,12 +79,23 @@ static const Trackdir _road_reverse_tabl
 

	
 
/** Converts the exit direction of a depot to trackdir the vehicle is going to drive to */
 
static const Trackdir _roadveh_depot_exit_trackdir[DIAGDIR_END] = {
 
	TRACKDIR_X_NE, TRACKDIR_Y_SE, TRACKDIR_X_SW, TRACKDIR_Y_NW
 
};
 

	
 

	
 
/**
 
 * Check whether a roadvehicle is a bus
 
 * @return true if bus
 
 */
 
bool RoadVehicle::IsBus() const
 
{
 
	assert(this->IsRoadVehFront());
 
	return IsCargoInClass(this->cargo_type, CC_PASSENGERS);
 
}
 

	
 
/**
 
 * Get the width of a road vehicle image in the GUI.
 
 * @param offset Additional offset for positioning the sprite; set to NULL if not needed
 
 * @return Width in pixels
 
 */
 
int RoadVehicle::GetDisplayImageWidth(Point *offset) const
 
@@ -726,13 +737,13 @@ static RoadVehicle *RoadVehFindCloseTo(R
 

	
 
	return RoadVehicle::From(rvf.best);
 
}
 

	
 
static void RoadVehArrivesAt(const RoadVehicle *v, Station *st)
 
{
 
	if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) {
 
	if (v->IsBus()) {
 
		/* Check if station was ever visited before */
 
		if (!(st->had_vehicle_of_type & HVOT_BUS)) {
 
			st->had_vehicle_of_type |= HVOT_BUS;
 
			SetDParam(0, st->index);
 
			AddVehicleNewsItem(
 
				v->roadtype == ROADTYPE_ROAD ? STR_NEWS_FIRST_BUS_ARRIVAL : STR_NEWS_FIRST_PASSENGER_TRAM_ARRIVAL,
 
@@ -957,13 +968,13 @@ static Trackdir RoadFindPathToDest(RoadV
 

	
 
		if (!IsTileOwner(tile, v->owner) || GetRoadStopDir(tile) == enterdir || v->HasArticulatedPart()) {
 
			/* different station owner or wrong orientation or the vehicle has articulated parts */
 
			trackdirs = TRACKDIR_BIT_NONE;
 
		} else {
 
			/* Our station */
 
			RoadStopType rstype = IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK;
 
			RoadStopType rstype = v->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK;
 

	
 
			if (GetRoadStopType(tile) != rstype) {
 
				/* Wrong station type */
 
				trackdirs = TRACKDIR_BIT_NONE;
 
			} else {
 
				/* Proper station type, check if there is free loading bay */
 
@@ -1486,13 +1497,13 @@ again:
 
	 * a through route, do not stop) */
 
	if (v->IsRoadVehFront() && ((IsInsideMM(v->state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END) &&
 
			_road_veh_data_1[v->state - RVSB_IN_ROAD_STOP + (_settings_game.vehicle.road_side << RVS_DRIVE_SIDE)] == v->frame) ||
 
			(IsInsideMM(v->state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) &&
 
			v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile)) &&
 
			v->owner == GetTileOwner(v->tile) &&
 
			GetRoadStopType(v->tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK) &&
 
			GetRoadStopType(v->tile) == (v->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK) &&
 
			v->frame == RVC_DRIVE_THROUGH_STOP_FRAME))) {
 

	
 
		RoadStop *rs = RoadStop::GetByTile(v->tile, GetRoadStopType(v->tile));
 
		Station *st = Station::GetByTile(v->tile);
 

	
 
		/* Vehicle is at the stop position (at a bay) in a road stop.
 
@@ -1500,13 +1511,13 @@ again:
 
		 * so if we get here the vehicle has just arrived or is just ready to leave. */
 
		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;
 
				RoadStopType type = v->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK;
 

	
 
				/* Check if next inline bay is free */
 
				if (IsDriveThroughStopTile(next_tile) && (GetRoadStopType(next_tile) == type) && GetStationIndex(v->tile) == GetStationIndex(next_tile)) {
 
					RoadStop *rs_n = RoadStop::GetByTile(next_tile, type);
 

	
 
					if (rs_n->IsFreeBay(HasBit(v->state, RVS_USING_SECOND_BAY)) && rs_n->num_vehicles < RoadStop::MAX_VEHICLES) {
src/station.cpp
Show inline comments
 
@@ -8,13 +8,12 @@
 
 */
 

	
 
/** @file station.cpp Implementation of the station base class. */
 

	
 
#include "stdafx.h"
 
#include "company_func.h"
 
#include "cargotype.h"
 
#include "roadveh.h"
 
#include "functions.h"
 
#include "window_func.h"
 
#include "date_func.h"
 
#include "command_func.h"
 
#include "news_func.h"
 
@@ -116,13 +115,13 @@ void BaseStation::PostDestructor(size_t 
 
 * Get the primary road stop (the first road stop) that the given vehicle can load/unload.
 
 * @param v the vehicle to get the first road stop for
 
 * @return the first roadstop that this vehicle can load at
 
 */
 
RoadStop *Station::GetPrimaryRoadStop(const RoadVehicle *v) const
 
{
 
	RoadStop *rs = this->GetPrimaryRoadStop(IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK);
 
	RoadStop *rs = this->GetPrimaryRoadStop(v->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK);
 

	
 
	for (; rs != NULL; rs = rs->next) {
 
		/* The vehicle cannot go to this roadstop (different roadtype) */
 
		if ((GetRoadTypes(rs->xy) & v->compatible_roadtypes) == ROADTYPES_NONE) continue;
 
		/* The vehicle is articulated and can therefor not go the a standard road stop */
 
		if (IsStandardRoadStopTile(rs->xy) && v->HasArticulatedPart()) continue;
src/station_cmd.cpp
Show inline comments
 
@@ -2696,13 +2696,13 @@ static VehicleEnterTileStatus VehicleEnt
 
					/* Vehicles entering a drive-through stop from the 'normal' side use first bay (bay 0). */
 
					byte side = ((DirToDiagDir(rv->direction) == ReverseDiagDir(GetRoadStopDir(tile))) == (rv->overtaking == 0)) ? 0 : 1;
 

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

	
 
					/* Check if the vehicle is stopping at this road stop */
 
					if (GetRoadStopType(tile) == (IsCargoInClass(rv->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK) &&
 
					if (GetRoadStopType(tile) == (rv->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK) &&
 
							rv->current_order.GetDestination() == GetStationIndex(tile)) {
 
						SetBit(rv->state, RVS_IS_STOPPING);
 
						rs->AllocateDriveThroughBay(side);
 
					}
 

	
 
					/* Indicate if vehicle is using second bay. */
0 comments (0 inline, 0 general)