summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/industry_cmd.cpp5
-rw-r--r--src/train_cmd.cpp22
-rw-r--r--src/vehicle_base.h3
-rw-r--r--src/water_cmd.cpp14
4 files changed, 17 insertions, 27 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index c07244978..a889d08ed 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1953,10 +1953,9 @@ int WhoCanServiceIndustry(Industry* ind)
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 {
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 56bf2a9a7..69ba0f779 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -2807,10 +2807,10 @@ static void SetVehicleCrashed(Vehicle *v)
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);
@@ -2819,9 +2819,11 @@ static void SetVehicleCrashed(Vehicle *v)
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;
}
@@ -3651,9 +3653,7 @@ void ConnectMultiheadedTrains()
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)) {
@@ -3678,7 +3678,7 @@ void ConnectMultiheadedTrains()
ClearMultiheaded(u);
}
}
- } END_ENUM_WAGONS(u)
+ }
}
}
}
@@ -3699,9 +3699,7 @@ 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);
@@ -3740,7 +3738,7 @@ void ConvertOldMultiheadToNew()
break;
default: NOT_REACHED(); break;
}
- } END_ENUM_WAGONS(u)
+ }
}
}
}
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index 894890169..0defc9566 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -564,9 +564,6 @@ struct InvalidVehicle : public 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
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 0f41878f2..fa6a654b4 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -819,19 +819,15 @@ static void FloodVehicle(Vehicle *v)
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();