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

Method _FillParamList

src/script/api/script_text.cpp:199–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199void ScriptText::_FillParamList(ParamList &params, ScriptTextList &seen_texts)
200{
201 if (std::ranges::find(seen_texts, this) != seen_texts.end()) throw Script_FatalError(fmt::format("{}: Circular reference detected", GetGameStringName(this->string)));
202 seen_texts.push_back(this);
203
204 for (int idx = 0; Param &p : this->param) {
205 params.emplace_back(this->string, idx, &p);
206 ++idx;
207 if (!std::holds_alternative<ScriptTextRef>(p)) continue;
208 std::get<ScriptTextRef>(p)->_FillParamList(params, seen_texts);
209 }
210
211 seen_texts.pop_back();
212
213 /* Fill with dummy parameters to match old FormatString() compatibility behaviour. */
214 if (seen_texts.empty() && ScriptText::pad_parameter_count > 0) {
215 static Param dummy = {};
216 for (int idx = static_cast<int>(std::size(this->param)); idx < ScriptText::pad_parameter_count; ++idx) {
217 params.emplace_back(StringIndexInTab(-1), idx, &dummy);
218 }
219 }
220}
221
222void ScriptText::ParamCheck::Encode(StringBuilder &builder, std::string_view cmd)
223{

Callers 1

GetEncodedTextMethod · 0.95

Calls 8

Script_FatalErrorClass · 0.85
push_backMethod · 0.80
pop_backMethod · 0.80
findFunction · 0.50
formatFunction · 0.50
sizeFunction · 0.50
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected