* Normalise the sub types of the parts in this chain. * @param chain the chain to normalise. */
| 958 | * @param chain the chain to normalise. |
| 959 | */ |
| 960 | static void NormaliseSubtypes(Train *chain) |
| 961 | { |
| 962 | /* Nothing to do */ |
| 963 | if (chain == nullptr) return; |
| 964 | |
| 965 | /* We must be the first in the chain. */ |
| 966 | assert(chain->Previous() == nullptr); |
| 967 | |
| 968 | /* Set the appropriate bits for the first in the chain. */ |
| 969 | if (chain->IsWagon()) { |
| 970 | chain->SetFreeWagon(); |
| 971 | } else { |
| 972 | assert(chain->IsEngine()); |
| 973 | chain->SetFrontEngine(); |
| 974 | } |
| 975 | |
| 976 | /* Now clear the bits for the rest of the chain */ |
| 977 | for (Train *t = chain->Next(); t != nullptr; t = t->Next()) { |
| 978 | t->ClearFreeWagon(); |
| 979 | t->ClearFrontEngine(); |
| 980 | } |
| 981 | } |
| 982 | |
| 983 | /** |
| 984 | * Check/validate whether we may actually build a new train. |
no test coverage detected