From 716bbbfc5a122a21ba2eb2891d05a4e196789faf Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Sat, 11 Feb 2017 22:39:25 +0100 Subject: [PATCH] Fix locations of movies, sounds, config and pictures --- src/blupi.cpp | 4 +++- src/movie.cpp | 7 ++----- src/pixmap.cpp | 2 +- src/sound.cpp | 4 +++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/blupi.cpp b/src/blupi.cpp index dfc5dcf..90d9923 100644 --- a/src/blupi.cpp +++ b/src/blupi.cpp @@ -68,7 +68,9 @@ bool ReadConfig(int argc, char *argv[]) char* pText; size_t nb; - file = fopen("data/config.ini", "rb"); + const auto config = GetBaseDir () + "data/config.ini"; + + file = fopen(config.c_str (), "rb"); if ( file == nullptr ) return false; nb = fread(buffer, sizeof(char), 200-1, file); buffer[nb] = 0; diff --git a/src/movie.cpp b/src/movie.cpp index 191f1a5..e64bbde 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -79,8 +79,7 @@ void CMovie::fileCloseMovie() bool CMovie::fileOpenMovie(RECT rect, const char *pFilename) { - std::string path = GetBaseDir (); - path += pFilename; + const auto path = GetBaseDir () + pFilename; // we got a filename, now close any old movie and open the new one. */ if ( m_fMovieOpen ) fileCloseMovie(); @@ -195,11 +194,9 @@ bool CMovie::GetEnable() bool CMovie::IsExist(const char *pFilename) { - std::string path = GetBaseDir (); + const auto path = GetBaseDir () + pFilename; FILE* file; - path += pFilename; - file = fopen(path.c_str (), "rb"); if ( file == nullptr ) return false; diff --git a/src/pixmap.cpp b/src/pixmap.cpp index 79e2834..d27c542 100644 --- a/src/pixmap.cpp +++ b/src/pixmap.cpp @@ -198,7 +198,7 @@ bool CPixmap::Cache(int channel, const char *pFilename, POINT totalDim, POINT ic { if ( channel < 0 || channel >= MAXIMAGE ) return false; - std::string file = pFilename; + std::string file = GetBaseDir () + pFilename; if (access ((file + ".bmp").c_str (), 0 /* F_OK */) != -1) file += ".bmp"; diff --git a/src/sound.cpp b/src/sound.cpp index 444e758..02fe535 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -151,7 +151,9 @@ bool CSound::Cache(int channel, const char *pFilename) if (m_lpSDL[channel]) Flush(channel); - m_lpSDL[channel] = Mix_LoadWAV (pFilename); + const auto file = GetBaseDir () + pFilename; + + m_lpSDL[channel] = Mix_LoadWAV (file.c_str ()); if (!m_lpSDL[channel]) { SDL_Log ("Mix_LoadWAV: %s\n", Mix_GetError ());