From 9b5b671673741ec6580c3f03688acbd4aba12973 Mon Sep 17 00:00:00 2001 From: Ted John Date: Mon, 4 Dec 2017 17:46:56 +0000 Subject: [PATCH] Fix #6776: Screenshots do not get stored in screenshot folder --- src/openrct2/interface/Screenshot.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index c286acb9a6..976c55c335 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -103,7 +103,15 @@ static sint32 screenshot_get_next_path(char *path, size_t size) #endif // Glue together path and filename - snprintf(path, size, "%s%s %d-%02d-%02d %02d-%02d-%02d.png", screenshotPath, park_name, currentDate.year, currentDate.month, currentDate.day, currentTime.hour, currentTime.minute, currentTime.second); + safe_strcpy(path, screenshotPath, size); + path_end_with_separator(path, size); + auto fileNameCh = strchr(path, '\0'); + if (fileNameCh == nullptr) + { + log_error("Unable to generate a screenshot filename."); + return -1; + } + snprintf(fileNameCh, size - strlen(path), "%s %d-%02d-%02d %02d-%02d-%02d.png", park_name, currentDate.year, currentDate.month, currentDate.day, currentTime.hour, currentTime.minute, currentTime.second); if (!platform_file_exists(path)) { return 0; // path ok