MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / RemoveFromConsist

Function RemoveFromConsist

src/train_cmd.cpp:907–917  ·  view source on GitHub ↗

* Remove the given wagon from its consist. * @param part the part of the train to remove. * @param chain whether to remove the whole chain. */

Source from the content-addressed store, hash-verified

905 * @param chain whether to remove the whole chain.
906 */
907static 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.

Callers 2

NormaliseDualHeadsFunction · 0.85
ArrangeTrainsFunction · 0.85

Calls 5

SetNextMethod · 0.80
LastMethod · 0.45
GetLastEnginePartMethod · 0.45
PreviousMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected