Changeset - r17111:4d3d3bfd7c40
[Not reviewed]
master
0 4 0
terkhen - 14 years ago 2011-01-19 18:41:53
terkhen@openttd.org
(svn r21858) -Codechange: Give more similar names to ArticulatedPart functions.
4 files changed with 14 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/articulated_vehicles.cpp
Show inline comments
 
@@ -25,13 +25,13 @@ static const uint MAX_ARTICULATED_PARTS 
 
 * @param index Position in chain
 
 * @param front_type Front engine type
 
 * @param front Front engine
 
 * @param mirrored Returns whether the part shall be flipped.
 
 * @return engine to add or INVALID_ENGINE
 
 */
 
static EngineID GetNextArticPart(uint index, EngineID front_type, Vehicle *front = NULL, bool *mirrored = NULL)
 
static EngineID GetNextArticulatedPart(uint index, EngineID front_type, Vehicle *front = NULL, bool *mirrored = NULL)
 
{
 
	assert(front == NULL || front->engine_type == front_type);
 

	
 
	uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, index, 0, front_type, front);
 
	if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) return INVALID_ENGINE;
 

	
 
@@ -52,13 +52,13 @@ uint CountArticulatedParts(EngineID engi
 
		v = new Vehicle();
 
		v->engine_type = engine_type;
 
	}
 

	
 
	uint i;
 
	for (i = 1; i < MAX_ARTICULATED_PARTS; i++) {
 
		if (GetNextArticPart(i, engine_type, v) == INVALID_ENGINE) break;
 
		if (GetNextArticulatedPart(i, engine_type, v) == INVALID_ENGINE) break;
 
	}
 

	
 
	delete v;
 

	
 
	return i - 1;
 
}
 
