diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 2936a8a147..1718ecce26 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -1493,6 +1493,7 @@ DEF_CONSOLE_CMD(ConScreenShot) IConsolePrint(CC_HELP, " 'minimap' makes a top-viewed minimap screenshot of the whole world which represents one tile by one pixel."); IConsolePrint(CC_HELP, " 'no_con' hides the console to create the screenshot (only useful in combination with 'viewport')."); IConsolePrint(CC_HELP, " 'size' sets the width and height of the viewport to make a screenshot of (only useful in combination with 'normal' or 'big')."); + IConsolePrint(CC_HELP, " A filename ending in # will prevent overwriting existing files and will number files counting upwards."); return true; } diff --git a/src/screenshot.cpp b/src/screenshot.cpp index e4cce7e1ed..bec7cc7c6b 100644 --- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -681,8 +681,16 @@ static const char *MakeScreenshotName(const char *default_fn, const char *ext, b } } - /* Add extension to screenshot file */ size_t len = strlen(_screenshot_name); + + /* Handle user-specified filenames ending in # with automatic numbering */ + if (StrEndsWith(_screenshot_name, "#")) { + generate = true; + len -= 1; + _screenshot_name[len] = '\0'; + } + + /* Add extension to screenshot file */ seprintf(&_screenshot_name[len], lastof(_screenshot_name), ".%s", ext); const char *screenshot_dir = crashlog ? _personal_dir.c_str() : FiosGetScreenshotDir();