MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / Run

Function Run

engine/Poseidon/Dev/Debug/DebugCommands.cpp:50–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50bool Run(std::string_view line, std::string& out)
51{
52 // Trim leading whitespace
53 while (!line.empty() && (line.front() == ' ' || line.front() == '\t'))
54 line.remove_prefix(1);
55 if (line.empty())
56 return false;
57
58 // Split on first whitespace.
59 size_t sp = 0;
60 while (sp < line.size() && line[sp] != ' ' && line[sp] != '\t')
61 sp++;
62 std::string_view name = line.substr(0, sp);
63 std::string_view args;
64 if (sp < line.size())
65 {
66 args = line.substr(sp + 1);
67 while (!args.empty() && (args.front() == ' ' || args.front() == '\t'))
68 args.remove_prefix(1);
69 }
70
71 const Command* cmd = Find(name);
72 if (!cmd)
73 {
74 out = "unknown command: " + std::string(name);
75 return false;
76 }
77 if (cmd->available && !cmd->available())
78 {
79 out = "command unavailable: " + std::string(name);
80 return true;
81 }
82 cmd->invoke(args, out);
83 return true;
84}
85
86} // namespace DebugCommands
87} // namespace Poseidon::Dev

Callers 3

ConsoleRunFunction · 0.85
TriConsoleRunFunction · 0.85

Calls 3

FindFunction · 0.85
sizeMethod · 0.80
emptyMethod · 0.45

Tested by 1

TriConsoleRunFunction · 0.68