(svn r1979) Const correctness

This commit is contained in:
tron
2005-03-09 21:54:52 +00:00
parent 9bd079d425
commit e5121e70d0
5 changed files with 18 additions and 21 deletions

View File

@@ -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;
}
}