(svn r4094) - Allow unused wagons have their ->first set. This fixes the faulty 0.4
authorpeter1138
Fri, 24 Mar 2006 22:36:54 +0000
branch0.4
changeset 9961 a218bf9da016
parent 9960 69513d9dd707
child 9962 1a78e226e561
(svn r4094) - Allow unused wagons have their ->first set. This fixes the faulty
cache warning message, and noticably speeds up depot operations in large
games. Backport of r3576 from trunk
vehicle.c
--- a/vehicle.c	Thu Mar 23 17:52:08 2006 +0000
+++ b/vehicle.c	Fri Mar 24 22:36:54 2006 +0000
@@ -505,7 +505,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!");
 	}
@@ -519,7 +519,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;