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

Function ExtractStringParams

src/game/game_text.cpp:257–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255}
256
257static void ExtractStringParams(const StringData &data, StringParamsList &params)
258{
259 for (size_t i = 0; i < data.max_strings; i++) {
260 const LangString *ls = data.strings[i].get();
261
262 if (ls != nullptr) {
263 StringParams &param = params.emplace_back();
264 ParsedCommandStruct pcs = ExtractCommandString(ls->english, false);
265
266 for (auto it = pcs.consuming_commands.begin(); it != pcs.consuming_commands.end(); it++) {
267 if (*it == nullptr) {
268 /* Skip empty param unless a non empty param exist after it. */
269 if (std::all_of(it, pcs.consuming_commands.end(), [](auto cs) { return cs == nullptr; })) break;
270 param.emplace_back(StringParam::UNUSED, 1);
271 continue;
272 }
273 const CmdStruct *cs = *it;
274 param.emplace_back(GetParamType(cs), cs->consumes, cs->cmd);
275 }
276 }
277 }
278}
279
280/** Compile the language. */
281void GameStrings::Compile()

Callers 1

CompileMethod · 0.85

Calls 5

ExtractCommandStringFunction · 0.85
GetParamTypeFunction · 0.85
getMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected