Changeset - r9321:a3548467da58
[Not reviewed]
master
0 4 0
peter1138 - 16 years ago 2008-05-21 12:06:05
peter1138@openttd.org
(svn r13205) -Codechange: Remove unnecessary code-style-buggering-up macro.
4 files changed with 17 insertions and 27 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -1950,16 +1950,15 @@ int WhoCanServiceIndustry(Industry* ind)
 
		if (v->owner != _local_player && result != 0) continue;
 

	
 
		/* Check whether it accepts the right kind of cargo */
 
		bool c_accepts = false;
 
		bool c_produces = false;
 
		if (v->type == VEH_TRAIN && IsFrontEngine(v)) {
 
			const Vehicle *u = v;
 
			BEGIN_ENUM_WAGONS(u)
 
			for (const Vehicle *u = v; u != NULL; u = u->Next()) {
 
				CanCargoServiceIndustry(u->cargo_type, ind, &c_accepts, &c_produces);
 
			END_ENUM_WAGONS(u)
 
			}
 
		} else if (v->type == VEH_ROAD || v->type == VEH_SHIP || v->type == VEH_AIRCRAFT) {
 
			CanCargoServiceIndustry(v->cargo_type, ind, &c_accepts, &c_produces);
 
		} else {
 
			continue;
 
		}
 
		if (!c_accepts && !c_produces) continue; // Wrong cargo
src/train_cmd.cpp
Show inline comments
 
@@ -2804,27 +2804,29 @@ static void SetVehicleCrashed(Vehicle *v
 
	if (v->u.rail.track == TRACK_BIT_DEPOT) {
 
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
	}
 

	
 
	InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
 

	
 
	BEGIN_ENUM_WAGONS(v)
 
	for (; v != NULL; v = v->Next()) {
 
		v->vehstatus |= VS_CRASHED;
 
		MarkSingleVehicleDirty(v);
 
	END_ENUM_WAGONS(v)
 
	}
 

	
 
	/* must be updated after the train has been marked crashed */
 
	if (crossing != INVALID_TILE) UpdateLevelCrossing(crossing);
 
}
 

	
 
static uint CountPassengersInTrain(const Vehicle *v)
 
{
 
	uint num = 0;
 
	BEGIN_ENUM_WAGONS(v)
 

	
 
	for (; v != NULL; v = v->Next()) {
 
		if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) num += v->cargo.Count();
 
	END_ENUM_WAGONS(v)
 
	}
 

	
 
	return num;
 
}
 

	
 
struct TrainCollideChecker {
 
	Vehicle *v;  ///< vehicle we are testing for collision
 
	uint num;    ///< number of dead if train collided
 
@@ -3648,15 +3650,13 @@ void ConnectMultiheadedTrains()
 
			v->u.rail.other_multiheaded_part = NULL;
 
		}
 
	}
 

	
 
	FOR_ALL_VEHICLES(v) {
 
		if (v->type == VEH_TRAIN && IsFrontEngine(v)) {
 
			Vehicle *u = v;
 

	
 
			BEGIN_ENUM_WAGONS(u) {
 
			for (Vehicle *u = v; u != NULL; u = u->Next()) {
 
				if (u->u.rail.other_multiheaded_part != NULL) continue; // we already linked this one
 

	
 
				if (IsMultiheaded(u)) {
 
					if (!IsTrainEngine(u)) {
 
						/* we got a rear car without a front car. We will convert it to a front one */
 
						SetTrainEngine(u);
 
@@ -3675,13 +3675,13 @@ void ConnectMultiheadedTrains()
 
						u->u.rail.other_multiheaded_part = w;
 
					} else {
 
						/* we got a front car and no rear cars. We will fake this one for forget that it should have been multiheaded */
 
						ClearMultiheaded(u);
 
					}
 
				}
 
			} END_ENUM_WAGONS(u)
 
			}
 
		}
 
	}
 
}
 

	
 
/**
 
 *  Converts all trains to the new subtype format introduced in savegame 16.2
 
@@ -3696,15 +3696,13 @@ void ConvertOldMultiheadToNew()
 
		}
 
	}
 

	
 
	FOR_ALL_VEHICLES(v) {
 
		if (v->type == VEH_TRAIN) {
 
			if (HasBit(v->subtype, 7) && ((v->subtype & ~0x80) == 0 || (v->subtype & ~0x80) == 4)) {
 
				Vehicle *u = v;
 

	
 
				BEGIN_ENUM_WAGONS(u) {
 
				for (Vehicle *u = v; u != NULL; u = u->Next()) {
 
					const RailVehicleInfo *rvi = RailVehInfo(u->engine_type);
 

	
 
					ClrBit(u->subtype, 7);
 
					switch (u->subtype) {
 
						case 0: /* TS_Front_Engine */
 
							if (rvi->railveh_type == RAILVEH_MULTIHEAD) SetMultiheaded(u);
 
@@ -3737,11 +3735,11 @@ void ConvertOldMultiheadToNew()
 
							u->subtype = 0;
 
							SetTrainWagon(u);
 
							SetFreeWagon(u);
 
							break;
 
						default: NOT_REACHED(); break;
 
					}
 
				} END_ENUM_WAGONS(u)
 
				}
 
			}
 
		}
 
	}
 
}
src/vehicle_base.h
Show inline comments
 
@@ -561,15 +561,12 @@ struct InvalidVehicle : public Vehicle {
 
	virtual ~InvalidVehicle() {}
 

	
 
	const char *GetTypeString() const { return "invalid vehicle"; }
 
	void Tick() {}
 
};
 

	
 
#define BEGIN_ENUM_WAGONS(v) do {
 
#define END_ENUM_WAGONS(v) } while ((v = v->Next()) != NULL);
 

	
 
static inline VehicleID GetMaxVehicleIndex()
 
{
 
	/* TODO - This isn't the real content of the function, but
 
	 *  with the new pool-system this will be replaced with one that
 
	 *  _really_ returns the highest index. Now it just returns
 
	 *  the next safe value we are sure about everything is below.
src/water_cmd.cpp
Show inline comments
 
@@ -816,25 +816,21 @@ static void FloodVehicle(Vehicle *v)
 
				if (!IsTileType(v->tile, MP_STATION) || !IsAirport(v->tile) || GetTileMaxZ(v->tile) != 0) return;
 
				const Station *st = GetStationByTile(v->tile);
 
				const AirportFTAClass *airport = st->Airport();
 

	
 
				if (v->z_pos != airport->delta_z + 1) return;
 
			}
 
			Vehicle *u;
 

	
 
			if (v->type != VEH_AIRCRAFT) v = v->First();
 
			u = v;
 

	
 
			/* crash all wagons, and count passengers */
 
			BEGIN_ENUM_WAGONS(v)
 
				if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) pass += v->cargo.Count();
 
				v->vehstatus |= VS_CRASHED;
 
				MarkSingleVehicleDirty(v);
 
			END_ENUM_WAGONS(v)
 

	
 
			v = u;
 
			for (Vehicle *u = v; u != NULL; u = u->Next()) {
 
				if (IsCargoInClass(u->cargo_type, CC_PASSENGERS)) pass += u->cargo.Count();
 
				u->vehstatus |= VS_CRASHED;
 
				MarkSingleVehicleDirty(u);
 
			}
 

	
 
			switch (v->type) {
 
				default: NOT_REACHED();
 
				case VEH_TRAIN:
 
					if (IsFrontEngine(v)) pass += 4; // driver
 
					v->u.rail.crash_anim_pos = 4000; // max 4440, disappear pretty fast
0 comments (0 inline, 0 general)