Skip to content

Commit

Permalink
cleanup concommand descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Poggicek committed Oct 4, 2024
1 parent 73033cb commit ecbd5b6
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/main/dumpers/concommands/concommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,24 @@ void WriteValueLine(ConVar* pCvar, std::ofstream& stream)
}
}

void FixNewlineTabbing(std::string& str)
{
auto it = str.begin();
while ((it = std::find(it, str.end(), '\n')) != str.end()) {
if (it + 1 == str.end() || *(it + 1) != '\t')
it = str.insert(it + 1, '\t') + 1;
else
it++;
}

// trim end of string
if (str.back() == '\t')
str.pop_back();

if (str.back() == '\n')
str.pop_back();
}

void DumpConVars()
{
ConVarHandle hCvarHandle;
Expand Down Expand Up @@ -239,9 +257,16 @@ void DumpConVars()

for (const auto cvar : convars)
{
std::string helpString = "<no description>";
if (cvar->m_pszHelpString[0])
{
helpString = cvar->m_pszHelpString;
FixNewlineTabbing(helpString);
}

output << cvar->m_pszName;
WriteValueLine(cvar, output);
output << "\n\t" << (cvar->m_pszHelpString[0] ? cvar->m_pszHelpString : "<no description>");
output << "\n\t" << helpString;

output << "\n" << std::endl;
}
Expand Down Expand Up @@ -279,9 +304,16 @@ void DumpCommands()

for (const auto command : commands)
{
std::string helpString = "<no description>";
if (command->m_pszHelpString[0])
{
helpString = command->m_pszHelpString;
FixNewlineTabbing(helpString);
}

output << command->m_pszName << " (";
WriteFlags(command->m_nFlags, output);
output << ")\n\t" << (command->m_pszHelpString[0] ? command->m_pszHelpString : "<no description>");
output << ")\n\t" << helpString;

output << "\n" << std::endl;
}
Expand Down

0 comments on commit ecbd5b6

Please sign in to comment.