From 44e842772989db40eb3921c452687aff42fbb626 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 25 Feb 2004 01:51:31 +0000 Subject: [PATCH] fix screenshot filename searching if a file like "screen0.jpg" exists --- stepmania/src/StepMania.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index b1617437bd..a345892ed3 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -1128,14 +1128,19 @@ CString SaveScreenshot( CString sDir, bool bSaveCompressed, bool bMakeSignature, * is deleted, we won't fill in the hole (which makes screenshots hard to find). */ if( iIndex == -1 ) { - for( int i = files.size()-1; i >= 0; --i ) - if( sscanf( files[i], "screen%d.%*s", &iIndex ) == 1 ) - break; + iIndex = 0; - if( iIndex == -1 ) - iIndex = 0; - else - ++iIndex; + for( int i = files.size()-1; i >= 0; --i ) + { + static Regex re( "^screen([0-9]{5})\\....$" ); + vector matches; + if( !re.Compare( files[i], matches ) ) + continue; + + ASSERT( matches.size() == 1 ); + iIndex = atoi( matches[0] )+1; + break; + } } //