MCPcopy Create free account
hub / github.com/crawl/crawl / hint_replace_cmds

Function hint_replace_cmds

crawl-ref/source/hints.cc:324–361  ·  view source on GitHub ↗

Substitute $cmd[CMD_FOO] with the corresponding key, and likewise transform foo .

Source from the content-addressed store, hash-verified

322/// Substitute $cmd[CMD_FOO] with the corresponding key, and likewise
323/// transform <input>foo</input>.
324void hint_replace_cmds(string &text)
325{
326 size_t p;
327 while ((p = text.find("$cmd[")) != string::npos)
328 {
329 size_t q = text.find("]", p + 5);
330 if (q == string::npos)
331 {
332 text += "<lightred>ERROR: unterminated $cmd</lightred>";
333 break;
334 }
335
336 string command = text.substr(p + 5, q - p - 5);
337 command_type cmd = name_to_command(command);
338
339 command = command_to_string(cmd);
340 if (command == "<")
341 command += "<";
342
343 text.replace(p, q - p + 1, command);
344 }
345
346 // Brand user-input -related (tutorial) items with <w>[(text here)]</w>.
347 while ((p = text.find("<input>")) != string::npos)
348 {
349 size_t q = text.find("</input>", p + 7);
350 if (q == string::npos)
351 {
352 text += "<lightred>ERROR: unterminated <input></lightred>";
353 break;
354 }
355
356 string input = text.substr(p + 7, q - p - 7);
357 input = "<w>[" + input;
358 input += "]</w>";
359 text.replace(p, q - p + 8, input);
360 }
361}
362
363static void _replace_static_tags(string &text)
364{

Callers 4

bane_long_descriptionFunction · 0.85
examine_indexMethod · 0.85
get_mutation_descFunction · 0.85
_replace_static_tagsFunction · 0.85

Calls 5

name_to_commandFunction · 0.85
command_to_stringFunction · 0.85
substrMethod · 0.80
replaceMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected