--- a/vehicle.c Wed Mar 09 19:48:20 2005 +0000
+++ b/vehicle.c Wed Mar 09 21:54:52 2005 +0000
@@ -365,29 +365,28 @@
return v;
}
-Vehicle *GetPrevVehicleInChain(Vehicle *v)
+Vehicle *GetPrevVehicleInChain(const Vehicle *v)
{
- Vehicle *org = v;
+ const Vehicle *org = v;
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_Train && org == v->next)
- return v;
+ return (Vehicle*)v;
}
return NULL;
}
-Vehicle *GetFirstVehicleInChain(Vehicle *v)
+Vehicle *GetFirstVehicleInChain(const Vehicle *v)
{
- Vehicle *u;
+ while (true) {
+ const Vehicle* u = v;
- while (true) {
- u = v;
v = GetPrevVehicleInChain(v);
/* If there is no such vehicle,
'v' == NULL and so 'u' is the first vehicle in chain */
if (v == NULL)
- return u;
+ return (Vehicle*)u;
}
}