diff options
-rw-r--r-- | src/game.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/game.cpp b/src/game.cpp index 0499263c..199c2638 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -342,6 +342,7 @@ bool saveScreenshot(SDL_Surface *screenshot) static unsigned int screenshotCount = 0; // Search for an unused screenshot name + std::stringstream filenameSuffix; std::stringstream filename; std::fstream testExists; bool found = false; @@ -349,12 +350,16 @@ bool saveScreenshot(SDL_Surface *screenshot) do { screenshotCount++; filename.str(""); + filenameSuffix.str(""); + filename << PHYSFS_getUserDir(); #if (defined __USE_UNIX98 || defined __FreeBSD__) - filename << PHYSFS_getUserDir() << ".tmw/"; + filenameSuffix << ".tmw/"; #elif defined __APPLE__ - filename << PHYSFS_getUserDir() << "Desktop/"; + filenameSuffix << "Desktop/"; #endif - filename << "TMW_Screenshot_" << screenshotCount << ".png"; + filenameSuffix << "TMW_Screenshot_" << screenshotCount << ".png"; + filename << filenameSuffix.str(); + std::cerr << "Trying `" << filename.str() << "' from `" << filenameSuffix.str() << "'\n"; testExists.open(filename.str().c_str(), std::ios::in); found = !testExists.is_open(); testExists.close(); @@ -363,7 +368,7 @@ bool saveScreenshot(SDL_Surface *screenshot) if (ImageWriter::writePNG(screenshot, filename.str())) { std::stringstream chatlogentry; - chatlogentry << "Screenshot saved to " << filename.str().c_str(); + chatlogentry << "Screenshot saved to ~/" << filenameSuffix.str().c_str(); chatWindow->chatLog(chatlogentry.str(), BY_SERVER); return true; } |