summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2018-09-03 18:43:55 +0200
committerNiels Martin Hansen <nielsm@indvikleren.dk>2018-09-03 21:57:04 +0200
commitbb086f92403aa70d5756c334df31a65f4b854e39 (patch)
tree22e853f8418a3fff56820a329440e2ca53b7e12a
parent560b01f3071664357c2608c031bb8a4f86caaf26 (diff)
downloadopenttd-bb086f92403aa70d5756c334df31a65f4b854e39.tar.xz
Fix: Better "temp" path for decoded MPSMIDI files when source filename has no path separators
-rw-r--r--src/music/midifile.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/music/midifile.cpp b/src/music/midifile.cpp
index 9506776ef..931be181a 100644
--- a/src/music/midifile.cpp
+++ b/src/music/midifile.cpp
@@ -1020,16 +1020,18 @@ std::string MidiFile::GetSMFFile(const MusicSongInfo &song)
if (song.filetype != MTT_MPSMIDI) return std::string();
- const char *lastpathsep = strrchr(song.filename, PATHSEPCHAR);
- if (lastpathsep == NULL) {
- lastpathsep = song.filename;
- }
-
char basename[MAX_PATH];
{
+ const char *fnstart = strrchr(song.filename, PATHSEPCHAR);
+ if (fnstart == NULL) {
+ fnstart = song.filename;
+ } else {
+ fnstart++;
+ }
+
/* Remove all '.' characters from filename */
char *wp = basename;
- for (const char *rp = lastpathsep + 1; *rp != '\0'; rp++) {
+ for (const char *rp = fnstart; *rp != '\0'; rp++) {
if (*rp != '.') *wp++ = *rp;
}
*wp++ = '\0';