MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / OnRootConsoleCommand

Method OnRootConsoleCommand

core/logic/ProfileTools.cpp:98–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98void
99ProfileToolManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs *args)
100{
101 if (tools_.size() == 0) {
102 rootmenu->ConsolePrint("No profiling tools are enabled.");
103 return;
104 }
105
106 if (args->ArgC() >= 3) {
107 cmdname = args->Arg(2);
108
109 if (strcmp(cmdname, "list") == 0) {
110 rootmenu->ConsolePrint("Profiling tools:");
111 for (size_t i = 0; i < tools_.size(); i++) {
112 rootmenu->DrawGenericOption(tools_[i]->Name(), tools_[i]->Description());
113 }
114 return;
115 }
116 if (strcmp(cmdname, "stop") == 0) {
117 if (!active_) {
118 rootmenu->ConsolePrint("No profiler is active.");
119 return;
120 }
121 g_pPawnEnv->DisableProfiling();
122 g_pPawnEnv->SetProfilingTool(nullptr);
123 active_->Stop(render_help);
124 active_ = nullptr;
125 return;
126 }
127 if (strcmp(cmdname, "dump") == 0) {
128 if (active_) {
129 // if we have an active profiler, dump it
130 active_->Dump();
131 return;
132 }
133 }
134
135 if (args->ArgC() < 4) {
136 if (strcmp(cmdname, "start") == 0) {
137 if (!default_) {
138 default_ = FindToolByName("vprof");
139 if (!default_ && tools_.size() > 0)
140 default_ = tools_[0];
141 if (!default_) {
142 rootmenu->ConsolePrint("Could not find any profiler to use.");
143 return;
144 }
145 }
146 StartFromConsole(default_);
147 return;
148 }
149 }
150
151 if (args->ArgC() < 4) {
152 rootmenu->ConsolePrint("You must specify a profiling tool name.");
153 return;
154 }
155

Callers

nothing calls this directly

Calls 10

DrawGenericOptionMethod · 0.80
NameMethod · 0.80
DescriptionMethod · 0.80
RenderHelpMethod · 0.80
sizeMethod · 0.45
ConsolePrintMethod · 0.45
ArgCMethod · 0.45
ArgMethod · 0.45
StopMethod · 0.45
DumpMethod · 0.45

Tested by

no test coverage detected