Changeset - r12294:7f9f5ab6fe85
[Not reviewed]
master
0 14 0
rubidium - 15 years ago 2009-07-02 08:59:27
rubidium@openttd.org
(svn r16721) -Codechange: make Is/SetRoadVehicleFront, Is/Set/HasArticulatedPart member of RoadVehicle.
14 files changed with 76 insertions and 72 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_vehicle.cpp
Show inline comments
 
@@ -409,13 +409,13 @@
 
{
 
	if (!IsValidVehicle(vehicle_id)) return false;
 
	if (GetVehicleType(vehicle_id) != VT_ROAD && GetVehicleType(vehicle_id) != VT_RAIL) return false;
 

	
 
	const Vehicle *v = ::Vehicle::Get(vehicle_id);
 
	switch (v->type) {
 
		case VEH_ROAD: return ::RoadVehHasArticPart(v);
 
		case VEH_ROAD: return ::RoadVehicle::From(v)->RoadVehHasArticPart();
 
		case VEH_TRAIN: return ::Train::From(v)->EngineHasArticPart();
 
		default: NOT_REACHED();
 
	}
 
}
 

	
 
/* static */ bool AIVehicle::HasSharedOrders(VehicleID vehicle_id)
src/articulated_vehicles.cpp
Show inline comments
 
@@ -208,13 +208,13 @@ bool IsArticulatedVehicleCarryingDiffere
 
		switch (v->type) {
 
			case VEH_TRAIN:
 
				v = Train::From(v)->EngineHasArticPart() ? GetNextArticPart(Train::From(v)) : NULL;
 
				break;
 

	
 
			case VEH_ROAD:
 
				v = (RoadVehHasArticPart(v) ? v->Next() : NULL);
 
				v = RoadVehicle::From(v)->RoadVehHasArticPart() ? v->Next() : NULL;
 
				break;
 

	
 
			default:
 
				v = NULL;
 
				break;
 
		}
 
@@ -255,13 +255,13 @@ void CheckConsistencyOfArticulatedVehicl
 
		switch (v->type) {
 
			case VEH_TRAIN:
 
				v = Train::From(v)->EngineHasArticPart() ? GetNextArticPart(Train::From(v)) : NULL;
 
				break;
 

	
 
			case VEH_ROAD:
 
				v = (RoadVehHasArticPart(v) ? v->Next() : NULL);
 
				v = RoadVehicle::From(v)->RoadVehHasArticPart() ? v->Next() : NULL;
 
				break;
 

	
 
			default:
 
				v = NULL;
 
				break;
 
		}
 
@@ -345,13 +345,13 @@ void AddArticulatedParts(Vehicle *first,
 
					rv->cargo_cap = e_artic->u.road.capacity;  // Callback 36 is called when the consist is finished
 
				} else {
 
					rv->cargo_type = front->cargo_type; // Needed for livery selection
 
					rv->cargo_cap = 0;
 
				}
 

	
 
				SetRoadVehArticPart(rv);
 
				rv->SetArticulatedPart();
 
			} break;
 
		}
 

	
 
		/* get common values from first engine */
 
		v->direction = first->direction;
 
		v->owner = first->owner;
src/disaster_cmd.cpp
Show inline comments
 
