| 537 | } |
| 538 | |
| 539 | ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *description, int flags, IPlugin *pPlugin) |
| 540 | { |
| 541 | ConCmdInfo *pInfo; |
| 542 | if (!m_Cmds.retrieve(name, &pInfo)) |
| 543 | { |
| 544 | pInfo = new ConCmdInfo(); |
| 545 | /* Find the commandopan */ |
| 546 | ConCommand *pCmd = FindCommand(name); |
| 547 | |
| 548 | if (!pCmd) |
| 549 | { |
| 550 | /* Note that we have to duplicate because the source might not be |
| 551 | * a static string, and these expect static memory. |
| 552 | */ |
| 553 | if (!description) |
| 554 | { |
| 555 | description = ""; |
| 556 | } |
| 557 | char *new_name = sm_strdup(name); |
| 558 | char *new_help = sm_strdup(description); |
| 559 | pCmd = new ConCommand(new_name, CommandCallback, new_help, flags); |
| 560 | pInfo->pPlugin = pPlugin; |
| 561 | pInfo->sourceMod = true; |
| 562 | } |
| 563 | else |
| 564 | { |
| 565 | TrackConCommandBase(pCmd, this); |
| 566 | CommandHook::Callback callback = [this] (int client, const ICommandArgs *args) -> bool { |
| 567 | AutoEnterCommand autoEnterCommand(args); |
| 568 | return this->InternalDispatch(client, args); |
| 569 | }; |
| 570 | pInfo->sh_hook = sCoreProviderImpl.AddCommandHook(pCmd, callback); |
| 571 | } |
| 572 | |
| 573 | pInfo->pCmd = pCmd; |
| 574 | |
| 575 | m_Cmds.insert(name, pInfo); |
| 576 | AddToCmdList(pInfo); |
| 577 | } |
| 578 | |
| 579 | return pInfo; |
| 580 | } |
| 581 | |
| 582 | void ConCmdManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command) |
| 583 | { |
nothing calls this directly
no test coverage detected