fixed null string condition being always true
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40226
This commit is contained in:
parent
522a1f605f
commit
1e573fe0d0
@ -33,6 +33,7 @@ inline const char *StatusToStr(PluginStatus st)
|
||||
}
|
||||
}
|
||||
|
||||
#define IS_STR_FILLED(var) (var[0] != '\0')
|
||||
CON_COMMAND(sm, "SourceMod Menu")
|
||||
{
|
||||
int argnum = engine->Cmd_Argc();
|
||||
@ -68,12 +69,12 @@ CON_COMMAND(sm, "SourceMod Menu")
|
||||
const sm_plugininfo_t *info = pl->GetPublicInfo();
|
||||
|
||||
len += snprintf(&buffer[len], sizeof(buffer)-len, " %02d <%s>", id, StatusToStr(pl->GetStatus()));
|
||||
len += snprintf(&buffer[len], sizeof(buffer)-len, " \"%s\"", (info->name) ? info->name : iter->GetPlugin()->GetFilename());
|
||||
if (info->version)
|
||||
len += snprintf(&buffer[len], sizeof(buffer)-len, " \"%s\"", (IS_STR_FILLED(info->name)) ? info->name : pl->GetFilename());
|
||||
if (IS_STR_FILLED(info->version))
|
||||
{
|
||||
len += snprintf(&buffer[len], sizeof(buffer)-len, " (%s)", info->version);
|
||||
}
|
||||
if (info->author)
|
||||
if (IS_STR_FILLED(info->author))
|
||||
{
|
||||
snprintf(&buffer[len], sizeof(buffer)-len, " by %s", info->author);
|
||||
}
|
||||
@ -101,7 +102,6 @@ CON_COMMAND(sm, "SourceMod Menu")
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
} else if (!strcmp("unload", cmd2)) {
|
||||
if (argnum < 4)
|
||||
{
|
||||
@ -109,7 +109,6 @@ CON_COMMAND(sm, "SourceMod Menu")
|
||||
return;
|
||||
}
|
||||
|
||||
IPlugin *pl = NULL;
|
||||
int id = 1;
|
||||
int num = atoi(engine->Cmd_Argv(3));
|
||||
if (num < 1 || num > (int)g_PluginSys.GetPluginCount())
|
||||
@ -120,11 +119,11 @@ CON_COMMAND(sm, "SourceMod Menu")
|
||||
|
||||
IPluginIterator *iter = g_PluginSys.GetPluginIterator();
|
||||
for (; iter->MorePlugins() && id<num; iter->NextPlugin(), id++) {}
|
||||
pl = iter->GetPlugin();
|
||||
IPlugin *pl = iter->GetPlugin();
|
||||
|
||||
char name[64];
|
||||
const sm_plugininfo_t *info = pl->GetPublicInfo();
|
||||
strcpy(name, (info->name) ? info->name : pl->GetFilename());
|
||||
strcpy(name, (IS_STR_FILLED(info->name)) ? info->name : pl->GetFilename());
|
||||
|
||||
if (g_PluginSys.UnloadPlugin(pl))
|
||||
{
|
||||
@ -135,7 +134,6 @@ CON_COMMAND(sm, "SourceMod Menu")
|
||||
|
||||
iter->Release();
|
||||
return;
|
||||
|
||||
} else if (!strcmp("info", cmd2)) {
|
||||
if (argnum < 4)
|
||||
{
|
||||
@ -143,7 +141,6 @@ CON_COMMAND(sm, "SourceMod Menu")
|
||||
return;
|
||||
}
|
||||
|
||||
IPlugin *pl = NULL;
|
||||
int id = 1;
|
||||
int num = atoi(engine->Cmd_Argv(3));
|
||||
if (num < 1 || num > (int)g_PluginSys.GetPluginCount())
|
||||
@ -154,27 +151,28 @@ CON_COMMAND(sm, "SourceMod Menu")
|
||||
|
||||
IPluginIterator *iter = g_PluginSys.GetPluginIterator();
|
||||
for (; iter->MorePlugins() && id<num; iter->NextPlugin(), id++) {}
|
||||
pl = iter->GetPlugin();
|
||||
|
||||
IPlugin *pl = iter->GetPlugin();
|
||||
const sm_plugininfo_t *info = pl->GetPublicInfo();
|
||||
|
||||
META_CONPRINTF(" Filename: %s\n", pl->GetFilename());
|
||||
if (info->name)
|
||||
if (IS_STR_FILLED(info->name))
|
||||
{
|
||||
META_CONPRINTF(" Title: %s\n", info->name);
|
||||
}
|
||||
if (info->author)
|
||||
if (IS_STR_FILLED(info->author))
|
||||
{
|
||||
META_CONPRINTF(" Author: %s\n", info->author);
|
||||
}
|
||||
if (info->version)
|
||||
if (IS_STR_FILLED(info->version))
|
||||
{
|
||||
META_CONPRINTF(" Version: %s\n", info->version);
|
||||
}
|
||||
if (info->description)
|
||||
if (IS_STR_FILLED(info->description))
|
||||
{
|
||||
META_CONPRINTF(" Description: %s\n", info->description);
|
||||
}
|
||||
if (info->url)
|
||||
if (IS_STR_FILLED(info->url))
|
||||
{
|
||||
META_CONPRINTF(" URL: %s\n", info->url);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user