@@ -299,25 +299,25 @@ static bool DisasterTick_Ufo(DisasterVeh
 
			return true;
 
		}
 
		v->current_order.SetDestination(1);
 

	
 
		RoadVehicle *u;
 
		FOR_ALL_ROADVEHICLES(u) {
 
			if (IsRoadVehFront(u)) {
 
			if (u->IsRoadVehFront()) {
 
				v->dest_tile = u->index;
 
				v->age = 0;
 
				return true;
 
			}
 
		}
 

	
 
		delete v;
 
		return false;
 
	} else {
 
		/* Target a vehicle */
 
		RoadVehicle *u = RoadVehicle::Get(v->dest_tile);
 
		assert(u != NULL && u->type == VEH_ROAD && IsRoadVehFront(u));
 
		assert(u != NULL && u->type == VEH_ROAD && u->IsRoadVehFront());
 

	
 
		uint dist = Delta(v->x_pos, u->x_pos) + Delta(v->y_pos, u->y_pos);
 

	
 
		if (dist < TILE_SIZE && !(u->vehstatus & VS_HIDDEN) && u->breakdown_ctr == 0) {
 
			u->breakdown_ctr = 3;
 
			u->breakdown_delay = 140;
src/roadstop.cpp
Show inline comments
 
@@ -37,13 +37,13 @@ RoadStop::~RoadStop()
 
RoadStop *RoadStop::GetNextRoadStop(const RoadVehicle *v) const
 
{
 
	for (RoadStop *rs = this->next; 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) && RoadVehHasArticPart(v)) continue;
 
		if (IsStandardRoadStopTile(rs->xy) && v->RoadVehHasArticPart()) continue;
 

	
 
		/* The vehicle can actually go to this road stop. So, return it! */
 
		return rs;
 
	}
 

	
 
	return NULL;
src/roadveh.h
Show inline comments
 
@@ -69,42 +69,12 @@ enum {
 

	
 
enum RoadVehicleSubType {
 
	RVST_FRONT,
 
	RVST_ARTIC_PART,
 
};
 

	
 
static inline bool IsRoadVehFront(const Vehicle *v)
 
{
 
	assert(v->type == VEH_ROAD);
 
	return v->subtype == RVST_FRONT;
 
}
 

	
 
static inline void SetRoadVehFront(Vehicle *v)
 
{
 
	assert(v->type == VEH_ROAD);
 
	v->subtype = RVST_FRONT;
 
}
 

	
 
static inline bool IsRoadVehArticPart(const Vehicle *v)
 
{
 
	assert(v->type == VEH_ROAD);
 
	return v->subtype == RVST_ARTIC_PART;
 
}
 

	
 
static inline void SetRoadVehArticPart(Vehicle *v)
 
{
 
	assert(v->type == VEH_ROAD);
 
	v->subtype = RVST_ARTIC_PART;
 
}
 

	
 
static inline bool RoadVehHasArticPart(const Vehicle *v)
 
{
 
	assert(v->type == VEH_ROAD);
 
	return v->Next() != NULL && IsRoadVehArticPart(v->Next());
 
}
 

	
 

	
 
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2);
 

	
 
byte GetRoadVehLength(const RoadVehicle *v);
 

	
 
void RoadVehUpdateCache(RoadVehicle *v);
 
@@ -139,23 +109,51 @@ struct RoadVehicle : public SpecializedV
 
	virtual ~RoadVehicle() { this->PreDestructor(); }
 

	
 
	const char *GetTypeString() const { return "road vehicle"; }
 
	void MarkDirty();
 
	void UpdateDeltaXY(Direction direction);
 
	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_ROADVEH_INC : EXPENSES_ROADVEH_RUN; }
 
	bool IsPrimaryVehicle() const { return IsRoadVehFront(this); }
 
	bool IsPrimaryVehicle() const { return this->IsRoadVehFront(); }
 
	SpriteID GetImage(Direction direction) const;
 
	int GetDisplaySpeed() const { return this->cur_speed / 2; }
 
	int GetDisplayMaxSpeed() const { return this->max_speed / 2; }
 
	Money GetRunningCost() const { return RoadVehInfo(this->engine_type)->running_cost * GetPriceByIndex(RoadVehInfo(this->engine_type)->running_cost_class); }
 
	bool IsInDepot() const { return this->state == RVSB_IN_DEPOT; }
 
	bool IsStoppedInDepot() const;
 
	bool Tick();
 
	void OnNewDay();
 
	Trackdir GetVehicleTrackdir() const;
 
	TileIndex GetOrderStationLocation(StationID station);
 
	bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
 

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

	
 
	/**
 
	 * Set front engine state
 
	 */
 
	FORCEINLINE void SetRoadVehFront() { this->subtype = RVST_FRONT; }
 

	
 
	/**
 
	 * Check if vehicl is an articulated part of an engine
 
	 * @return Returns true if vehicle is an articulated part
 
	 */
 
	FORCEINLINE bool IsArticulatedPart() const { return this->subtype == RVST_ARTIC_PART; }
 

	
 
	/**
 
	 * Set a vehicle to be an articulated part
 
	 */
 
	FORCEINLINE void SetArticulatedPart() { this->subtype = RVST_ARTIC_PART; }
 

	
 
	/**
 
	 * Check if an engine has an articulated part.
 
	 * @return True if the engine has an articulated part.
 
	 */
 
	FORCEINLINE bool RoadVehHasArticPart() const { return this->Next() != NULL && this->Next()->IsArticulatedPart(); }
 
};
 

	
 
