changeset 2998:669dab4d9b50 draft

(svn r3576) - Allow unused wagons have their ->first set. This fixes the faulty cache warning message, and noticably speeds up depot operations in large games.
author peter1138 <peter1138@openttd.org>
date Wed, 08 Feb 2006 08:18:29 +0000
parents ea59763ce06b
children 65932847ef9b
files vehicle.c
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/vehicle.c
+++ b/vehicle.c
@@ -504,7 +504,7 @@
 	assert(v != NULL);
 
 	if (v->first != NULL) {
-		if (IsFrontEngine(v->first)) return v->first;
+		if (IsFrontEngine(v->first) || IsFreeWagon(v->first)) return v->first;
 
 		DEBUG(misc, 0) ("v->first cache faulty. We shouldn't be here, rebuilding cache!");
 	}
@@ -518,7 +518,7 @@
 	while ((u = GetPrevVehicleInChain_bruteforce(v)) != NULL) v = u;
 
 	/* Set the first pointer of all vehicles in that chain to the first wagon */
-	if (IsFrontEngine(v))
+	if (IsFrontEngine(v) || IsFreeWagon(v))
 		for (u = (Vehicle *)v; u != NULL; u = u->next) u->first = (Vehicle *)v;
 
 	return (Vehicle*)v;