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

Function RestoreTrainBackup

src/train_cmd.cpp:884–900  ·  view source on GitHub ↗

* Restore the train from the backup list. * @param list the train to restore. */

Source from the content-addressed store, hash-verified

882 * @param list the train to restore.
883 */
884static 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.

Callers 2

CmdMoveRailVehicleFunction · 0.85
CmdSellRailWagonFunction · 0.85

Calls 3

SetNextMethod · 0.80
emptyMethod · 0.45
PreviousMethod · 0.45

Tested by

no test coverage detected