#define FOR_ALL_ROADVEHICLES(var) FOR_ALL_VEHICLES_OF_TYPE(RoadVehicle, var)
 

	
 
#endif /* ROADVEH_H */
src/roadveh_cmd.cpp
Show inline comments
 
@@ -135,13 +135,13 @@ byte GetRoadVehLength(const RoadVehicle 
 
	return length;
 
}
 

	
 
void RoadVehUpdateCache(RoadVehicle *v)
 
{
 
	assert(v->type == VEH_ROAD);
 
	assert(IsRoadVehFront(v));
 
	assert(v->IsRoadVehFront());
 

	
 
	v->InvalidateNewGRFCacheOfChain();
 

	
 
	for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
 
		/* Check the v->first cache. */
 
		assert(u->First() == v);
 
@@ -242,13 +242,13 @@ CommandCost CmdBuildRoadVeh(TileIndex ti
 

	
 
		v->date_of_last_service = _date;
 
		v->build_year = _cur_year;
 

	
 
		v->cur_image = SPR_IMG_QUERY;
 
		v->random_bits = VehicleRandomBits();
 
		SetRoadVehFront(v);
 
		v->SetRoadVehFront();
 

	
 
		v->roadtype = HasBit(EngInfo(v->engine_type)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD;
 
		v->compatible_roadtypes = RoadTypeToRoadTypes(v->roadtype);
 
		v->rcache.cached_veh_length = 8;
 

	
 
		v->vehicle_flags = 0;
 
@@ -301,13 +301,13 @@ void ClearSlot(RoadVehicle *v)
 

	
 
bool RoadVehicle::IsStoppedInDepot() const
 
{
 
	TileIndex tile = this->tile;
 

	
 
	if (!IsRoadDepotTile(tile)) return false;
 
	if (IsRoadVehFront(this) && !(this->vehstatus & VS_STOPPED)) return false;
 
	if (this->IsRoadVehFront() && !(this->vehstatus & VS_STOPPED)) return false;
 

	
 
	for (const RoadVehicle *v = this; v != NULL; v = v->Next()) {
 
		if (v->state != RVSB_IN_DEPOT || v->tile != tile) return false;
 
	}
 
	return true;
 
}
 
@@ -913,13 +913,13 @@ static void RoadVehCheckOvertake(RoadVeh
 
	if (v->roadtype == ROADTYPE_TRAM) return;
 

	
 
	/* Don't overtake in stations */
 
	if (IsTileType(v->tile, MP_STATION)) return;
 

	
 
	/* For now, articulated road vehicles can't overtake anything. */
 
	if (RoadVehHasArticPart(v)) return;
 
	if (v->RoadVehHasArticPart()) return;
 

	
 
	/* Vehicles are not driving in same direction || direction is not a diagonal direction */
 
	if (v->direction != u->direction || !(v->direction & 1)) return;
 

	
 
	/* Check if vehicle is in a road stop, depot, tunnel or bridge or not on a straight road */
 
	if (v->state >= RVSB_IN_ROAD_STOP || !IsStraightRoadTrackdir((Trackdir)(v->state & RVSB_TRACKDIR_MASK))) return;
 
@@ -1024,13 +1024,13 @@ static Trackdir RoadFindPathToDest(RoadV
 
			/* Road depot owned by another company or with the wrong orientation */
 
			trackdirs = TRACKDIR_BIT_NONE;
 
		}
 
	} else if (IsTileType(tile, MP_STATION) && IsStandardRoadStopTile(tile)) {
 
		/* Standard road stop (drive-through stops are treated as normal road) */
 

	
 
		if (!IsTileOwner(tile, v->owner) || GetRoadStopDir(tile) == enterdir || RoadVehHasArticPart(v)) {
 
		if (!IsTileOwner(tile, v->owner) || GetRoadStopDir(tile) == enterdir || v->RoadVehHasArticPart()) {
 
			/* 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;
 

	
 
@@ -1354,13 +1354,13 @@ static bool IndividualRoadVehicleControl
 
	if (v->IsInDepot()) return true;
 

	
 
	if (v->state == RVSB_WORMHOLE) {
 
		/* Vehicle is entering a depot or is on a bridge or in a tunnel */
 
		GetNewVehiclePosResult gp = GetNewVehiclePos(v);
 

	
 
		if (IsRoadVehFront(v)) {
 
		if (v->IsRoadVehFront()) {
 
			const Vehicle *u = RoadVehFindCloseTo(v, gp.x, gp.y, v->direction);
 
			if (u != NULL) {
 
				v->cur_speed = u->First()->cur_speed;
 
				return false;
 
			}
 
		}
 
@@ -1386,21 +1386,21 @@ static bool IndividualRoadVehicleControl
 
		(_settings_game.vehicle.road_side << RVS_DRIVE_SIDE)) ^ v->overtaking][v->frame + 1];
 

	
 
	if (rd.x & RDE_NEXT_TILE) {
 
		TileIndex tile = v->tile + TileOffsByDiagDir((DiagDirection)(rd.x & 3));
 
		Trackdir dir;
 

	
 
		if (IsRoadVehFront(v)) {
 
		if (v->IsRoadVehFront()) {
 
			/* If this is the front engine, look for the right path. */
 
			dir = RoadFindPathToDest(v, tile, (DiagDirection)(rd.x & 3));
 
		} else {
 
			dir = FollowPreviousRoadVehicle(v, prev, tile, (DiagDirection)(rd.x & 3), false);
 
		}
 

	
 
		if (dir == INVALID_TRACKDIR) {
 
			if (!IsRoadVehFront(v)) error("Disconnecting road vehicle.");
 
			if (!v->IsRoadVehFront()) error("Disconnecting road vehicle.");
 
			v->cur_speed = 0;
 
			return false;
 
		}
 

	
 
again:
 
		uint start_frame = RVC_DEFAULT_START_FRAME;
 
@@ -1415,25 +1415,25 @@ again:
 
					case TRACKDIR_RVREV_NE: needed = ROAD_SW; break;
 
					case TRACKDIR_RVREV_SE: needed = ROAD_NW; break;
 
					case TRACKDIR_RVREV_SW: needed = ROAD_NE; break;
 
					case TRACKDIR_RVREV_NW: needed = ROAD_SE; break;
 
				}
 
				if ((v->Previous() != NULL && v->Previous()->tile == tile) ||
 
						(IsRoadVehFront(v) && IsNormalRoadTile(tile) && !HasRoadWorks(tile) &&
 
						(v->IsRoadVehFront() && IsNormalRoadTile(tile) && !HasRoadWorks(tile) &&
 
							(needed & GetRoadBits(tile, ROADTYPE_TRAM)) != ROAD_NONE)) {
 
					/*
 
					 * Taking the 'big' corner for trams only happens when:
 
					 * - The previous vehicle in this (articulated) tram chain is
 
					 *   already on the 'next' tile, we just follow them regardless of
 
					 *   anything. When it is NOT on the 'next' tile, the tram started
 
					 *   doing a reversing turn when the piece of tram track on the next
 
					 *   tile did not exist yet. Do not use the big tram loop as that is
 
					 *   going to cause the tram to split up.
 
					 * - Or the front of the tram can drive over the next tile.
 
					 */
 
				} else if (!IsRoadVehFront(v) || !CanBuildTramTrackOnTile(v->owner, tile, needed) || ((~needed & GetAnyRoadBits(v->tile, ROADTYPE_TRAM, false)) == ROAD_NONE)) {
 
				} else if (!v->IsRoadVehFront() || !CanBuildTramTrackOnTile(v->owner, tile, needed) || ((~needed & GetAnyRoadBits(v->tile, ROADTYPE_TRAM, false)) == ROAD_NONE)) {
 
					/*
 
					 * Taking the 'small' corner for trams only happens when:
 
					 * - We are not the from vehicle of an articulated tram.
 
					 * - Or when the company cannot build on the next tile.
 
					 *
 
					 * The 'small' corner means that the vehicle is on the end of a
 
@@ -1461,13 +1461,13 @@ again:
 
		const RoadDriveEntry *rdp = _road_drive_data[v->roadtype][(dir + (_settings_game.vehicle.road_side << RVS_DRIVE_SIDE)) ^ v->overtaking];
 

	
 
		int x = TileX(tile) * TILE_SIZE + rdp[start_frame].x;
 
		int y = TileY(tile) * TILE_SIZE + rdp[start_frame].y;
 

	
 
		Direction new_dir = RoadVehGetSlidingDirection(v, x, y);
 
		if (IsRoadVehFront(v)) {
 
		if (v->IsRoadVehFront()) {
 
			Vehicle *u = RoadVehFindCloseTo(v, x, y, new_dir);
 
			if (u != NULL) {
 
				v->cur_speed = u->First()->cur_speed;
 
				return false;
 
			}
 
		}
 
@@ -1540,13 +1540,13 @@ again:
 
				case DIAGDIR_NW: dir = TRACKDIR_RVREV_SE; break;
 
				case DIAGDIR_NE: dir = TRACKDIR_RVREV_SW; break;
 
				case DIAGDIR_SE: dir = TRACKDIR_RVREV_NW; break;
 
				case DIAGDIR_SW: dir = TRACKDIR_RVREV_NE; break;
 
			}
 
		} else {
 
			if (IsRoadVehFront(v)) {
 
			if (v->IsRoadVehFront()) {
 
				/* If this is the front engine, look for the right path. */
 
				dir = RoadFindPathToDest(v, v->tile, (DiagDirection)(rd.x & 3));
 
			} else {
 
				dir = FollowPreviousRoadVehicle(v, prev, v->tile, (DiagDirection)(rd.x & 3), true);
 
			}
 
		}
 
@@ -1559,13 +1559,13 @@ again:
 
		const RoadDriveEntry *rdp = _road_drive_data[v->roadtype][(_settings_game.vehicle.road_side << RVS_DRIVE_SIDE) + dir];
 

	
 
		int x = TileX(v->tile) * TILE_SIZE + rdp[turn_around_start_frame].x;
 
		int y = TileY(v->tile) * TILE_SIZE + rdp[turn_around_start_frame].y;
 

	
 
		Direction new_dir = RoadVehGetSlidingDirection(v, x, y);
 
		if (IsRoadVehFront(v) && RoadVehFindCloseTo(v, x, y, new_dir) != NULL) return false;
 
		if (v->IsRoadVehFront() && RoadVehFindCloseTo(v, x, y, new_dir) != NULL) return false;
 

	
 
		uint32 r = VehicleEnterTile(v, v->tile, x, y);
 
		if (HasBit(r, VETS_CANNOT_ENTER)) {
 
			v->cur_speed = 0;
 
			return false;
 
		}
 
@@ -1595,13 +1595,13 @@ again:
 
	/* Calculate new position for the vehicle */
 
	int x = (v->x_pos & ~15) + (rd.x & 15);
 
	int y = (v->y_pos & ~15) + (rd.y & 15);
 

	
 
	Direction new_dir = RoadVehGetSlidingDirection(v, x, y);
 

	
 
	if (IsRoadVehFront(v) && !IsInsideMM(v->state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END)) {
 
	if (v->IsRoadVehFront() && !IsInsideMM(v->state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END)) {
 
		/* Vehicle is not in a road stop.
 
		 * Check for another vehicle to overtake */
 
		RoadVehicle *u = RoadVehFindCloseTo(v, x, y, new_dir);
 

	
 
		if (u != NULL) {
 
			u = u->First();
 
@@ -1629,13 +1629,13 @@ again:
 

	
 
	/* If the vehicle is in a normal road stop and the frame equals the stop frame OR
 
	 * if the vehicle is in a drive-through road stop and this is the destination station
 
	 * 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->state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END) &&
 
	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) &&
 
			v->frame == RVC_DRIVE_THROUGH_STOP_FRAME))) {
 
@@ -1817,13 +1817,13 @@ static void AgeRoadVehCargo(RoadVehicle 
 
}
 

	
 
bool RoadVehicle::Tick()
 
{
 
	AgeRoadVehCargo(this);
 

	
 
	if (IsRoadVehFront(this)) {
 
	if (this->IsRoadVehFront()) {
 
		if (!(this->vehstatus & VS_STOPPED)) this->running_ticks++;
 
		return RoadVehController(this);
 
	}
 

	
 
	return true;
 
}
 
@@ -1861,13 +1861,13 @@ static void CheckIfRoadVehNeedsService(R
 
	v->dest_tile = depot->xy;
 
	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
}
 

	
 
void RoadVehicle::OnNewDay()
 
{
 
	if (!IsRoadVehFront(this)) return;
 
	if (!this->IsRoadVehFront()) return;
 

	
 
	if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
 
	if (this->blocked_ctr == 0) CheckVehicleBreakdown(this);
 

	
 
	AgeVehicle(this);
 
	CheckIfRoadVehNeedsService(this);
src/roadveh_gui.cpp
Show inline comments
 
@@ -21,22 +21,24 @@
 
 * @param left  The left most coordinate to draw
 
 * @param right The right most coordinate to draw
 
 * @param y     The y coordinate
 
 */
 
void DrawRoadVehDetails(const Vehicle *v, int left, int right, int y)
 
{
 
	uint y_offset = RoadVehHasArticPart(v) ? 15 : 0;
 
	const RoadVehicle *rv = RoadVehicle::From(v);
 

	
 
	uint y_offset = rv->RoadVehHasArticPart() ? 15 : 0;
 
	StringID str;
 
	Money feeder_share = 0;
 

	
 
	SetDParam(0, v->engine_type);
 
	SetDParam(1, v->build_year);
 
	SetDParam(2, v->value);
 
	DrawString(left, right, y + y_offset, STR_VEHICLE_INFO_BUILT_VALUE);
 

	
 
	if (RoadVehHasArticPart(v)) {
 
	if (rv->RoadVehHasArticPart()) {
 
		CargoArray max_cargo;
 
		StringID subtype_text[NUM_CARGO];
 
		char capacity[512];
 

	
 
		memset(subtype_text, 0, sizeof(subtype_text));
 

	
src/saveload/vehicle_sl.cpp
Show inline comments
 
@@ -311,14 +311,17 @@ void AfterLoadVehicles(bool part_of_load
 
		if (v->type == VEH_TRAIN) {
 
			Train *t = Train::From(v);
 
			if (t->IsFrontEngine() || t->IsFreeWagon()) {
 
				t->tcache.last_speed = t->cur_speed; // update displayed train speed
 
				TrainConsistChanged(t, false);
 
			}
 
		} else if (v->type == VEH_ROAD && IsRoadVehFront(v)) {
 
			RoadVehUpdateCache(RoadVehicle::From(v));
 
		} else if (v->type == VEH_ROAD) {
 
			RoadVehicle *rv = RoadVehicle::From(v);
 
			if (rv->IsRoadVehFront()) {
 
				RoadVehUpdateCache(rv);
 
			}
 
		}
 
	}
 

	
 
	/* Stop non-front engines */
 
	if (CheckSavegameVersion(112)) {
 
		FOR_ALL_VEHICLES(v) {
src/station.cpp
Show inline comments
 
@@ -118,13 +118,13 @@ RoadStop *Station::GetPrimaryRoadStop(co
 
	RoadStop *rs = this->GetPrimaryRoadStop(IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? 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) && RoadVehHasArticPart(v)) continue;
 
		if (IsStandardRoadStopTile(rs->xy) && v->RoadVehHasArticPart()) continue;
 

	
 
		/* The vehicle can actually go to this road stop. So, return it! */
 
		break;
 
	}
 

	
 
	return rs;
src/station_cmd.cpp
Show inline comments
 
@@ -2539,13 +2539,13 @@ static VehicleEnterTileStatus VehicleEnt
 
				if (spd < v->cur_speed) v->cur_speed = spd;
 
			}
 
		}
 
	} else if (v->type == VEH_ROAD) {
 
		RoadVehicle *rv = RoadVehicle::From(v);
 
		if (rv->state < RVSB_IN_ROAD_STOP && !IsReversingRoadTrackdir((Trackdir)rv->state) && rv->frame == 0) {
 
			if (IsRoadStop(tile) && IsRoadVehFront(v)) {
 
			if (IsRoadStop(tile) && rv->IsRoadVehFront()) {
 
				/* Attempt to allocate a parking bay in a road stop */
 
				RoadStop *rs = RoadStop::GetByTile(tile, GetRoadStopType(tile));
 

	
 
				if (IsDriveThroughStopTile(tile)) {
 
					if (!rv->current_order.ShouldStopAtStation(v, station_id)) return VETSB_CONTINUE;
 

	
 
@@ -2567,13 +2567,13 @@ static VehicleEnterTileStatus VehicleEnt
 
					SetBit(rv->state, RVS_IN_DT_ROAD_STOP);
 
					return VETSB_CONTINUE;
 
				}
 

	
 
				/* For normal (non drive-through) road stops
 
				 * Check if station is busy or if there are no free bays or whether it is a articulated vehicle. */
 
				if (rs->IsEntranceBusy() || !rs->HasFreeBay() || RoadVehHasArticPart(v)) return VETSB_CANNOT_ENTER;
 
				if (rs->IsEntranceBusy() || !rs->HasFreeBay() || rv->RoadVehHasArticPart()) return VETSB_CANNOT_ENTER;
 

	
 
				SetBit(rv->state, RVS_IN_ROAD_STOP);
 

	
 
				/* Allocate a bay and update the road state */
 
				uint bay_nr = rs->AllocateBay();
 
				SB(rv->state, RVS_USING_SECOND_BAY, 1, bay_nr);
src/vehicle.cpp
Show inline comments
 
@@ -480,13 +480,13 @@ bool IsEngineCountable(const Vehicle *v)
 
{
 
	switch (v->type) {
 
		case VEH_AIRCRAFT: return IsNormalAircraft(v); // don't count plane shadows and helicopter rotors
 
		case VEH_TRAIN:
 
			return !Train::From(v)->IsArticulatedPart() && // tenders and other articulated parts
 
					!Train::From(v)->IsRearDualheaded(); // rear parts of multiheaded engines
 
		case VEH_ROAD: return IsRoadVehFront(v);
 
		case VEH_ROAD: return RoadVehicle::From(v)->IsRoadVehFront();
 
		case VEH_SHIP: return true;
 
		default: return false; // Only count company buildable vehicles
 
	}
 
}
 

	
 
void Vehicle::PreDestructor()
 
@@ -600,13 +600,13 @@ void CallVehicleTicks()
 
			case VEH_TRAIN:
 
			case VEH_ROAD:
 
			case VEH_AIRCRAFT:
 
			case VEH_SHIP:
 
				if (v->type == VEH_TRAIN && Train::From(v)->IsWagon()) continue;
 
				if (v->type == VEH_AIRCRAFT && v->subtype != AIR_HELICOPTER) continue;
 
				if (v->type == VEH_ROAD && !IsRoadVehFront(v)) continue;
 
				if (v->type == VEH_ROAD && !RoadVehicle::From(v)->IsRoadVehFront()) continue;
 

	
 
				v->motion_counter += (v->direction & 1) ? (v->cur_speed * 3) / 4 : v->cur_speed;
 
				/* Play a running sound if the motion counter passes 256 (Do we not skip sounds?) */
 
				if (GB(v->motion_counter, 0, 8) < v->cur_speed) PlayVehicleSound(v, VSE_RUNNING);
 

	
 
				/* Play an alterate running sound every 16 ticks */
 
@@ -973,13 +973,13 @@ void VehicleEnterDepot(Vehicle *v)
 
			TrainConsistChanged(t, true);
 
			break;
 
		}
 

	
 
		case VEH_ROAD:
 
			InvalidateWindowClasses(WC_ROADVEH_LIST);
 
			if (!IsRoadVehFront(v)) v = v->First();
 
			if (!RoadVehicle::From(v)->IsRoadVehFront()) v = v->First();
 
			break;
 

	
 
		case VEH_SHIP:
 
			InvalidateWindowClasses(WC_SHIPS_LIST);
 
			Ship::From(v)->state = TRACK_BIT_DEPOT;
 
			RecalcShipStuff(v);
src/vehicle_cmd.cpp
Show inline comments
 
@@ -436,13 +436,13 @@ CommandCost CmdCloneVehicle(TileIndex ti
 
					CommandCost cost = DoCommand(0, w->index, v->cargo_type | (v->cargo_subtype << 8) | 1U << 16 , flags, GetCmdRefitVeh(v));
 
					if (CmdSucceeded(cost)) total_cost.AddCost(cost);
 
				}
 

	
 
				if (w->type == VEH_TRAIN && Train::From(w)->EngineHasArticPart()) {
 
					w = GetNextArticPart(Train::From(w));
 
				} else if (w->type == VEH_ROAD && RoadVehHasArticPart(w)) {
 
				} else if (w->type == VEH_ROAD && RoadVehicle::From(w)->RoadVehHasArticPart()) {
 
					w = w->Next();
 
				} else {
 
					break;
 
				}
 
			} else {
 
				const Engine *e = Engine::Get(v->engine_type);
 
@@ -452,13 +452,13 @@ CommandCost CmdCloneVehicle(TileIndex ti
 
					total_cost.AddCost(GetRefitCost(v->engine_type));
 
				}
 
			}
 

	
 
			if (v->type == VEH_TRAIN && Train::From(v)->EngineHasArticPart()) {
 
				v = GetNextArticPart(Train::From(v));
 
			} else if (v->type == VEH_ROAD && RoadVehHasArticPart(v)) {
 
			} else if (v->type == VEH_ROAD && RoadVehicle::From(v)->RoadVehHasArticPart()) {
 
				v = v->Next();
 
			} else {
 
				break;
 
			}
 
		} while (v != NULL);
 

	
src/vehicle_gui.cpp
Show inline comments
 
@@ -1352,13 +1352,13 @@ struct VehicleDetailsWindow : Window {
 
				this->widget[VLD_WIDGET_RENAME_VEHICLE].tooltips = STR_VEHICLE_DETAILS_TRAIN_RENAME;
 
				break;
 

	
 
			case VEH_ROAD: {
 
				this->widget[VLD_WIDGET_RENAME_VEHICLE].tooltips = STR_QUERY_RENAME_ROAD_CAPTION;
 

	
 
				if (!RoadVehHasArticPart(v)) break;
 
				if (!RoadVehicle::From(v)->RoadVehHasArticPart()) break;
 

	
 
				/* Draw the text under the vehicle instead of next to it, minus the
 
				 * height already allocated for the cargo of the first vehicle. */
 
				uint height_extension = 15 - 11;
 

	
 
				/* Add space for the cargo amount for each part. */
src/water_cmd.cpp
Show inline comments
 
@@ -810,17 +810,18 @@ static void FloodVehicle(Vehicle *v)
 
					}
 
					t->crash_anim_pos = 4000; // max 4440, disappear pretty fast
 
					InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
 
					break;
 
				}
 

	
 
				case VEH_ROAD:
 
					if (IsRoadVehFront(v)) pass += 1; // driver
 
					RoadVehicle::From(v)->crashed_ctr = 2000; // max 2220, disappear pretty fast
 
				case VEH_ROAD: {
 
					RoadVehicle *rv = RoadVehicle::From(v);
 
					if (rv->IsRoadVehFront()) pass += 1; // driver
 
					rv->crashed_ctr = 2000; // max 2220, disappear pretty fast
 
					InvalidateWindowClassesData(WC_ROADVEH_LIST, 0);
 
					break;
 
				} break;
 

	
 
				case VEH_AIRCRAFT:
 
					pass += 2; // driver
 
					Aircraft::From(v)->crashed_counter = 9000; // max 10000, disappear pretty fast
 
					InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
 
					break;
0 comments (0 inline, 0 general)