From 9f2b625b1d5832d8e7c51f0cc3e61a2e90effd0c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 13 Jan 2014 20:46:44 +0300 Subject: allow create screenshot before connecting to game. --- src/game.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index a2f389626..8d11d222c 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -488,9 +488,12 @@ Game::~Game() bool Game::createScreenshot() { + if (!mainGraphics) + return false; + SDL_Surface *screenshot = nullptr; - if (!config.getBoolValue("showip")) + if (!config.getBoolValue("showip") && gui) { mainGraphics->setSecure(true); mainGraphics->prepareScreenshot(); @@ -512,7 +515,6 @@ bool Game::createScreenshot() bool Game::saveScreenshot(SDL_Surface *const screenshot) { std::string screenshotDirectory = client->getScreenshotDirectory(); - if (mkdir_r(screenshotDirectory.c_str()) != 0) { logger->log("Directory %s doesn't exist and can't be created! " @@ -554,12 +556,14 @@ bool Game::saveScreenshot(SDL_Surface *const screenshot) if (success) { - std::stringstream chatlogentry; - // TRANSLATORS: save file message - chatlogentry << strprintf(_("Screenshot saved as %s"), - filenameSuffix.str().c_str()); if (localChatTab) - localChatTab->chatLog(chatlogentry.str(), BY_SERVER); + { + std::stringstream chatlogentry; + // TRANSLATORS: save file message + std::string str = strprintf(_("Screenshot saved as %s"), + filenameSuffix.str().c_str()); + localChatTab->chatLog(str, BY_SERVER); + } } else { @@ -573,7 +577,6 @@ bool Game::saveScreenshot(SDL_Surface *const screenshot) } MSDL_FreeSurface(screenshot); - return success; } -- cgit v1.2.3-70-g09d2