Put date/time in screenshot file names.

The new format is "wz2100-YYYYMMDD_HHMMSS-mapname[-x]", where the "-x" part is
only added when the file already exists (should only happen when people time
travel or hammer F10). Refs #1890.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/branches/qt-trunk@10903 4a71c877-e1ca-e34f-864e-861f7616d084
master
Christian Ohm 2010-06-03 19:13:50 +00:00 committed by Git SVN Gateway
parent bcef5a3f5d
commit 0b1cf62050
1 changed files with 12 additions and 14 deletions

View File

@ -453,21 +453,19 @@ void screenDoDumpToDiskIfRequired(void)
*/
void screenDumpToDisk(const char* path)
{
static unsigned int screendump_num = 0;
unsigned int screendump_num = 0;
time_t aclock;
struct tm *t;
while (++screendump_num != 0) {
// We can safely use '/' as path separator here since PHYSFS uses that as its default separator
ssprintf(screendump_filename, "%s/wz2100_%s_shot_%03i.png", path, getLevelName(), screendump_num);
if (!PHYSFS_exists(screendump_filename)) {
// Found a usable filename, so we'll stop searching.
break;
}
time(&aclock); /* Get time in seconds */
t = localtime(&aclock); /* Convert time to struct */
ssprintf(screendump_filename, "%s/wz2100-%04d%02d%02d_%02d%02d%02d-%s.png", path, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, getLevelName());
while (PHYSFS_exists(screendump_filename))
{
ssprintf(screendump_filename, "%s/wz2100-%04d%02d%02d_%02d%02d%02d-%s-%d.png", path, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, getLevelName(), ++screendump_num);
}
ASSERT( screendump_num != 0, "screenDumpToDisk: integer overflow; no more filenumbers available.\n" );
// If we have an integer overflow, we don't want to go about and overwrite files
if (screendump_num != 0)
screendump_required = true;
screendump_required = true;
}