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

Function FindGoodVehiclePos

src/train_cmd.cpp:849–865  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

847}
848
849static Train *FindGoodVehiclePos(const Train *src)
850{
851 EngineID eng = src->engine_type;
852
853 for (VehicleID vehicle : GetFreeWagonsInDepot(src->tile)) {
854 Train *dst = Train::Get(vehicle);
855
856 /* check so all vehicles in the line have the same engine. */
857 Train *t = dst;
858 while (t->engine_type == eng) {
859 t = t->Next();
860 if (t == nullptr) return dst;
861 }
862 }
863
864 return nullptr;
865}
866
867/** Helper type for lists/vectors of trains */
868typedef std::vector<Train *> TrainList;

Callers 1

CmdMoveRailVehicleFunction · 0.85

Calls 2

GetFreeWagonsInDepotFunction · 0.85
NextMethod · 0.45

Tested by

no test coverage detected