summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-02-08 08:18:29 +0000
committerpeter1138 <peter1138@openttd.org>2006-02-08 08:18:29 +0000
commit2265915e6ce2b201fca854a07c0f539e83b5b63d (patch)
tree4ee4a2ac89e48bf98b7c8a14786f7a0049773972
parent0755e24ce41577282ef97156b0c50646880d9763 (diff)
downloadopenttd-2265915e6ce2b201fca854a07c0f539e83b5b63d.tar.xz
(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.
-rw-r--r--vehicle.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/vehicle.c b/vehicle.c
index 1d7feda07..4740ab9ac 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -504,7 +504,7 @@ Vehicle *GetFirstVehicleInChain(const Vehicle *v)
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 @@ Vehicle *GetFirstVehicleInChain(const Vehicle *v)
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;