From f2bb0b2e79a8ffe5cffea528481dc1560568be91 Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Tue, 31 Dec 2013 17:19:05 -0500 Subject: [PATCH] initialize gameFolder to be SDL_GetBasePath() --- src/config.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index e6f3354..0d14a61 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -21,6 +21,8 @@ #include "config.h" +#include + #include #include #include @@ -46,7 +48,13 @@ Config::Config() solidFonts(false), gameFolder("."), allowSymlinks(false) -{} +{ + char *dataDir = SDL_GetBasePath(); + if (dataDir) { + gameFolder = dataDir; + SDL_free(dataDir); + } +} void Config::read() { @@ -101,9 +109,9 @@ void Config::readGameINI() { if (!customScript.empty()) { - size_t pos = customScript.find_last_of("/\\"); - if (pos == customScript.npos) pos = 0; - game.title = customScript.substr(pos); + size_t pos = customScript.find_last_of("/\\"); + if (pos == customScript.npos) pos = 0; + game.title = customScript.substr(pos); return; } @@ -131,8 +139,8 @@ void Config::readGameINI() strReplace(game.scripts, '\\', '/'); if (game.title.empty()) { - size_t pos = gameFolder.find_last_of("/\\"); - if (pos == gameFolder.npos) pos = 0; - game.title = gameFolder.substr(pos); - } + size_t pos = gameFolder.find_last_of("/\\"); + if (pos == gameFolder.npos) pos = 0; + game.title = gameFolder.substr(pos); + } }