mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-12-09 11:28:33 +00:00
Reformatted output of meta list command
--HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40420
This commit is contained in:
parent
e00aa3cbd4
commit
afbd6cc123
@ -302,6 +302,37 @@ CPluginManager::CPlugin *CPluginManager::FindByAPI(ISmmPlugin *api)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CPluginManager::GetPluginCount()
|
||||||
|
{
|
||||||
|
return (int)m_Plugins.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *CPluginManager::GetStatusText(CPlugin *pl)
|
||||||
|
{
|
||||||
|
switch (pl->m_Status)
|
||||||
|
{
|
||||||
|
case Pl_NotFound:
|
||||||
|
return "NOFILE";
|
||||||
|
case Pl_Error:
|
||||||
|
return "ERROR";
|
||||||
|
case Pl_Refused:
|
||||||
|
return "FAILED";
|
||||||
|
case Pl_Paused:
|
||||||
|
return "PAUSED";
|
||||||
|
case Pl_Running:
|
||||||
|
{
|
||||||
|
if (pl->m_API && pl->m_API->QueryRunning(NULL, 0))
|
||||||
|
{
|
||||||
|
return "STOPPED";
|
||||||
|
} else {
|
||||||
|
return "RUNNING";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source, char *error, size_t maxlen)
|
CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source, char *error, size_t maxlen)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|||||||
@ -116,6 +116,9 @@ namespace SourceMM
|
|||||||
*/
|
*/
|
||||||
bool Retry(PluginId id, char *error, size_t len);
|
bool Retry(PluginId id, char *error, size_t len);
|
||||||
|
|
||||||
|
int GetPluginCount();
|
||||||
|
const char *GetStatusText(CPlugin *pl);
|
||||||
|
|
||||||
//get alias info
|
//get alias info
|
||||||
const char *LookupAlias(const char *alias);
|
const char *LookupAlias(const char *alias);
|
||||||
SourceHook::List<SourceMM::CNameAlias *>::iterator _alias_begin();
|
SourceHook::List<SourceMM::CNameAlias *>::iterator _alias_begin();
|
||||||
|
|||||||
@ -10,6 +10,8 @@
|
|||||||
version.
|
version.
|
||||||
- Added OnUnlinkConCommandBase to IMetamodListner to notify when Metamod:Source
|
- Added OnUnlinkConCommandBase to IMetamodListner to notify when Metamod:Source
|
||||||
is about to remove a concommand or convar.
|
is about to remove a concommand or convar.
|
||||||
|
- The output of the "meta list" command has been reformatted in order to allow
|
||||||
|
more space for plugins' name, version, and author fields.
|
||||||
|
|
||||||
2007/06/26 1.4.2:
|
2007/06/26 1.4.2:
|
||||||
- Fixed a bug where unloading all plugins could crash if one plugin had child
|
- Fixed a bug where unloading all plugins could crash if one plugin had child
|
||||||
|
|||||||
@ -15,6 +15,9 @@
|
|||||||
#include "sh_string.h"
|
#include "sh_string.h"
|
||||||
#include "sh_list.h"
|
#include "sh_list.h"
|
||||||
|
|
||||||
|
using namespace SourceMM;
|
||||||
|
using namespace SourceHook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Console Command Implementations
|
* @brief Console Command Implementations
|
||||||
* @file concommands.cpp
|
* @file concommands.cpp
|
||||||
@ -50,7 +53,7 @@ bool SMConVarAccessor::Register(ConCommandBase *pCommand)
|
|||||||
|
|
||||||
void SMConVarAccessor::MarkCommandsAsGameDLL()
|
void SMConVarAccessor::MarkCommandsAsGameDLL()
|
||||||
{
|
{
|
||||||
for (SourceHook::List<ConCommandBase*>::iterator iter = m_RegisteredCommands.begin();
|
for (List<ConCommandBase*>::iterator iter = m_RegisteredCommands.begin();
|
||||||
iter != m_RegisteredCommands.end(); ++iter)
|
iter != m_RegisteredCommands.end(); ++iter)
|
||||||
{
|
{
|
||||||
(*iter)->AddFlags(FCVAR_GAMEDLL);
|
(*iter)->AddFlags(FCVAR_GAMEDLL);
|
||||||
@ -61,8 +64,8 @@ void SMConVarAccessor::Unregister(PluginId id, ConCommandBase *pCommand)
|
|||||||
{
|
{
|
||||||
/* Notify via IMetamodListener */
|
/* Notify via IMetamodListener */
|
||||||
PluginIter iter;
|
PluginIter iter;
|
||||||
SourceMM::CPluginManager::CPlugin *pPlugin;
|
CPluginManager::CPlugin *pPlugin;
|
||||||
SourceHook::List<IMetamodListener *>::iterator event;
|
List<IMetamodListener *>::iterator event;
|
||||||
IMetamodListener *pML;
|
IMetamodListener *pML;
|
||||||
for (iter=g_PluginMngr._begin(); iter!=g_PluginMngr._end(); iter++)
|
for (iter=g_PluginMngr._begin(); iter!=g_PluginMngr._end(); iter++)
|
||||||
{
|
{
|
||||||
@ -217,65 +220,63 @@ CON_COMMAND(meta, "Metamod:Source Menu")
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
} else if (strcmp(command, "list") == 0) {
|
} else if (strcmp(command, "list") == 0) {
|
||||||
SourceMM::CPluginManager::CPlugin *pl;
|
CPluginManager::CPlugin *pl;
|
||||||
|
ISmmPlugin *plapi;
|
||||||
|
const char *plname;
|
||||||
PluginIter i;
|
PluginIter i;
|
||||||
const char *status="";
|
char buffer[256];
|
||||||
const char *version=NULL;
|
int len;
|
||||||
const char *name=NULL;
|
int plnum = g_PluginMngr.GetPluginCount();
|
||||||
const char *author=NULL;
|
|
||||||
|
|
||||||
CONMSG("-Id- %-20.19s %-10.9s %-20.19s %-8.7s\n", "Name", "Version", "Author", "Status");
|
if (!plnum)
|
||||||
for (i=g_PluginMngr._begin(); i!=g_PluginMngr._end(); i++)
|
{
|
||||||
|
CONMSG("No plugins loaded.\n");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
CONMSG("Listing %d plugin%s:\n", plnum, (plnum > 1) ? "s" : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = g_PluginMngr._begin(); i != g_PluginMngr._end(); i++)
|
||||||
{
|
{
|
||||||
pl = (*i);
|
pl = (*i);
|
||||||
if (!pl)
|
if (!pl)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
if (pl->m_Status == Pl_Paused)
|
|
||||||
{
|
|
||||||
status = "PAUSE";
|
|
||||||
} else if (pl->m_Status == Pl_Running) {
|
|
||||||
if (pl->m_API && pl->m_API->QueryRunning(NULL, 0))
|
|
||||||
status = "RUN";
|
|
||||||
else
|
|
||||||
status = "STOPPED";
|
|
||||||
} else if (pl->m_Status == Pl_Refused) {
|
|
||||||
status = "FAIL";
|
|
||||||
} else if (pl->m_Status == Pl_Error) {
|
|
||||||
status = "ERROR";
|
|
||||||
} else if (pl->m_Status == Pl_NotFound) {
|
|
||||||
status = "NOFILE";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pl->m_API)
|
len = 0;
|
||||||
|
|
||||||
|
if (pl->m_Status != Pl_Running)
|
||||||
{
|
{
|
||||||
version = pl->m_API->GetVersion();
|
len += UTIL_Format(buffer, sizeof(buffer), " [%02d] <%s>", pl->m_Id, g_PluginMngr.GetStatusText(pl));
|
||||||
author = pl->m_API->GetAuthor();
|
|
||||||
name = pl->m_API->GetName();
|
|
||||||
} else {
|
} else {
|
||||||
version = "-";
|
len += UTIL_Format(buffer, sizeof(buffer), " [%02d]", pl->m_Id);
|
||||||
author = "-";
|
|
||||||
name = "-";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!version)
|
if ((plapi = pl->m_API))
|
||||||
version = "-";
|
{
|
||||||
if (!author)
|
plname = IS_STR_FILLED(plapi->GetName()) ? plapi->GetName() : pl->m_File.c_str();
|
||||||
author = "-";
|
len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " %s", plname);
|
||||||
if (!name)
|
|
||||||
name = pl->m_File.c_str();
|
|
||||||
|
|
||||||
|
if (IS_STR_FILLED(plapi->GetVersion()))
|
||||||
|
{
|
||||||
|
len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " (%s)", plapi->GetVersion());
|
||||||
|
}
|
||||||
|
if (IS_STR_FILLED(plapi->GetAuthor()))
|
||||||
|
{
|
||||||
|
UTIL_Format(&buffer[len], sizeof(buffer)-len, " by %s", plapi->GetAuthor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CONMSG("[%02d] %-20.19s %-10.9s %-20.19s %-8.7s\n", pl->m_Id, name, version, author, status);
|
CONMSG("%s\n", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
//CONMSG("\n");
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else if (strcmp(command, "cmds") == 0) {
|
} else if (strcmp(command, "cmds") == 0) {
|
||||||
if (args >= 3)
|
if (args >= 3)
|
||||||
{
|
{
|
||||||
int id = atoi(e->Cmd_Argv(2));
|
int id = atoi(e->Cmd_Argv(2));
|
||||||
SourceMM::CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
|
CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
|
||||||
|
|
||||||
if (!pl)
|
if (!pl)
|
||||||
{
|
{
|
||||||
@ -288,7 +289,7 @@ CON_COMMAND(meta, "Metamod:Source Menu")
|
|||||||
CONMSG("Plugin %d is not loaded.\n", id);
|
CONMSG("Plugin %d is not loaded.\n", id);
|
||||||
} else {
|
} else {
|
||||||
CONMSG("Console commands for %s:\n", pl->m_API->GetName());
|
CONMSG("Console commands for %s:\n", pl->m_API->GetName());
|
||||||
SourceHook::List<ConCommandBase *>::iterator ci;
|
List<ConCommandBase *>::iterator ci;
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
|
|
||||||
for (ci=pl->m_Cmds.begin(); ci!=pl->m_Cmds.end(); ci++)
|
for (ci=pl->m_Cmds.begin(); ci!=pl->m_Cmds.end(); ci++)
|
||||||
@ -306,7 +307,7 @@ CON_COMMAND(meta, "Metamod:Source Menu")
|
|||||||
if (args >= 3)
|
if (args >= 3)
|
||||||
{
|
{
|
||||||
int id = atoi(e->Cmd_Argv(2));
|
int id = atoi(e->Cmd_Argv(2));
|
||||||
SourceMM::CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
|
CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
|
||||||
|
|
||||||
if (!pl)
|
if (!pl)
|
||||||
{
|
{
|
||||||
@ -319,7 +320,7 @@ CON_COMMAND(meta, "Metamod:Source Menu")
|
|||||||
CONMSG("Plugin %d is not loaded.\n", id);
|
CONMSG("Plugin %d is not loaded.\n", id);
|
||||||
} else {
|
} else {
|
||||||
CONMSG("Registered cvars for %s:\n", pl->m_API->GetName());
|
CONMSG("Registered cvars for %s:\n", pl->m_API->GetName());
|
||||||
SourceHook::List<ConCommandBase *>::iterator ci;
|
List<ConCommandBase *>::iterator ci;
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
|
|
||||||
for (ci=pl->m_Cvars.begin(); ci!=pl->m_Cvars.end(); ci++)
|
for (ci=pl->m_Cvars.begin(); ci!=pl->m_Cvars.end(); ci++)
|
||||||
@ -337,7 +338,7 @@ CON_COMMAND(meta, "Metamod:Source Menu")
|
|||||||
if (args >= 3)
|
if (args >= 3)
|
||||||
{
|
{
|
||||||
int id = atoi(e->Cmd_Argv(2));
|
int id = atoi(e->Cmd_Argv(2));
|
||||||
SourceMM::CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
|
CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
|
||||||
if (!pl)
|
if (!pl)
|
||||||
{
|
{
|
||||||
CONMSG("Plugin %d not found.\n", id);
|
CONMSG("Plugin %d not found.\n", id);
|
||||||
@ -446,7 +447,7 @@ CON_COMMAND(meta, "Metamod:Source Menu")
|
|||||||
|
|
||||||
char error[255]={0};
|
char error[255]={0};
|
||||||
bool already;
|
bool already;
|
||||||
SourceMM::CPluginManager::CPlugin *pl;
|
CPluginManager::CPlugin *pl;
|
||||||
|
|
||||||
PluginId id = g_PluginMngr.Load(full_path, Pl_Console, already, error, sizeof(error));
|
PluginId id = g_PluginMngr.Load(full_path, Pl_Console, already, error, sizeof(error));
|
||||||
pl = g_PluginMngr.FindById(id);
|
pl = g_PluginMngr.FindById(id);
|
||||||
@ -493,8 +494,8 @@ CON_COMMAND(meta, "Metamod:Source Menu")
|
|||||||
CONMSG("Alias \"%s\" was not found.\n", alias);
|
CONMSG("Alias \"%s\" was not found.\n", alias);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SourceHook::List<SourceMM::CNameAlias *>::iterator iter, end;
|
List<CNameAlias *>::iterator iter, end;
|
||||||
SourceMM::CNameAlias *p;
|
CNameAlias *p;
|
||||||
|
|
||||||
iter = g_PluginMngr._alias_begin();
|
iter = g_PluginMngr._alias_begin();
|
||||||
end = g_PluginMngr._alias_end();
|
end = g_PluginMngr._alias_end();
|
||||||
@ -547,8 +548,8 @@ CON_COMMAND(meta, "Metamod:Source Menu")
|
|||||||
g_SmmAPI.PathFormat(full_path, sizeof(full_path), "%s/%s%s", g_ModPath.c_str(), file, ext);
|
g_SmmAPI.PathFormat(full_path, sizeof(full_path), "%s/%s%s", g_ModPath.c_str(), file, ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceHook::List<SourceMM::CPluginManager::CPlugin *>::iterator iter, end;
|
List<CPluginManager::CPlugin *>::iterator iter, end;
|
||||||
SourceMM::CPluginManager::CPlugin *pl;
|
CPluginManager::CPlugin *pl;
|
||||||
iter = g_PluginMngr._begin();
|
iter = g_PluginMngr._begin();
|
||||||
end = g_PluginMngr._end();
|
end = g_PluginMngr._end();
|
||||||
for (; iter!=end; iter++)
|
for (; iter!=end; iter++)
|
||||||
@ -729,45 +730,49 @@ void ClientCommand_handler(edict_t *client)
|
|||||||
|
|
||||||
RETURN_META(MRES_SUPERCEDE);
|
RETURN_META(MRES_SUPERCEDE);
|
||||||
} else if(strcmp(subcmd, "list") == 0) {
|
} else if(strcmp(subcmd, "list") == 0) {
|
||||||
SourceMM::CPluginManager::CPlugin *pl;
|
CPluginManager::CPlugin *pl;
|
||||||
Pl_Status st;
|
ISmmPlugin *plapi;
|
||||||
|
const char *plname;
|
||||||
PluginIter i;
|
PluginIter i;
|
||||||
const char *version = NULL;
|
char buffer[256];
|
||||||
const char *name = NULL;
|
int len = 0;
|
||||||
const char *author = NULL;
|
int plnum = 0;
|
||||||
const char *status = NULL;
|
|
||||||
|
|
||||||
CLIENT_CONMSG(client, "-Id- %-20.19s %-10.9s %-20.19s %6s\n", "Name", "Version", "Author", "Status");
|
for (i = g_PluginMngr._begin(); i != g_PluginMngr._end(); i++, len=0)
|
||||||
|
|
||||||
for (i=g_PluginMngr._begin(); i!=g_PluginMngr._end(); i++)
|
|
||||||
{
|
{
|
||||||
pl = (*i);
|
pl = (*i);
|
||||||
if (!pl)
|
if (pl && pl->m_Status == Pl_Running)
|
||||||
break;
|
|
||||||
|
|
||||||
st = pl->m_Status;
|
|
||||||
|
|
||||||
/* Only show plugins that are running or paused */
|
|
||||||
if (pl->m_API && (st == Pl_Running || st == Pl_Paused))
|
|
||||||
{
|
{
|
||||||
version = pl->m_API->GetVersion();
|
plapi = pl->m_API;
|
||||||
author = pl->m_API->GetAuthor();
|
if (!plapi || !plapi->QueryRunning(NULL, 0))
|
||||||
name = pl->m_API->GetName();
|
|
||||||
|
|
||||||
if (st == Pl_Running && pl->m_API->QueryRunning(NULL, 0))
|
|
||||||
{
|
{
|
||||||
status = "RUN";
|
continue;
|
||||||
} else {
|
}
|
||||||
status = "PAUSE";
|
plnum++;
|
||||||
|
|
||||||
|
len += UTIL_Format(buffer, sizeof(buffer), " [%02d]", plnum);
|
||||||
|
|
||||||
|
plname = IS_STR_FILLED(plapi->GetName()) ? plapi->GetName() : pl->m_File.c_str();
|
||||||
|
len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " %s", plname);
|
||||||
|
|
||||||
|
if (IS_STR_FILLED(plapi->GetVersion()))
|
||||||
|
{
|
||||||
|
len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " (%s)", plapi->GetVersion());
|
||||||
|
}
|
||||||
|
if (IS_STR_FILLED(plapi->GetAuthor()))
|
||||||
|
{
|
||||||
|
UTIL_Format(&buffer[len], sizeof(buffer)-len, " by %s", plapi->GetAuthor());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!version || !author || !name)
|
CLIENT_CONMSG(client, "%s\n", buffer);
|
||||||
break;
|
|
||||||
|
|
||||||
CLIENT_CONMSG(client, "[%02d] %-20.19s %-10.9s %-20.19s %6s\n", pl->m_Id, name, version, author, status);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!plnum)
|
||||||
|
{
|
||||||
|
CLIENT_CONMSG(client, "No active plugins loaded.\n");
|
||||||
|
}
|
||||||
|
|
||||||
RETURN_META(MRES_SUPERCEDE);
|
RETURN_META(MRES_SUPERCEDE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,11 @@
|
|||||||
* @file util.h
|
* @file util.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns true is string is not blank, false otherwise.
|
||||||
|
*/
|
||||||
|
#define IS_STR_FILLED(var) (var != NULL && var[0] != '\0')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns a pointer to the extension in a file name.
|
* @brief Returns a pointer to the extension in a file name.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user