summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormaedhros <maedhros@openttd.org>2007-06-02 09:11:06 +0000
committermaedhros <maedhros@openttd.org>2007-06-02 09:11:06 +0000
commit8f361393ddd26f2f1a08a108bb74c6bbfc6cab56 (patch)
tree8678c073dba5d9f177f55cb67813b6e68a63723e /src
parent06084e0a63a78bb1844916ddf59e5d8c174da380 (diff)
downloadopenttd-8f361393ddd26f2f1a08a108bb74c6bbfc6cab56.tar.xz
(svn r10020) -Fix [FS#824]: GetNextVehicle() is invalid for anything that isn't a train.
Diffstat (limited to 'src')
-rw-r--r--src/vehicle.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 298bcfcaf..d6c46e5e5 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -612,11 +612,20 @@ void DestroyVehicle(Vehicle *v)
if (v->type == VEH_TRAIN && EngineHasArticPart(v)) DeleteVehicle(v->next);
}
+/**
+ * Deletes all vehicles in a chain.
+ * @param v The first vehicle in the chain.
+ *
+ * @warning This function is not valid for any vehicle containing articulated
+ * parts.
+ */
void DeleteVehicleChain(Vehicle *v)
{
+ assert(v->type != VEH_TRAIN);
+
do {
Vehicle *u = v;
- v = GetNextVehicle(v);
+ v = v->next;
DeleteVehicle(u);
} while (v != NULL);
}