summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-07-23 17:17:43 +0000
committertron <tron@openttd.org>2006-07-23 17:17:43 +0000
commitc4ed8e9ec4998dfa18a94fc13028bfadcfe67982 (patch)
treee71d6ae5c8d0bf41d69bc5b03b7510e8b3638c58
parent79e1f4eea0a959eee53a79385b16bd5e75936853 (diff)
downloadopenttd-c4ed8e9ec4998dfa18a94fc13028bfadcfe67982.tar.xz
(svn r5599) GetPrevVehicleInChain() may never fail to find a valid vehicle. Reflect this in the code
-rw-r--r--vehicle.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/vehicle.c b/vehicle.c
index b9bca4bfb..70fe7e696 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -486,11 +486,9 @@ Vehicle *GetPrevVehicleInChain(const Vehicle *v)
// Check to see if this is the first
if (v == u) return NULL;
- do {
- if (u->next == v) return u;
- } while ( ( u = u->next) != NULL);
+ for (; u->next != v; u = u->next) assert(u->next != NULL);
- return NULL;
+ return u;
}
/** Finds the first vehicle in a chain.