aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Robbins <kde.psych@gmail.com>2015-03-25 02:42:31 +1000
committerCraig Robbins <kde.psych@gmail.com>2015-03-25 02:55:28 +1000
commit4fbcfac6cf5f7404df62e94133388c601386d687 (patch)
treef319b8d892fcd641811771383fa2107892ab532d
parent2641fcc4bb9c3fae58e28a2b73921dd1fb419d8a (diff)
downloadminetest-4fbcfac6cf5f7404df62e94133388c601386d687.tar.gz
minetest-4fbcfac6cf5f7404df62e94133388c601386d687.tar.bz2
minetest-4fbcfac6cf5f7404df62e94133388c601386d687.zip
Change filename of screenshots to something more human readable
-rw-r--r--src/client.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 3320172f4..b637e0336 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1710,13 +1710,22 @@ void Client::makeScreenshot(IrrlichtDevice *device)
if (image) {
raw_image->copyTo(image);
- irr::c8 filename[256];
- snprintf(filename, sizeof(filename),
- (std::string("%s") + DIR_DELIM + "screenshot_%u.png").c_str(),
- g_settings->get("screenshot_path").c_str(),
- device->getTimer()->getRealTime());
+
+ std::string filename;
+
+ time_t t = time(NULL);
+ struct tm *tm = localtime(&t);
+ char timetstamp_c[16]; // YYYYMMDD_HHMMSS + '\0'
+ strftime(timetstamp_c, sizeof(timetstamp_c), "%Y%m%d_%H%M%S", tm);
+
+ filename = g_settings->get("screenshot_path")
+ + DIR_DELIM
+ + std::string("screenshot_")
+ + std::string(timetstamp_c)
+ + ".png";
+
std::ostringstream sstr;
- if (driver->writeImageToFile(image, filename)) {
+ if (driver->writeImageToFile(image, filename.c_str())) {
sstr << "Saved screenshot to '" << filename << "'";
} else {
sstr << "Failed to save screenshot '" << filename << "'";