From e5121e70d0bc12ec82dba3ba6f114d5137b69fec Mon Sep 17 00:00:00 2001 From: tron Date: Wed, 9 Mar 2005 21:54:52 +0000 Subject: (svn r1979) Const correctness --- vehicle.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'vehicle.c') diff --git a/vehicle.c b/vehicle.c index 1fdbd670c..9faf679e6 100644 --- a/vehicle.c +++ b/vehicle.c @@ -365,29 +365,28 @@ Vehicle *GetLastVehicleInChain(Vehicle *v) 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) { - u = v; + const Vehicle* 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; } } -- cgit v1.2.3-54-g00ecf