mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 07:23:51 +00:00
Merge pull request #2743 from Capostrophic/formatting
Improve blank line handling in settings writer (bug #5326)
This commit is contained in:
commit
79e7155f50
2 changed files with 32 additions and 11 deletions
|
@ -207,6 +207,7 @@
|
|||
Bug #5300: NPCs don't switch from torch to shield when starting combat
|
||||
Bug #5308: World map copying makes save loading much slower
|
||||
Bug #5313: Node properties of identical type are not applied in the correct order
|
||||
Bug #5326: Formatting issues in the settings.cfg
|
||||
Bug #5328: Skills aren't properly reset for dead actors
|
||||
Feature #1774: Handle AvoidNode
|
||||
Feature #2229: Improve pathfinding AI
|
||||
|
|
|
@ -77,6 +77,9 @@ void Settings::SettingsFileParser::saveSettingsFile(const std::string& file, con
|
|||
// Were there any lines at all in the file?
|
||||
bool existing = false;
|
||||
|
||||
// Is an entirely blank line queued to be added?
|
||||
bool emptyLineQueued = false;
|
||||
|
||||
// The category/section we're currently in.
|
||||
std::string currentCategory;
|
||||
|
||||
|
@ -103,9 +106,19 @@ void Settings::SettingsFileParser::saveSettingsFile(const std::string& file, con
|
|||
// Don't add additional newlines at the end of the file.
|
||||
if (istream.eof()) continue;
|
||||
|
||||
// Copy entirely blank lines.
|
||||
if (!skipWhiteSpace(i, line)) {
|
||||
ostream << line << std::endl;
|
||||
// An empty line was queued.
|
||||
if (emptyLineQueued)
|
||||
{
|
||||
emptyLineQueued = false;
|
||||
// We're still going through the current category, so we should copy it.
|
||||
if (currentCategory.empty() || line[i] != '[')
|
||||
ostream << std::endl;
|
||||
}
|
||||
|
||||
// Queue entirely blank lines to add them if desired.
|
||||
if (!skipWhiteSpace(i, line))
|
||||
{
|
||||
emptyLineQueued = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -128,9 +141,13 @@ void Settings::SettingsFileParser::saveSettingsFile(const std::string& file, con
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!currentCategory.empty())
|
||||
{
|
||||
// Ensure that all options in the current category have been written.
|
||||
for (CategorySettingStatusMap::iterator mit = written.begin(); mit != written.end(); ++mit) {
|
||||
if (mit->second == false && mit->first.first == currentCategory) {
|
||||
for (CategorySettingStatusMap::iterator mit = written.begin(); mit != written.end(); ++mit)
|
||||
{
|
||||
if (mit->second == false && mit->first.first == currentCategory)
|
||||
{
|
||||
Log(Debug::Verbose) << "Added new setting: [" << currentCategory << "] "
|
||||
<< mit->first.second << " = " << settings.at(mit->first);
|
||||
ostream << mit->first.second << " = " << settings.at(mit->first) << std::endl;
|
||||
|
@ -138,6 +155,9 @@ void Settings::SettingsFileParser::saveSettingsFile(const std::string& file, con
|
|||
changed = true;
|
||||
}
|
||||
}
|
||||
// Add an empty line after the last option in a category.
|
||||
ostream << std::endl;
|
||||
}
|
||||
|
||||
// Update the current category.
|
||||
currentCategory = line.substr(i+1, end - (i+1));
|
||||
|
|
Loading…
Reference in a new issue