2
0
mirror of https://github.com/rehlds/metamod-r.git synced 2024-12-27 23:25:36 +03:00

Reworked MPluginList::getWidthFields

Fix typo in MPlugin::str_action
This commit is contained in:
s1lent 2017-11-18 21:25:25 +07:00
parent c0155f8f1d
commit e343dfe905
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
2 changed files with 10 additions and 23 deletions

View File

@ -579,6 +579,11 @@ void MPluginList::retry_all(PLUG_LOADTIME now)
void MPluginList::getWidthFields(int source_index, size_t &widthDescBest, size_t &widthFileBest, size_t &widthVersBest) void MPluginList::getWidthFields(int source_index, size_t &widthDescBest, size_t &widthFileBest, size_t &widthVersBest)
{ {
// width by default
widthDescBest = sizeof("description") - 1;
widthFileBest = sizeof("file") - 1;
widthVersBest = sizeof("vers") - 1;
for (auto p : m_plugins) for (auto p : m_plugins)
{ {
if (p->m_status < PL_VALID) if (p->m_status < PL_VALID)
@ -587,27 +592,9 @@ void MPluginList::getWidthFields(int source_index, size_t &widthDescBest, size_t
if (source_index > 0 && p->m_source_plugin_index != source_index) if (source_index > 0 && p->m_source_plugin_index != source_index)
continue; continue;
size_t nDescLen = Q_strlen(p->m_desc); widthDescBest = Q_max(widthDescBest, Q_strlen(p->m_desc));
if (widthDescBest < nDescLen) { widthFileBest = Q_max(widthFileBest, Q_strlen(p->m_file));
widthDescBest = nDescLen; widthVersBest = Q_max(widthVersBest, (p->info() && p->info()->version) ? Q_strlen(p->info()->version) : sizeof(" -") - 1);
}
size_t nFileLen = Q_strlen(p->m_file);
if (widthFileBest < nFileLen) {
widthFileBest = nFileLen;
}
size_t nVersLen;
if (p->info() && p->info()->version) {
nVersLen = Q_strlen(p->info()->version);
}
else {
nVersLen = sizeof(" -") - 1;
}
if (widthVersBest < nVersLen) {
widthVersBest = nVersLen;
}
} }
} }
@ -619,7 +606,7 @@ void MPluginList::show(int source_index)
else else
META_CONS("Child plugins:"); META_CONS("Child plugins:");
size_t nWidthDesc = 0, nWidthFile = 0, nWidthVers = 0; size_t nWidthDesc, nWidthFile, nWidthVers;
getWidthFields(source_index, nWidthDesc, nWidthFile, nWidthVers); getWidthFields(source_index, nWidthDesc, nWidthFile, nWidthVers);
char *desc = new char[nWidthDesc + 1]; // + 1 for term null char *desc = new char[nWidthDesc + 1]; // + 1 for term null

View File

@ -1155,7 +1155,7 @@ const char *MPlugin::str_status(STR_STATUS fmt) const
// SHOW is max 4 chars, for "show" output. // SHOW is max 4 chars, for "show" output.
const char *MPlugin::str_action(STR_ACTION fmt) const const char *MPlugin::str_action(STR_ACTION fmt) const
{ {
bool show = fmt == ST_SHOW; bool show = fmt == SA_SHOW;
switch (m_action) { switch (m_action) {
case PA_NULL: return "null"; case PA_NULL: return "null";
case PA_NONE: return show ? " - " : "none"; case PA_NONE: return show ? " - " : "none";