Add whether the vehicle is non-front to the vehicle pool pointer tag

Add iteration filters which check this
This commit is contained in:
Jonathan G Rennison
2024-02-25 14:49:31 +00:00
parent 05e237f8d1
commit 93bf033107
23 changed files with 145 additions and 81 deletions

View File

@@ -4317,6 +4317,9 @@ void Vehicle::SetNext(Vehicle *next)
v->first = this->next;
}
this->next->previous = nullptr;
#if OTTD_UPPER_TAGGED_PTR
VehiclePoolOps::SetIsNonFrontVehiclePtr(_vehicle_pool.GetRawRef(this->next->index), false);
#endif
}
this->next = next;
@@ -4325,6 +4328,9 @@ void Vehicle::SetNext(Vehicle *next)
/* A new next vehicle. Update the first and previous pointers */
if (this->next->previous != nullptr) this->next->previous->next = nullptr;
this->next->previous = this;
#if OTTD_UPPER_TAGGED_PTR
VehiclePoolOps::SetIsNonFrontVehiclePtr(_vehicle_pool.GetRawRef(this->next->index), true);
#endif
for (Vehicle *v = this->next; v != nullptr; v = v->Next()) {
v->first = this->first;
}
@@ -4549,7 +4555,7 @@ char *Vehicle::DumpVehicleFlagsMultiline(char *b, const char *last, const char *
void VehiclesYearlyLoop()
{
for (Vehicle *v : Vehicle::Iterate()) {
for (Vehicle *v : Vehicle::IterateFrontOnly()) {
if (v->IsPrimaryVehicle()) {
/* show warning if vehicle is not generating enough income last 2 years (corresponds to a red icon in the vehicle list) */
Money profit = v->GetDisplayProfitThisYear();