From ca0e88c0a8f66304fe7122bcacdf975c36b1dcd3 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 20 Apr 2003 23:45:01 +0000 Subject: [PATCH] Fix images not being seen on first load. Work around broken data with leading spaces in the path. --- stepmania/src/NotesLoaderSM.cpp | 5 ----- stepmania/src/Song.cpp | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/stepmania/src/NotesLoaderSM.cpp b/stepmania/src/NotesLoaderSM.cpp index 69fe1d76dd..d6157974bc 100644 --- a/stepmania/src/NotesLoaderSM.cpp +++ b/stepmania/src/NotesLoaderSM.cpp @@ -275,11 +275,6 @@ bool SMLoader::LoadFromSMFile( CString sPath, Song &out ) LOG->Trace( "Unexpected value named '%s'", sValueName.GetString() ); } - out.m_sBannerFile.Replace("\\", "/"); - out.m_sBackgroundFile.Replace("\\", "/"); - out.m_sCDTitleFile.Replace("\\", "/"); - out.m_sMusicFile.Replace("\\", "/"); - return true; } diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index f4bc58e0b7..a9fd140965 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -512,6 +512,25 @@ void Song::TidyUpData() LOG->Trace("Looking for images..."); + /* Replace backslashes with slashes in all paths. */ + m_sMusicFile.Replace("\\", "/"); + m_sBannerFile.Replace("\\", "/"); + m_sBackgroundFile.Replace("\\", "/"); + m_sCDTitleFile.Replace("\\", "/"); + m_sLyricsFile.Replace("\\", "/"); + + /* Many imported files contain erroneous whitespace before or after + * filenames. Paths usually don't actually start or end with spaces, + * so let's just remove it. */ + TrimLeft(m_sBannerFile); + TrimRight(m_sBannerFile); + TrimLeft(m_sBackgroundFile); + TrimRight(m_sBackgroundFile); + TrimLeft(m_sCDTitleFile); + TrimRight(m_sCDTitleFile); + TrimLeft(m_sLyricsFile); + TrimRight(m_sLyricsFile); + // // First, check the file name for hints. //