summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 2e0a3cb5..2cc68c0e 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -349,6 +349,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;
@@ -356,12 +357,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();
@@ -370,7 +375,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;
}