* Normalise the dual heads in the train, i.e. if one is * missing move that one to this train. * @param t the train to normalise. */
| 936 | * @param t the train to normalise. |
| 937 | */ |
| 938 | static void NormaliseDualHeads(Train *t) |
| 939 | { |
| 940 | for (; t != nullptr; t = t->GetNextVehicle()) { |
| 941 | if (!t->IsMultiheaded() || !t->IsEngine()) continue; |
| 942 | |
| 943 | /* Make sure that there are no free cars before next engine */ |
| 944 | Train *u; |
| 945 | for (u = t; u->Next() != nullptr && !u->Next()->IsEngine(); u = u->Next()) {} |
| 946 | |
| 947 | if (u == t->other_multiheaded_part) continue; |
| 948 | |
| 949 | /* Remove the part from the 'wrong' train */ |
| 950 | RemoveFromConsist(t->other_multiheaded_part); |
| 951 | /* And add it to the 'right' train */ |
| 952 | InsertInConsist(u, t->other_multiheaded_part); |
| 953 | } |
| 954 | } |
| 955 | |
| 956 | /** |
| 957 | * Normalise the sub types of the parts in this chain. |
no test coverage detected