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