* Remove the given wagon from its consist. * @param part the part of the train to remove. * @param chain whether to remove the whole chain. */
| 905 | * @param chain whether to remove the whole chain. |
| 906 | */ |
| 907 | static void RemoveFromConsist(Train *part, bool chain = false) |
| 908 | { |
| 909 | Train *tail = chain ? part->Last() : part->GetLastEnginePart(); |
| 910 | |
| 911 | /* Unlink at the front, but make it point to the next |
| 912 | * vehicle after the to be remove part. */ |
| 913 | if (part->Previous() != nullptr) part->Previous()->SetNext(tail->Next()); |
| 914 | |
| 915 | /* Unlink at the back */ |
| 916 | tail->SetNext(nullptr); |
| 917 | } |
| 918 | |
| 919 | /** |
| 920 | * Inserts a chain into the train at dst. |
no test coverage detected