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

Function GetDriverParam

src/driver.cpp:47–59  ·  view source on GitHub ↗

* Get a string parameter the list of parameters. * @param parm The parameters. * @param name The parameter name we're looking for. * @return The parameter value. */

Source from the content-addressed store, hash-verified

45 * @return The parameter value.
46 */
47std::optional<std::string_view> GetDriverParam(const StringList &parm, std::string_view name)
48{
49 if (parm.empty()) return std::nullopt;
50
51 for (auto &p : parm) {
52 StringConsumer consumer{p};
53 if (consumer.ReadIf(name)) {
54 if (!consumer.AnyBytesLeft()) return "";
55 if (consumer.ReadIf("=")) return consumer.GetLeftData();
56 }
57 }
58 return std::nullopt;
59}
60
61/**
62 * Get a boolean parameter the list of parameters.

Callers 6

GetDriverParamBoolFunction · 0.85
GetDriverParamIntFunction · 0.85
StartMethod · 0.85
StartMethod · 0.85
StartMethod · 0.85
StartMethod · 0.85

Calls 4

ReadIfMethod · 0.80
AnyBytesLeftMethod · 0.80
GetLeftDataMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected