Skip to content

Commit

Permalink
Pad plugin ID based on the total plugin count (#1027)
Browse files Browse the repository at this point in the history
Closes #994
  • Loading branch information
Mart-User authored and asherkin committed Jun 17, 2019
1 parent 14227c0 commit e47c1a8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions core/logic/PluginSys.cpp
Expand Up @@ -1701,6 +1701,9 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const ICommandArg
char buffer[256];
unsigned int id = 1;
int plnum = GetPluginCount();
char plstr[10];
ke::SafeSprintf(plstr, sizeof(plstr), "%d", plnum);
int plpadding = strlen(plstr);

if (!plnum)
{
Expand All @@ -1709,7 +1712,7 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const ICommandArg
}
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;
Expand All @@ -1721,14 +1724,14 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const ICommandArg
const sm_plugininfo_t *info = pl->GetPublicInfo();
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. */
fail_list.append(pl);
}
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)
{
Expand Down Expand Up @@ -1958,11 +1961,11 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const ICommandArg
if (IPluginRuntime *runtime = pl->GetRuntime()) {
unsigned char *pCodeHash = runtime->GetCodeHash();
unsigned char *pDataHash = runtime->GetDataHash();

char combinedHash[33];
for (int i = 0; i < 16; i++)
ke::SafeSprintf(combinedHash + (i * 2), 3, "%02x", pCodeHash[i] ^ pDataHash[i]);

rootmenu->ConsolePrint(" Hash: %s", combinedHash);
}
} else {
Expand Down Expand Up @@ -2090,7 +2093,7 @@ void CPluginManager::ReloadPluginImpl(int id, const char filename[], PluginType
char error[128];
bool wasloaded;
IPlugin *newpl = LoadPlugin(filename, true, ptype, error, sizeof(error), &wasloaded);
if (!newpl)
if (!newpl)
{
rootmenu->ConsolePrint("[SM] Plugin %s failed to reload: %s.", filename, error);
return;
Expand Down

0 comments on commit e47c1a8

Please sign in to comment.