Add wrapper to iterate vehicle pool with vehicle type filter
Without needing to dereference vehicle pointers if using tagged pointers
This commit is contained in:
@@ -595,12 +595,12 @@ void FixupTrainLengths()
|
||||
{
|
||||
/* Vehicle center was moved from 4 units behind the front to half the length
|
||||
* behind the front. Move vehicles so they end up on the same spot. */
|
||||
for (Vehicle *v : Vehicle::Iterate()) {
|
||||
if (v->type == VEH_TRAIN && v->IsPrimaryVehicle()) {
|
||||
for (Train *v : Train::Iterate()) {
|
||||
if (v->IsPrimaryVehicle()) {
|
||||
/* The vehicle center is now more to the front depending on vehicle length,
|
||||
* so we need to move all vehicles forward to cover the difference to the
|
||||
* old center, otherwise wagon spacing in trains would be broken upon load. */
|
||||
for (Train *u = Train::From(v); u != nullptr; u = u->Next()) {
|
||||
for (Train *u = v; u != nullptr; u = u->Next()) {
|
||||
if (u->track == TRACK_BIT_DEPOT || (u->vehstatus & VS_CRASHED)) continue;
|
||||
|
||||
Train *next = u->Next();
|
||||
@@ -670,7 +670,7 @@ void FixupTrainLengths()
|
||||
}
|
||||
|
||||
/* Update all cached properties after moving the vehicle chain around. */
|
||||
Train::From(v)->ConsistChanged(CCF_TRACK);
|
||||
v->ConsistChanged(CCF_TRACK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -149,9 +149,7 @@ void MoveWaypointsToBaseStations()
|
||||
for (Order *o = ol->GetFirstOrder(); o != nullptr; o = o->next) UpdateWaypointOrder(o);
|
||||
}
|
||||
|
||||
for (Vehicle *v : Vehicle::Iterate()) {
|
||||
if (v->type != VEH_TRAIN) continue;
|
||||
|
||||
for (Vehicle *v : Vehicle::IterateType(VEH_TRAIN)) {
|
||||
UpdateWaypointOrder(&v->current_order);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user