Pad plugin ID based on the total plugin count (#1027)

Closes #994
This commit is contained in:
MartLegion 2019-06-16 21:06:03 -03:00 committed by Asher Baker
parent 14227c04b8
commit e47c1a840a

View File

@ -1701,6 +1701,9 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const ICommandArg
char buffer[256]; char buffer[256];
unsigned int id = 1; unsigned int id = 1;
int plnum = GetPluginCount(); int plnum = GetPluginCount();
char plstr[10];
ke::SafeSprintf(plstr, sizeof(plstr), "%d", plnum);
int plpadding = strlen(plstr);
if (!plnum) if (!plnum)
{ {
@ -1709,7 +1712,7 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const ICommandArg
} }
else else
{ {
rootmenu->ConsolePrint("[SM] Listing %d plugin%s:", GetPluginCount(), (plnum > 1) ? "s" : ""); rootmenu->ConsolePrint("[SM] Listing %d plugin%s:", plnum, (plnum > 1) ? "s" : "");
} }
ke::LinkedList<CPlugin *> fail_list; ke::LinkedList<CPlugin *> fail_list;
@ -1721,14 +1724,14 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const ICommandArg
const sm_plugininfo_t *info = pl->GetPublicInfo(); const sm_plugininfo_t *info = pl->GetPublicInfo();
if (pl->GetStatus() != Plugin_Running && !pl->IsSilentlyFailed()) if (pl->GetStatus() != Plugin_Running && !pl->IsSilentlyFailed())
{ {
len += ke::SafeSprintf(buffer, sizeof(buffer), " %02d <%s>", id, GetStatusText(pl->GetDisplayStatus())); len += ke::SafeSprintf(buffer, sizeof(buffer), " %0*d <%s>", plpadding, id, GetStatusText(pl->GetDisplayStatus()));
/* Plugin has failed to load. */ /* Plugin has failed to load. */
fail_list.append(pl); fail_list.append(pl);
} }
else else
{ {
len += ke::SafeSprintf(buffer, sizeof(buffer), " %02d", id); len += ke::SafeSprintf(buffer, sizeof(buffer), " %0*d", plpadding, id);
} }
if (pl->GetStatus() < Plugin_Created || pl->GetStatus() == Plugin_Evicted) if (pl->GetStatus() < Plugin_Created || pl->GetStatus() == Plugin_Evicted)
{ {