* Restore the train from the backup list. * @param list the train to restore. */
| 882 | * @param list the train to restore. |
| 883 | */ |
| 884 | static void RestoreTrainBackup(TrainList &list) |
| 885 | { |
| 886 | /* No train, nothing to do. */ |
| 887 | if (list.empty()) return; |
| 888 | |
| 889 | Train *prev = nullptr; |
| 890 | /* Iterate over the list and rebuild it. */ |
| 891 | for (Train *t : list) { |
| 892 | if (prev != nullptr) { |
| 893 | prev->SetNext(t); |
| 894 | } else if (t->Previous() != nullptr) { |
| 895 | /* Make sure the head of the train is always the first in the chain. */ |
| 896 | t->Previous()->SetNext(nullptr); |
| 897 | } |
| 898 | prev = t; |
| 899 | } |
| 900 | } |
| 901 | |
| 902 | /** |
| 903 | * Remove the given wagon from its consist. |
no test coverage detected