From 7871ce1879d3dba99cdfecc50a41d571a8f7438a Mon Sep 17 00:00:00 2001 From: bjarni Date: Sun, 21 Jan 2007 00:13:39 +0000 Subject: (svn r8294) -Fix: deleting a vehicle with shared orders, but no orders would fail to reset prev_shared and next_shared -As a result, vehicles in the game could end up having prev/next pointers to vehicles, that was no longer in the game --- src/vehicle.cpp | 2 +- src/vehicle.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 2ebd1e2b2..e3cd3b08d 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -572,7 +572,7 @@ void DestroyVehicle(Vehicle *v) UpdateVehiclePosHash(v, INVALID_COORD, 0); v->next_hash = NULL; - if (v->orders != NULL) DeleteVehicleOrders(v); + if (IsPlayerBuildableVehicleType(v)) DeleteVehicleOrders(v); /* Now remove any artic part. This will trigger an other * destroy vehicle, which on his turn can remove any diff --git a/src/vehicle.h b/src/vehicle.h index 85b74135d..d831058d2 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -407,6 +407,18 @@ static inline void DeleteVehicle(Vehicle *v) v->type = 0; } +static inline bool IsPlayerBuildableVehicleType(const Vehicle *v) +{ + switch (v->type) { + case VEH_Train: + case VEH_Road: + case VEH_Ship: + case VEH_Aircraft: + return true; + } + return false; +} + #define FOR_ALL_VEHICLES_FROM(v, start) for (v = GetVehicle(start); v != NULL; v = (v->index + 1U < GetVehiclePoolSize()) ? GetVehicle(v->index + 1) : NULL) if (IsValidVehicle(v)) #define FOR_ALL_VEHICLES(v) FOR_ALL_VEHICLES_FROM(v, 0) -- cgit v1.2.3-70-g09d2