summaryrefslogtreecommitdiff
path: root/src/music.cpp
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2018-03-04 23:34:02 +0100
committerMichael Lutz <michi@icosahedron.de>2018-06-15 23:09:17 +0200
commit276192f714d6816088791435c1b70dfa7122cdbd (patch)
tree98ca1f899d2769c7538333617ee01db1bd2c68b7 /src/music.cpp
parent836d25e738b78d1c8820ecab1f7bd90b0833ca17 (diff)
downloadopenttd-276192f714d6816088791435c1b70dfa7122cdbd.tar.xz
Change #6684: Cutting point overrides for music base sets
This improves bad looping of title screen song from Windows TTD, and fixes a long silence at the end of "Can't get there from here" from Windows TTD.
Diffstat (limited to 'src/music.cpp')
-rw-r--r--src/music.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/music.cpp b/src/music.cpp
index e131c0210..65e35f955 100644
--- a/src/music.cpp
+++ b/src/music.cpp
@@ -125,6 +125,7 @@ bool MusicSet::FillSetDetails(IniFile *ini, const char *path, const char *full_f
this->num_available = 0;
IniGroup *names = ini->GetGroup("names");
IniGroup *catindex = ini->GetGroup("catindex");
+ IniGroup *timingtrim = ini->GetGroup("timingtrim");
for (uint i = 0, j = 1; i < lengthof(this->songinfo); i++) {
const char *filename = this->files[i].filename;
if (names == NULL || StrEmpty(filename)) {
@@ -150,15 +151,16 @@ bool MusicSet::FillSetDetails(IniFile *ini, const char *path, const char *full_f
this->songinfo[i].filetype = MTT_STANDARDMIDI;
}
+ const char *trimmed_filename = filename;
/* As we possibly add a path to the filename and we compare
* on the filename with the path as in the .obm, we need to
* keep stripping path elements until we find a match. */
- for (const char *p = filename; p != NULL; p = strchr(p, PATHSEPCHAR)) {
+ for (; trimmed_filename != NULL; trimmed_filename = strchr(trimmed_filename, PATHSEPCHAR)) {
/* Remove possible double path separator characters from
* the beginning, so we don't start reading e.g. root. */
- while (*p == PATHSEPCHAR) p++;
+ while (*trimmed_filename == PATHSEPCHAR) trimmed_filename++;
- item = names->GetItem(p, false);
+ item = names->GetItem(trimmed_filename, false);
if (item != NULL && !StrEmpty(item->value)) break;
}
@@ -173,6 +175,15 @@ bool MusicSet::FillSetDetails(IniFile *ini, const char *path, const char *full_f
this->num_available++;
this->songinfo[i].tracknr = j++;
+
+ item = timingtrim->GetItem(trimmed_filename, false);
+ if (item != NULL && !StrEmpty(item->value)) {
+ const char *endpos = strchr(item->value, ':');
+ if (endpos != NULL) {
+ this->songinfo[i].override_start = atoi(item->value);
+ this->songinfo[i].override_end = atoi(endpos + 1);
+ }
+ }
}
}
return ret;