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

Function NormaliseSubtypes

src/train_cmd.cpp:960–981  ·  view source on GitHub ↗

* Normalise the sub types of the parts in this chain. * @param chain the chain to normalise. */

Source from the content-addressed store, hash-verified

958 * @param chain the chain to normalise.
959 */
960static 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.

Callers 2

CmdMoveRailVehicleFunction · 0.85
CmdSellRailWagonFunction · 0.85

Calls 8

SetFreeWagonMethod · 0.80
IsEngineMethod · 0.80
SetFrontEngineMethod · 0.80
ClearFreeWagonMethod · 0.80
ClearFrontEngineMethod · 0.80
PreviousMethod · 0.45
IsWagonMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected