From a1a74c6e9c5ade41f8bbb943677985af6dfa0dd7 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 16 May 2010 01:46:04 +0000 Subject: [PATCH] Implemented read+write logic for handling a "post movie" savestate. Also fixed a slight error where rerecordcount wouldn't increment if _S9XLUA_H is not defined. --- src/movie.cpp | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/movie.cpp b/src/movie.cpp index 0299391f..0277b7b5 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -1342,29 +1342,32 @@ bool FCEUMOV_ReadState(std::istream* is, uint32 size) } else //Read + write { - //truncate before we copy, just to save some time - tempMovieData.truncateAt(currFrameCounter); - currMovieData = tempMovieData; - - #ifdef _S9XLUA_H - if(!FCEU_LuaRerecordCountSkip()) + if (currFrameCounter > (int)tempMovieData.records.size()) + { + //This is a post movie savestate, handle it differently + //Recplae movie contents but then switch to movie finished mode + currMovieData = tempMovieData; + openRecordingMovie(curMovieFilename); + currMovieData.dump(osRecordingMovie, false/*currMovieData.binaryFlag*/); + FinishPlayback(); + } + else + { + //truncate before we copy, just to save some time + tempMovieData.truncateAt(currFrameCounter); //we can only assume this here since we have checked that the frame counter is not greater than the movie data + currMovieData = tempMovieData; +#ifdef _S9XLUA_H + if(!FCEU_LuaRerecordCountSkip()) + currRerecordCount++; +#else currRerecordCount++; - #endif - - currMovieData.rerecordCount = currRerecordCount; +#endif + currMovieData.rerecordCount = currRerecordCount; + openRecordingMovie(curMovieFilename); + currMovieData.dump(osRecordingMovie, false/*currMovieData.binaryFlag*/); + movieMode = MOVIEMODE_RECORD; - openRecordingMovie(curMovieFilename); - - /* - is->seekg((uint32)curr); - char *str = new char[size]; - is->read(str, size); - osRecordingMovie->write(str,size); - delete[] str; - */ - - currMovieData.dump(osRecordingMovie, false/*currMovieData.binaryFlag*/); - movieMode = MOVIEMODE_RECORD; + } } }