Changeset - r12295:bb9023f54628
[Not reviewed]
master
0 13 0
rubidium - 15 years ago 2009-07-02 09:06:15
rubidium@openttd.org
(svn r16722) -Codechange: unify the naming of the Is/Set/HasArticulatedPart functions
13 files changed with 26 insertions and 26 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_vehicle.cpp
Show inline comments
 
@@ -412,8 +412,8 @@
 

	
 
	const Vehicle *v = ::Vehicle::Get(vehicle_id);
 
	switch (v->type) {
 
		case VEH_ROAD: return ::RoadVehicle::From(v)->RoadVehHasArticPart();
 
		case VEH_TRAIN: return ::Train::From(v)->EngineHasArticPart();
 
		case VEH_ROAD: return ::RoadVehicle::From(v)->HasArticulatedPart();
 
		case VEH_TRAIN: return ::Train::From(v)->HasArticulatedPart();
 
		default: NOT_REACHED();
 
	}
 
}
src/articulated_vehicles.cpp
Show inline comments
 
@@ -207,11 +207,11 @@ bool IsArticulatedVehicleCarryingDiffere
 

	
 
		switch (v->type) {
 
			case VEH_TRAIN:
 
				v = Train::From(v)->EngineHasArticPart() ? GetNextArticPart(Train::From(v)) : NULL;
 
				v = Train::From(v)->HasArticulatedPart() ? GetNextArticPart(Train::From(v)) : NULL;
 
				break;
 

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

	
 
			default:
 
@@ -254,11 +254,11 @@ void CheckConsistencyOfArticulatedVehicl
 

	
 
		switch (v->type) {
 
			case VEH_TRAIN:
 
				v = Train::From(v)->EngineHasArticPart() ? GetNextArticPart(Train::From(v)) : NULL;
 
				v = Train::From(v)->HasArticulatedPart() ? GetNextArticPart(Train::From(v)) : NULL;
 
				break;
 

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

	
 
			default:
src/depot_gui.cpp
Show inline comments
 
@@ -860,7 +860,7 @@ struct DepotWindow : Window {
 
					loaded  [w->cargo_type] += w->cargo.Count();
 
				}
 

	
 
				if (w->type == VEH_TRAIN && !Train::From(w)->EngineHasArticPart()) {
 
				if (w->type == VEH_TRAIN && !Train::From(w)->HasArticulatedPart()) {
 
					num++;
 
					if (!whole_chain) break;
 
				}
src/roadstop.cpp
Show inline comments
 
@@ -40,7 +40,7 @@ RoadStop *RoadStop::GetNextRoadStop(cons
 
		/* 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->RoadVehHasArticPart()) continue;
 
		if (IsStandardRoadStopTile(rs->xy) && v->HasArticulatedPart()) continue;
 

	
 
		/* The vehicle can actually go to this road stop. So, return it! */
 
		return rs;
src/roadveh.h
Show inline comments
 
@@ -151,7 +151,7 @@ struct RoadVehicle : public SpecializedV
 
	 * 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(); }
 
	FORCEINLINE bool HasArticulatedPart() const { return this->Next() != NULL && this->Next()->IsArticulatedPart(); }
 
};
 

	
 
#define FOR_ALL_ROADVEHICLES(var) FOR_ALL_VEHICLES_OF_TYPE(RoadVehicle, var)
src/roadveh_cmd.cpp
Show inline comments
 
@@ -916,7 +916,7 @@ static void RoadVehCheckOvertake(RoadVeh
 
	if (IsTileType(v->tile, MP_STATION)) return;
 

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

	
 
	/* Vehicles are not driving in same direction || direction is not a diagonal direction */
 
	if (v->direction != u->direction || !(v->direction & 1)) return;
 
@@ -1027,7 +1027,7 @@ static Trackdir RoadFindPathToDest(RoadV
 
	} 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 || v->RoadVehHasArticPart()) {
 
		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 {
src/roadveh_gui.cpp
Show inline comments
 
@@ -26,7 +26,7 @@ void DrawRoadVehDetails(const Vehicle *v
 
{
 
	const RoadVehicle *rv = RoadVehicle::From(v);
 

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

	
 
@@ -35,7 +35,7 @@ void DrawRoadVehDetails(const Vehicle *v
 
	SetDParam(2, v->value);
 
	DrawString(left, right, y + y_offset, STR_VEHICLE_INFO_BUILT_VALUE);
 

	
 
	if (rv->RoadVehHasArticPart()) {
 
	if (rv->HasArticulatedPart()) {
 
		CargoArray max_cargo;
 
		StringID subtype_text[NUM_CARGO];
 
		char capacity[512];
src/saveload/afterload.cpp
Show inline comments
 
@@ -1870,7 +1870,7 @@ bool AfterLoadGame()
 
		FOR_ALL_DISASTERVEHICLES(v) {
 
			if (v->subtype == 2/*ST_SMALL_UFO*/ && v->current_order.GetDestination() != 0) {
 
				const Vehicle *u = Vehicle::GetIfValid(v->dest_tile);
 
				if (u == NULL || u->type != VEH_ROAD || !IsRoadVehFront(u)) {
 
				if (u == NULL || u->type != VEH_ROAD || !RoadVehicle::From(u)->IsRoadVehFront()) {
 
					delete v;
 
				}
 
			}
src/station.cpp
Show inline comments
 
@@ -121,7 +121,7 @@ RoadStop *Station::GetPrimaryRoadStop(co
 
		/* 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->RoadVehHasArticPart()) continue;
 
		if (IsStandardRoadStopTile(rs->xy) && v->HasArticulatedPart()) continue;
 

	
 
		/* The vehicle can actually go to this road stop. So, return it! */
 
		break;
src/station_cmd.cpp
Show inline comments
 
@@ -2570,7 +2570,7 @@ static VehicleEnterTileStatus VehicleEnt
 

	
 
				/* 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() || rv->RoadVehHasArticPart()) return VETSB_CANNOT_ENTER;
 
				if (rs->IsEntranceBusy() || !rs->HasFreeBay() || rv->HasArticulatedPart()) return VETSB_CANNOT_ENTER;
 

	
 
				SetBit(rv->state, RVS_IN_ROAD_STOP);
 

	
src/train.h
Show inline comments
 
@@ -259,7 +259,7 @@ struct Train : public SpecializedVehicle
 
	 * Check if an engine has an articulated part.
 
	 * @return True if the engine has an articulated part.
 
	 */
 
	FORCEINLINE bool EngineHasArticPart() const { return this->Next() != NULL && this->Next()->IsArticulatedPart(); }
 
	FORCEINLINE bool HasArticulatedPart() const { return this->Next() != NULL && this->Next()->IsArticulatedPart(); }
 

	
 
};
 

	
 
@@ -267,12 +267,12 @@ struct Train : public SpecializedVehicle
 

	
 
/**
 
 * Get the next part of a multi-part engine.
 
 * Will only work on a multi-part engine (v->EngineHasArticPart() == true),
 
 * Will only work on a multi-part engine (v->HasArticulatedPart() == true),
 
 * Result is undefined for normal engine.
 
 */
 
static inline Train *GetNextArticPart(const Train *v)
 
{
 
	assert(v->EngineHasArticPart());
 
	assert(v->HasArticulatedPart());
 
	return v->Next();
 
}
 

	
 
@@ -282,7 +282,7 @@ static inline Train *GetNextArticPart(co
 
 */
 
static inline Train *GetLastEnginePart(Train *v)
 
{
 
	while (v->EngineHasArticPart()) v = GetNextArticPart(v);
 
	while (v->HasArticulatedPart()) v = GetNextArticPart(v);
 
	return v;
 
}
 

	
 
@@ -292,7 +292,7 @@ static inline Train *GetLastEnginePart(T
 
 */
 
static inline Train *GetNextVehicle(const Train *v)
 
{
 
	while (v->EngineHasArticPart()) v = GetNextArticPart(v);
 
	while (v->HasArticulatedPart()) v = GetNextArticPart(v);
 

	
 
	/* v now contains the last artic part in the engine */
 
	return v->Next();
src/vehicle_cmd.cpp
Show inline comments
 
@@ -437,9 +437,9 @@ CommandCost CmdCloneVehicle(TileIndex ti
 
					if (CmdSucceeded(cost)) total_cost.AddCost(cost);
 
				}
 

	
 
				if (w->type == VEH_TRAIN && Train::From(w)->EngineHasArticPart()) {
 
				if (w->type == VEH_TRAIN && Train::From(w)->HasArticulatedPart()) {
 
					w = GetNextArticPart(Train::From(w));
 
				} else if (w->type == VEH_ROAD && RoadVehicle::From(w)->RoadVehHasArticPart()) {
 
				} else if (w->type == VEH_ROAD && RoadVehicle::From(w)->HasArticulatedPart()) {
 
					w = w->Next();
 
				} else {
 
					break;
 
@@ -453,9 +453,9 @@ CommandCost CmdCloneVehicle(TileIndex ti
 
				}
 
			}
 

	
 
			if (v->type == VEH_TRAIN && Train::From(v)->EngineHasArticPart()) {
 
			if (v->type == VEH_TRAIN && Train::From(v)->HasArticulatedPart()) {
 
				v = GetNextArticPart(Train::From(v));
 
			} else if (v->type == VEH_ROAD && RoadVehicle::From(v)->RoadVehHasArticPart()) {
 
			} else if (v->type == VEH_ROAD && RoadVehicle::From(v)->HasArticulatedPart()) {
 
				v = v->Next();
 
			} else {
 
				break;
src/vehicle_gui.cpp
Show inline comments
 
@@ -1355,7 +1355,7 @@ struct VehicleDetailsWindow : Window {
 
			case VEH_ROAD: {
 
				this->widget[VLD_WIDGET_RENAME_VEHICLE].tooltips = STR_QUERY_RENAME_ROAD_CAPTION;
 

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

	
 
				/* Draw the text under the vehicle instead of next to it, minus the
 
				 * height already allocated for the cargo of the first vehicle. */
0 comments (0 inline, 0 general)