summaryrefslogtreecommitdiff
path: root/src/music.cpp
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2020-05-17 23:32:03 +0200
committerMichael Lutz <michi@icosahedron.de>2020-05-21 20:02:34 +0200
commit715aa67a9c13444ee76e717bfa656472f5fb2ac3 (patch)
tree3a9cd303082ced0bceb6246edc02102a28fcc3fd /src/music.cpp
parent8aef14386fc403ee631f176abf0ec86af7dcd37b (diff)
downloadopenttd-715aa67a9c13444ee76e717bfa656472f5fb2ac3.tar.xz
Codechange: Use std::string in INI file parsing.
Diffstat (limited to 'src/music.cpp')
-rw-r--r--src/music.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/music.cpp b/src/music.cpp
index a95a9d348..131651e55 100644
--- a/src/music.cpp
+++ b/src/music.cpp
@@ -135,10 +135,10 @@ bool MusicSet::FillSetDetails(IniFile *ini, const char *path, const char *full_f
this->songinfo[i].filename = filename; // non-owned pointer
IniItem *item = catindex->GetItem(_music_file_names[i], false);
- if (item != nullptr && !StrEmpty(item->value)) {
+ 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;
- this->songinfo[i].cat_index = atoi(item->value);
+ this->songinfo[i].cat_index = atoi(item->value->c_str());
char *songname = GetMusicCatEntryName(filename, this->songinfo[i].cat_index);
if (songname == nullptr) {
DEBUG(grf, 0, "Base music set song missing from CAT file: %s/%d", filename, this->songinfo[i].cat_index);
@@ -161,12 +161,12 @@ bool MusicSet::FillSetDetails(IniFile *ini, const char *path, const char *full_f
while (*trimmed_filename == PATHSEPCHAR) trimmed_filename++;
item = names->GetItem(trimmed_filename, false);
- if (item != nullptr && !StrEmpty(item->value)) break;
+ if (item != nullptr && item->value.has_value() && !item->value->empty()) break;
}
if (this->songinfo[i].filetype == MTT_STANDARDMIDI) {
- if (item != nullptr && !StrEmpty(item->value)) {
- strecpy(this->songinfo[i].songname, item->value, lastof(this->songinfo[i].songname));
+ if (item != nullptr && item->value.has_value() && !item->value->empty()) {
+ strecpy(this->songinfo[i].songname, item->value->c_str(), lastof(this->songinfo[i].songname));
} else {
DEBUG(grf, 0, "Base music set song name missing: %s", filename);
return false;
@@ -181,12 +181,12 @@ bool MusicSet::FillSetDetails(IniFile *ini, const char *path, const char *full_f
this->songinfo[i].tracknr = tracknr++;
}
- item = timingtrim->GetItem(trimmed_filename, false);
- if (item != nullptr && !StrEmpty(item->value)) {
- const char *endpos = strchr(item->value, ':');
- if (endpos != nullptr) {
- this->songinfo[i].override_start = atoi(item->value);
- this->songinfo[i].override_end = atoi(endpos + 1);
+ item = trimmed_filename != nullptr ? timingtrim->GetItem(trimmed_filename, false) : nullptr;
+ if (item != nullptr && item->value.has_value() && !item->value->empty()) {
+ auto endpos = item->value->find(':');
+ if (endpos != std::string::npos) {
+ this->songinfo[i].override_start = atoi(item->value->c_str());
+ this->songinfo[i].override_end = atoi(item->value->c_str() + endpos + 1);
}
}
}