diff --git a/core/sm_srvcmds.cpp b/core/sm_srvcmds.cpp index 8148c8f5..6d8f8ed0 100644 --- a/core/sm_srvcmds.cpp +++ b/core/sm_srvcmds.cpp @@ -34,6 +34,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(); @@ -69,12 +70,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); } @@ -102,7 +103,6 @@ CON_COMMAND(sm, "SourceMod Menu") } return; - } else if (!strcmp("unload", cmd2)) { if (argnum < 4) { @@ -110,7 +110,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()) @@ -121,11 +120,11 @@ CON_COMMAND(sm, "SourceMod Menu") IPluginIterator *iter = g_PluginSys.GetPluginIterator(); for (; iter->MorePlugins() && idNextPlugin(), 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)) { @@ -136,7 +135,6 @@ CON_COMMAND(sm, "SourceMod Menu") iter->Release(); return; - } else if (!strcmp("info", cmd2)) { if (argnum < 4) { @@ -144,7 +142,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()) @@ -155,27 +152,28 @@ CON_COMMAND(sm, "SourceMod Menu") IPluginIterator *iter = g_PluginSys.GetPluginIterator(); for (; iter->MorePlugins() && idNextPlugin(), 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); }