Implemented amb506 - plugin file name can now be used with "sm plugins unload"
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401258
This commit is contained in:
parent
5a979b9090
commit
005f49947a
@ -2002,22 +2002,34 @@ void CPluginManager::OnRootConsoleCommand(const char *command, unsigned int argc
|
|||||||
} else if (strcmp(cmd, "unload") == 0) {
|
} else if (strcmp(cmd, "unload") == 0) {
|
||||||
if (argcount < 4)
|
if (argcount < 4)
|
||||||
{
|
{
|
||||||
g_RootMenu.ConsolePrint("[SM] Usage: sm plugins unload <#>");
|
g_RootMenu.ConsolePrint("[SM] Usage: sm plugins unload <#|file>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = 1;
|
CPlugin *pl;
|
||||||
int num = atoi(g_RootMenu.GetArgument(3));
|
char *end;
|
||||||
if (num < 1 || num > (int)GetPluginCount())
|
const char *arg = g_RootMenu.GetArgument(3);
|
||||||
|
int id = strtol(arg, &end, 10);
|
||||||
|
|
||||||
|
if (*end == '\0')
|
||||||
{
|
{
|
||||||
g_RootMenu.ConsolePrint("[SM] Plugin index %d not found.", num);
|
pl = GetPluginByOrder(id);
|
||||||
return;
|
if (!pl)
|
||||||
}
|
{
|
||||||
|
g_RootMenu.ConsolePrint("[SM] Plugin index %d not found.", id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
char pluginfile[256];
|
||||||
|
const char *ext = g_LibSys.GetFileExtension(arg) ? "" : ".smx";
|
||||||
|
UTIL_Format(pluginfile, sizeof(pluginfile), "%s%s", arg, ext);
|
||||||
|
|
||||||
IPluginIterator *iter = GetPluginIterator();
|
if (!sm_trie_retrieve(m_LoadLookup, pluginfile, (void **)&pl))
|
||||||
for (; iter->MorePlugins() && id<num; iter->NextPlugin(), id++)
|
{
|
||||||
;
|
g_RootMenu.ConsolePrint("[SM] Plugin %s is not loaded.", pluginfile);
|
||||||
IPlugin *pl = iter->GetPlugin();
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char name[PLATFORM_MAX_PATH];
|
char name[PLATFORM_MAX_PATH];
|
||||||
const sm_plugininfo_t *info = pl->GetPublicInfo();
|
const sm_plugininfo_t *info = pl->GetPublicInfo();
|
||||||
@ -2030,7 +2042,6 @@ void CPluginManager::OnRootConsoleCommand(const char *command, unsigned int argc
|
|||||||
g_RootMenu.ConsolePrint("[SM] Failed to unload plugin %s.", name);
|
g_RootMenu.ConsolePrint("[SM] Failed to unload plugin %s.", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
iter->Release();
|
|
||||||
return;
|
return;
|
||||||
} else if (strcmp(cmd, "info") == 0) {
|
} else if (strcmp(cmd, "info") == 0) {
|
||||||
if (argcount < 4)
|
if (argcount < 4)
|
||||||
|
Loading…
Reference in New Issue
Block a user