| 1700 | } |
| 1701 | |
| 1702 | void CPluginManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command) |
| 1703 | { |
| 1704 | int argcount = command->ArgC(); |
| 1705 | if (argcount >= 3) |
| 1706 | { |
| 1707 | const char *cmd = command->Arg(2); |
| 1708 | if (strcmp(cmd, "list") == 0) |
| 1709 | { |
| 1710 | char buffer[256]; |
| 1711 | unsigned int id = 1; |
| 1712 | int plnum = GetPluginCount(); |
| 1713 | char plstr[10]; |
| 1714 | ke::SafeSprintf(plstr, sizeof(plstr), "%d", plnum); |
| 1715 | int plpadding = strlen(plstr); |
| 1716 | |
| 1717 | if (!plnum) |
| 1718 | { |
| 1719 | rootmenu->ConsolePrint("[SM] No plugins loaded"); |
| 1720 | return; |
| 1721 | } |
| 1722 | else |
| 1723 | { |
| 1724 | rootmenu->ConsolePrint("[SM] Listing %d plugin%s:", plnum, (plnum > 1) ? "s" : ""); |
| 1725 | } |
| 1726 | |
| 1727 | std::list<CPlugin *> fail_list; |
| 1728 | |
| 1729 | for (PluginIter iter(m_plugins); !iter.done(); iter.next(), id++) { |
| 1730 | CPlugin *pl = (*iter); |
| 1731 | assert(pl->GetStatus() != Plugin_Created); |
| 1732 | int len = 0; |
| 1733 | const sm_plugininfo_t *info = pl->GetPublicInfo(); |
| 1734 | if (pl->GetStatus() != Plugin_Running && !pl->IsSilentlyFailed()) |
| 1735 | { |
| 1736 | len += ke::SafeSprintf(buffer, sizeof(buffer), " %0*d <%s>", plpadding, id, GetStatusText(pl->GetDisplayStatus())); |
| 1737 | |
| 1738 | /* Plugin has failed to load. */ |
| 1739 | fail_list.push_back(pl); |
| 1740 | } |
| 1741 | else |
| 1742 | { |
| 1743 | len += ke::SafeSprintf(buffer, sizeof(buffer), " %0*d", plpadding, id); |
| 1744 | } |
| 1745 | if (pl->GetStatus() < Plugin_Created || pl->GetStatus() == Plugin_Evicted) |
| 1746 | { |
| 1747 | if (pl->IsSilentlyFailed()) |
| 1748 | len += ke::SafeStrcpy(&buffer[len], sizeof(buffer)-len, " Disabled:"); |
| 1749 | len += ke::SafeSprintf(&buffer[len], sizeof(buffer)-len, " \"%s\"", (IS_STR_FILLED(info->name)) ? info->name : pl->GetFilename()); |
| 1750 | if (IS_STR_FILLED(info->version)) |
| 1751 | { |
| 1752 | len += ke::SafeSprintf(&buffer[len], sizeof(buffer)-len, " (%s)", info->version); |
| 1753 | } |
| 1754 | if (IS_STR_FILLED(info->author)) |
| 1755 | { |
| 1756 | ke::SafeSprintf(&buffer[len], sizeof(buffer)-len, " by %s", info->author); |
| 1757 | } |
| 1758 | } |
| 1759 | else |
nothing calls this directly
no test coverage detected