(svn r18463) -Codechange: some simplifications for finding the end of a vehicle

This commit is contained in:
rubidium 2009-12-11 19:28:28 +00:00
parent b8a7efc450
commit 53d6d4a094

View File

@ -1402,9 +1402,7 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u
if (move_chain) { if (move_chain) {
/* unlink ALL wagons */ /* unlink ALL wagons */
if (src != src_head) { if (src != src_head) {
Train *v = src_head; src->Previous()->SetNext(NULL);
while (v->GetNextVehicle() != src) v = v->GetNextVehicle();
v->GetLastEnginePart()->SetNext(NULL);
} else { } else {
InvalidateWindowData(WC_VEHICLE_DEPOT, src_head->tile); // We removed a line InvalidateWindowData(WC_VEHICLE_DEPOT, src_head->tile); // We removed a line
src_head = NULL; src_head = NULL;
@ -1463,8 +1461,8 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u
{ {
Train *v; Train *v;
for (v = src; v->GetNextVehicle() != NULL; v = v->GetNextVehicle()) {} for (v = src; v->Next() != NULL; v = v->Next()) {}
v->GetLastEnginePart()->SetNext(dst->Next()); v->SetNext(dst->Next());
} }
dst->SetNext(src); dst->SetNext(src);
} }