1.1 --- a/core/systems/PluginSys.cpp Sat Mar 01 05:18:26 2008 +0000
1.2 +++ b/core/systems/PluginSys.cpp Sat Mar 01 05:42:25 2008 +0000
1.3 @@ -2305,14 +2305,33 @@
1.4 return;
1.5 }
1.6
1.7 - int num = atoi(command.Arg(3));
1.8 - if (num < 1 || num > (int)GetPluginCount())
1.9 + CPlugin *pl;
1.10 + char *end;
1.11 + const char *arg = command.Arg(3);
1.12 + int id = strtol(arg, &end, 10);
1.13 +
1.14 + if (*end == '\0')
1.15 {
1.16 - g_RootMenu.ConsolePrint("[SM] Plugin index not found.");
1.17 - return;
1.18 + pl = GetPluginByOrder(id);
1.19 + if (!pl)
1.20 + {
1.21 + g_RootMenu.ConsolePrint("[SM] Plugin index %d not found.", id);
1.22 + return;
1.23 + }
1.24 + }
1.25 + else
1.26 + {
1.27 + char pluginfile[256];
1.28 + const char *ext = g_LibSys.GetFileExtension(arg) ? "" : ".smx";
1.29 + UTIL_Format(pluginfile, sizeof(pluginfile), "%s%s", arg, ext);
1.30 +
1.31 + if (!sm_trie_retrieve(m_LoadLookup, pluginfile, (void **)&pl))
1.32 + {
1.33 + g_RootMenu.ConsolePrint("[SM] Plugin %s is not loaded.", pluginfile);
1.34 + return;
1.35 + }
1.36 }
1.37
1.38 - CPlugin *pl = GetPluginByOrder(num);
1.39 const sm_plugininfo_t *info = pl->GetPublicInfo();
1.40
1.41 g_RootMenu.ConsolePrint(" Filename: %s", pl->GetFilename());
1.42 @@ -2388,11 +2407,31 @@
1.43 return;
1.44 }
1.45
1.46 - int num = atoi(command.Arg(3));
1.47 - if (num < 1 || num > (int)GetPluginCount())
1.48 + CPlugin *pl;
1.49 + char *end;
1.50 + const char *arg = command.Arg(3);
1.51 + int id = strtol(arg, &end, 10);
1.52 +
1.53 + if (*end == '\0')
1.54 {
1.55 - g_RootMenu.ConsolePrint("[SM] Plugin index not found.");
1.56 - return;
1.57 + pl = GetPluginByOrder(id);
1.58 + if (!pl)
1.59 + {
1.60 + g_RootMenu.ConsolePrint("[SM] Plugin index %d not found.", id);
1.61 + return;
1.62 + }
1.63 + }
1.64 + else
1.65 + {
1.66 + char pluginfile[256];
1.67 + const char *ext = g_LibSys.GetFileExtension(arg) ? "" : ".smx";
1.68 + UTIL_Format(pluginfile, sizeof(pluginfile), "%s%s", arg, ext);
1.69 +
1.70 + if (!sm_trie_retrieve(m_LoadLookup, pluginfile, (void **)&pl))
1.71 + {
1.72 + g_RootMenu.ConsolePrint("[SM] Plugin %s is not loaded.", pluginfile);
1.73 + return;
1.74 + }
1.75 }
1.76
1.77 int res;
1.78 @@ -2413,7 +2452,6 @@
1.79 debug = false;
1.80 }
1.81
1.82 - CPlugin *pl = GetPluginByOrder(num);
1.83 if (debug && pl->IsDebugging())
1.84 {
1.85 g_RootMenu.ConsolePrint("[SM] This plugin is already in debug mode.");
1.86 @@ -2807,3 +2845,33 @@
1.87 return -1;
1.88 }
1.89
1.90 +CPlugin *CPluginManager::FindPluginByConsoleArg(const char *arg)
1.91 +{
1.92 + int id;
1.93 + char *end;
1.94 + CPlugin *pl;
1.95 +
1.96 + id = strtol(arg, &end, 10);
1.97 +
1.98 + if (*end == '\0')
1.99 + {
1.100 + pl = GetPluginByOrder(id);
1.101 + if (!pl)
1.102 + {
1.103 + return NULL;
1.104 + }
1.105 + }
1.106 + else
1.107 + {
1.108 + char pluginfile[256];
1.109 + const char *ext = g_LibSys.GetFileExtension(arg) ? "" : ".smx";
1.110 + UTIL_Format(pluginfile, sizeof(pluginfile), "%s%s", arg, ext);
1.111 +
1.112 + if (!sm_trie_retrieve(m_LoadLookup, pluginfile, (void **)&pl))
1.113 + {
1.114 + return NULL;
1.115 + }
1.116 + }
1.117 +
1.118 + return pl;
1.119 +}