lua functions movie.ispoweron() and movie.isfromsavestate() fixed.

This commit is contained in:
ugetab 2010-04-21 21:10:17 +00:00
parent a96f1e5360
commit 1ff2b3d892
3 changed files with 17 additions and 5 deletions

View File

@ -120,7 +120,6 @@ int luaRunning = FALSE;
// True at the frame boundary, false otherwise.
static int frameBoundary = FALSE;
// The execution speed we're running at.
static enum {SPEED_NORMAL, SPEED_NOTHROTTLE, SPEED_TURBO, SPEED_MAXIMUM} speedmode = SPEED_NORMAL;
@ -2567,8 +2566,9 @@ static int movie_replay (lua_State *L) {
//
//If movie is recorded from power-on
static int movie_ispoweron (lua_State *L) {
if (FCEUMOV_IsRecording() && FCEUMOV_IsPlaying())
return (currMovieData.savestate.size() == 0);
if (FCEUMOV_IsRecording() || FCEUMOV_IsPlaying()) {
return FCEUMOV_FromPoweron();
}
else
return 0;
}
@ -2577,8 +2577,9 @@ static int movie_ispoweron (lua_State *L) {
//
//If movie is recorded from a savestate
static int movie_isfromsavestate (lua_State *L) {
if (FCEUMOV_IsRecording() && FCEUMOV_IsPlaying())
return (currMovieData.savestate.size() != 0);
if (FCEUMOV_IsRecording() || FCEUMOV_IsPlaying()) {
return !FCEUMOV_FromPoweron();
}
else
return 0;
}

View File

@ -53,6 +53,7 @@ std::vector<string> subtitleMessages; //Messages of subtitles
bool subtitlesOnAVI = false;
bool autoMovieBackup = false; //Toggle that determines if movies should be backed up automatically before altering them
bool freshMovie = false; //True when a movie loads, false when movie is altered. Used to determine if a movie has been altered since opening
bool movieFromPoweron = true;
// Function declarations------------------------
@ -797,6 +798,10 @@ void FCEUMOV_ExitTasEdit()
currMovieData = MovieData();
}
bool FCEUMOV_FromPoweron()
{
return movieFromPoweron;
}
bool MovieData::loadSavestateFrom(std::vector<char>* buf)
{
memorystream ms(buf);
@ -852,8 +857,11 @@ bool FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _paus
//WE NEED TO LOAD A SAVESTATE
if(currMovieData.savestate.size() != 0)
{
movieFromPoweron = false;
bool success = MovieData::loadSavestateFrom(&currMovieData.savestate);
if(!success) return true; //adelikat: I guess return true here? False is only for a bad movie filename, if it got this far the file was god?
} else {
movieFromPoweron = true;
}
//if there is no savestate, we won't have this crucial piece of information at the start of the movie.
@ -938,10 +946,12 @@ void FCEUI_SaveMovie(const char *fname, EMOVIE_FLAG flags, std::wstring author)
if(flags & MOVIE_FLAG_FROM_POWERON)
{
movieFromPoweron = true;
poweron(true);
}
else
{
movieFromPoweron = false;
MovieData::dumpSavestateTo(&currMovieData.savestate,Z_BEST_COMPRESSION);
}

View File

@ -87,6 +87,7 @@ bool FCEUMOV_PostLoad();
void FCEUMOV_EnterTasEdit();
void FCEUMOV_ExitTasEdit();
bool FCEUMOV_FromPoweron();
class MovieData;
class MovieRecord