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

Method AddRootConsoleCommand3

core/logic/RootConsoleMenu.cpp:96–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96bool RootConsoleMenu::AddRootConsoleCommand3(const char *cmd,
97 const char *text,
98 IRootConsoleCommand *pHandler)
99{
100 if (m_Commands.contains(cmd))
101 return false;
102
103 /* Sort this into the menu */
104 List<ConsoleEntry *>::iterator iter = m_Menu.begin();
105 ConsoleEntry *pEntry;
106 bool inserted = false;
107 while (iter != m_Menu.end())
108 {
109 pEntry = (*iter);
110 if (strcmp(cmd, pEntry->command.c_str()) < 0)
111 {
112 ConsoleEntry *pNew = new ConsoleEntry;
113 pNew->command.assign(cmd);
114 pNew->description.assign(text);
115 pNew->cmd = pHandler;
116 m_Commands.insert(cmd, pNew);
117 m_Menu.insert(iter, pNew);
118 inserted = true;
119 break;
120 }
121 iter++;
122 }
123
124 if (!inserted)
125 {
126 ConsoleEntry *pNew = new ConsoleEntry;
127 pNew->command.assign(cmd);
128 pNew->description.assign(text);
129 pNew->cmd = pHandler;
130 m_Commands.insert(cmd, pNew);
131 m_Menu.push_back(pNew);
132 }
133
134 return true;
135}
136
137bool RootConsoleMenu::RemoveRootConsoleCommand(const char *cmd, IRootConsoleCommand *pHandler)
138{

Calls 6

push_backMethod · 0.80
containsMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected