diff -r e9116270cf6a -r ce912ad912a5 core/systems/PluginSys.cpp --- a/core/systems/PluginSys.cpp Sat Mar 01 05:18:26 2008 +0000 +++ b/core/systems/PluginSys.cpp Sat Mar 01 05:42:25 2008 +0000 @@ -2305,14 +2305,33 @@ return; } - int num = atoi(command.Arg(3)); - if (num < 1 || num > (int)GetPluginCount()) + CPlugin *pl; + char *end; + const char *arg = command.Arg(3); + int id = strtol(arg, &end, 10); + + if (*end == '\0') { - g_RootMenu.ConsolePrint("[SM] Plugin index not found."); - return; + pl = GetPluginByOrder(id); + 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); + + if (!sm_trie_retrieve(m_LoadLookup, pluginfile, (void **)&pl)) + { + g_RootMenu.ConsolePrint("[SM] Plugin %s is not loaded.", pluginfile); + return; + } } - CPlugin *pl = GetPluginByOrder(num); const sm_plugininfo_t *info = pl->GetPublicInfo(); g_RootMenu.ConsolePrint(" Filename: %s", pl->GetFilename()); @@ -2388,11 +2407,31 @@ return; } - int num = atoi(command.Arg(3)); - if (num < 1 || num > (int)GetPluginCount()) + CPlugin *pl; + char *end; + const char *arg = command.Arg(3); + int id = strtol(arg, &end, 10); + + if (*end == '\0') { - g_RootMenu.ConsolePrint("[SM] Plugin index not found."); - return; + pl = GetPluginByOrder(id); + 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); + + if (!sm_trie_retrieve(m_LoadLookup, pluginfile, (void **)&pl)) + { + g_RootMenu.ConsolePrint("[SM] Plugin %s is not loaded.", pluginfile); + return; + } } int res; @@ -2413,7 +2452,6 @@ debug = false; } - CPlugin *pl = GetPluginByOrder(num); if (debug && pl->IsDebugging()) { g_RootMenu.ConsolePrint("[SM] This plugin is already in debug mode."); @@ -2807,3 +2845,33 @@ return -1; } +CPlugin *CPluginManager::FindPluginByConsoleArg(const char *arg) +{ + int id; + char *end; + CPlugin *pl; + + id = strtol(arg, &end, 10); + + if (*end == '\0') + { + pl = GetPluginByOrder(id); + if (!pl) + { + return NULL; + } + } + else + { + char pluginfile[256]; + const char *ext = g_LibSys.GetFileExtension(arg) ? "" : ".smx"; + UTIL_Format(pluginfile, sizeof(pluginfile), "%s%s", arg, ext); + + if (!sm_trie_retrieve(m_LoadLookup, pluginfile, (void **)&pl)) + { + return NULL; + } + } + + return pl; +}