@@ -110,13 +110,13 @@ CargoArray GetCapacityOfArticulatedParts
 

	
 
	if (!e->IsGroundVehicle()) return capacity;
 

	
 
	if (!HasBit(e->info.callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return capacity;
 

	
 
	for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
 
		EngineID artic_engine = GetNextArticPart(i, engine);
 
		EngineID artic_engine = GetNextArticulatedPart(i, engine);
 
		if (artic_engine == INVALID_ENGINE) break;
 

	
 
		cargo_capacity = GetVehicleDefaultCapacity(artic_engine, &cargo_type);
 
		if (cargo_type < NUM_CARGO) capacity[cargo_type] += cargo_capacity;
 
	}
 

	
 
@@ -135,13 +135,13 @@ bool IsArticulatedVehicleRefittable(Engi
 
	const Engine *e = Engine::Get(engine);
 
	if (!e->IsGroundVehicle()) return false;
 

	
 
	if (!HasBit(e->info.callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return false;
 

	
 
	for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
 
		EngineID artic_engine = GetNextArticPart(i, engine);
 
		EngineID artic_engine = GetNextArticulatedPart(i, engine);
 
		if (artic_engine == INVALID_ENGINE) break;
 

	
 
		if (IsEngineRefittable(artic_engine)) return true;
 
	}
 

	
 
	return false;
 
@@ -162,13 +162,13 @@ void GetArticulatedRefitMasks(EngineID e
 
	*intersection_mask = (veh_cargos != 0) ? veh_cargos : UINT32_MAX;
 

	
 
	if (!e->IsGroundVehicle()) return;
 
	if (!HasBit(e->info.callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return;
 

	
 
	for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
 
		EngineID artic_engine = GetNextArticPart(i, engine);
 
		EngineID artic_engine = GetNextArticulatedPart(i, engine);
 
		if (artic_engine == INVALID_ENGINE) break;
 

	
 
		veh_cargos = GetAvailableVehicleCargoTypes(artic_engine, include_initial_cargo_type);
 
		*union_mask |= veh_cargos;
 
		if (veh_cargos != 0) *intersection_mask &= veh_cargos;
 
	}
 
@@ -220,13 +220,13 @@ bool IsArticulatedVehicleCarryingDiffere
 
				return true;
 
			}
 
		}
 

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

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

	
 
@@ -267,13 +267,13 @@ void CheckConsistencyOfArticulatedVehicl
 

	
 
		assert(v->cargo_type < NUM_CARGO);
 
		real_default_capacity[v->cargo_type] += v->cargo_cap;
 

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

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

	
 
@@ -303,13 +303,13 @@ void AddArticulatedParts(Vehicle *first)
 
	VehicleType type = first->type;
 
	if (!HasBit(EngInfo(first->engine_type)->callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return;
 

	
 
	Vehicle *v = first;
 
	for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
 
		bool flip_image;
 
		EngineID engine_type = GetNextArticPart(i, first->engine_type, first, &flip_image);
 
		EngineID engine_type = GetNextArticulatedPart(i, first->engine_type, first, &flip_image);
 
		if (engine_type == INVALID_ENGINE) return;
 

	
 
		/* In the (very rare) case the GRF reported wrong number of articulated parts
 
		 * and we run out of available vehicles, bail out. */
 
		if (!Vehicle::CanAllocateItem()) return;
 

	
src/train.h
Show inline comments
 
@@ -264,13 +264,13 @@ struct Train : public GroundVehicle<Trai
 
	/**
 
	 * Get the next part of a multi-part engine.
 
	 * Will only work on a multi-part engine (this->EngineHasArticPart() == true),
 
	 * Result is undefined for normal engine.
 
	 * @return next part of articulated engine
 
	 */
 
	FORCEINLINE Train *GetNextArticPart() const
 
	FORCEINLINE Train *GetNextArticulatedPart() const
 
	{
 
		assert(this->HasArticulatedPart());
 
		return this->Next();
 
	}
 

	
 
	/**
 
@@ -299,24 +299,24 @@ struct Train : public GroundVehicle<Trai
 
	 * Get the last part of a multi-part engine.
 
	 * @return Last part of the engine.
 
	 */
 
	FORCEINLINE Train *GetLastEnginePart()
 
	{
 
		Train *v = this;
 
		while (v->HasArticulatedPart()) v = v->GetNextArticPart();
 
		while (v->HasArticulatedPart()) v = v->GetNextArticulatedPart();
 
		return v;
 
	}
 

	
 
	/**
 
	 * Get the next real (non-articulated part) vehicle in the consist.
 
	 * @return Next vehicle in the consist.
 
	 */
 
	FORCEINLINE Train *GetNextVehicle() const
 
	{
 
		const Train *v = this;
 
		while (v->HasArticulatedPart()) v = v->GetNextArticPart();
 
		while (v->HasArticulatedPart()) v = v->GetNextArticulatedPart();
 

	
 
		/* v now contains the last artic part in the engine */
 
		return v->Next();
 
	}
 

	
 
	/**
src/vehicle.cpp
Show inline comments
 
@@ -2370,13 +2370,13 @@ void GetVehicleSet(VehicleSet &set, Vehi
 
		Train *u = Train::From(v);
 
		/* If the first vehicle in the selection is part of an articulated vehicle, add the previous parts of the vehicle. */
 
		if (u->IsArticulatedPart()) {
 
			u = u->GetFirstEnginePart();
 
			while (u->index != v->index) {
 
				set.Include(u->index);
 
				u = u->GetNextArticPart();
 
				u = u->GetNextArticulatedPart();
 
			}
 
		}
 

	
 
		for (;u != NULL && num_vehicles > 0; num_vehicles--, u = u->Next()) {
 
			/* Include current vehicle in the selection. */
 
			set.Include(u->index);
src/vehicle_cmd.cpp
Show inline comments
 
@@ -761,13 +761,13 @@ CommandCost CmdCloneVehicle(TileIndex ti
 
				if (w->cargo_type != v->cargo_type || w->cargo_subtype != subtype) {
 
					CommandCost cost = DoCommand(0, w->index, v->cargo_type | (subtype << 8) | 1U << 16, flags, GetCmdRefitVeh(v));
 
					if (cost.Succeeded()) total_cost.AddCost(cost);
 
				}
 

	
 
				if (w->type == VEH_TRAIN && Train::From(w)->HasArticulatedPart()) {
 
					w = Train::From(w)->GetNextArticPart();
 
					w = Train::From(w)->GetNextArticulatedPart();
 
				} else if (w->type == VEH_ROAD && RoadVehicle::From(w)->HasArticulatedPart()) {
 
					w = w->Next();
 
				} else {
 
					break;
 
				}
 
			} else {
 
@@ -777,13 +777,13 @@ CommandCost CmdCloneVehicle(TileIndex ti
 
				if (v->cargo_type != initial_cargo && initial_cargo != CT_INVALID) {
 
					total_cost.AddCost(GetRefitCost(v->engine_type));
 
				}
 
			}
 

	
 
			if (v->type == VEH_TRAIN && Train::From(v)->HasArticulatedPart()) {
 
				v = Train::From(v)->GetNextArticPart();
 
				v = Train::From(v)->GetNextArticulatedPart();
 
			} else if (v->type == VEH_ROAD && RoadVehicle::From(v)->HasArticulatedPart()) {
 
				v = v->Next();
 
			} else {
 
				break;
 
			}
 
		} while (v != NULL);
0 comments (0 inline, 0 general)