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

Function ValidateTrains

src/train_cmd.cpp:1130–1140  ·  view source on GitHub ↗

* Validate whether we are going to create valid trains. * @note All vehicles are/were 'heads' of their chains. * @param original_dst The original destination chain. * @param dst The destination chain after constructing the train. * @param original_src The original source chain. * @param src The source chain after constructing the train. * @param check_limit Whether to chec

Source from the content-addressed store, hash-verified

1128 * @return possible error of this command.
1129 */
1130static CommandCost ValidateTrains(Train *original_dst, Train *dst, Train *original_src, Train *src, bool check_limit)
1131{
1132 /* Check whether we may actually construct the trains. */
1133 CommandCost ret = CheckTrainAttachment(src);
1134 if (ret.Failed()) return ret;
1135 ret = CheckTrainAttachment(dst);
1136 if (ret.Failed()) return ret;
1137
1138 /* Check whether we need to build a new train. */
1139 return check_limit ? CheckNewTrain(original_dst, dst, original_src, src) : CommandCost();
1140}
1141
1142/**
1143 * Arrange the trains in the wanted way.

Callers 2

CmdMoveRailVehicleFunction · 0.85
CmdSellRailWagonFunction · 0.85

Calls 4

CheckTrainAttachmentFunction · 0.85
CheckNewTrainFunction · 0.85
CommandCostClass · 0.85
FailedMethod · 0.80

Tested by

no test coverage detected