Codechange: Remove create parameter from IniLoadFile::GetGroup.

GetGroup now only returns nullptr if the group does not exist.
Use GetOrCreateGroup to create a group.

This avoids creating groups while reading ini files.
This commit is contained in:
Peter Nelson
2023-10-10 19:25:59 +01:00
committed by Peter Nelson
parent c47a0e1578
commit 1fecbeff76
8 changed files with 37 additions and 30 deletions

View File

@@ -133,7 +133,7 @@ bool MusicSet::FillSetDetails(IniFile &ini, const std::string &path, const std::
this->songinfo[i].filename = filename; // non-owned pointer
IniItem *item = catindex->GetItem(_music_file_names[i]);
IniItem *item = catindex != nullptr ? catindex->GetItem(_music_file_names[i]) : nullptr;
if (item != nullptr && item->value.has_value() && !item->value->empty()) {
/* Song has a CAT file index, assume it's MPS MIDI format */
this->songinfo[i].filetype = MTT_MPSMIDI;
@@ -158,7 +158,7 @@ bool MusicSet::FillSetDetails(IniFile &ini, const std::string &path, const std::
* the beginning, so we don't start reading e.g. root. */
while (*trimmed_filename == PATHSEPCHAR) trimmed_filename++;
item = names->GetItem(trimmed_filename);
item = names != nullptr ? names->GetItem(trimmed_filename) : nullptr;
if (item != nullptr && item->value.has_value() && !item->value->empty()) break;
}
@@ -179,7 +179,7 @@ bool MusicSet::FillSetDetails(IniFile &ini, const std::string &path, const std::
this->songinfo[i].tracknr = tracknr++;
}
item = trimmed_filename != nullptr ? timingtrim->GetItem(trimmed_filename) : nullptr;
item = trimmed_filename != nullptr && timingtrim != nullptr ? timingtrim->GetItem(trimmed_filename) : nullptr;
if (item != nullptr && item->value.has_value() && !item->value->empty()) {
auto endpos = item->value->find(':');
if (endpos != std::string::npos) {