Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix recording from save state
  • Loading branch information
rog9 committed Oct 18, 2012
1 parent a366521 commit 7f624cd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
22 changes: 15 additions & 7 deletions Source/Core/Core/Src/Movie.cpp
Expand Up @@ -217,6 +217,11 @@ bool IsJustStartingRecordingInputFromSaveState()
return IsRecordingInputFromSaveState() && g_currentFrame == 0;
}

bool IsJustStartingPlayingInputFromSaveState()
{
return tmpHeader.bFromSaveState && g_currentFrame == 1;
}

bool IsPlayingInput()
{
return (g_playMode == MODE_PLAYING);
Expand Down Expand Up @@ -287,6 +292,13 @@ bool BeginRecordingInput(int controllers)
if(g_playMode != MODE_NONE || controllers == 0)
return false;

g_numPads = controllers;
g_currentFrame = g_totalFrames = 0;
g_currentLagCount = g_totalLagCount = 0;
g_currentInputCount = g_totalInputCount = 0;
g_recordingStartTime = Common::Timer::GetLocalTimeSinceJan1970();
g_rerecords = 0;

if (Core::IsRunning())
{
if(File::Exists(tmpStateFilename))
Expand All @@ -295,13 +307,6 @@ bool BeginRecordingInput(int controllers)
State::SaveAs(tmpStateFilename.c_str());
g_bRecordingFromSaveState = true;
}

g_numPads = controllers;
g_currentFrame = g_totalFrames = 0;
g_currentLagCount = g_totalLagCount = 0;
g_currentInputCount = g_totalInputCount = 0;
g_recordingStartTime = Common::Timer::GetLocalTimeSinceJan1970();
g_rerecords = 0;
g_playMode = MODE_RECORDING;

delete [] tmpInput;
Expand Down Expand Up @@ -548,6 +553,8 @@ bool PlayInput(const char *filename)
if(File::Exists(stateFilename))
Core::SetStateFileName(stateFilename);
g_bRecordingFromSaveState = true;
Movie::LoadInput(filename);
g_currentFrame = 0;
}

/* TODO: Put this verification somewhere we have the gameID of the played game
Expand Down Expand Up @@ -877,6 +884,7 @@ void EndPlayInput(bool cont)
g_currentByte = 0;
g_playMode = MODE_NONE;
Core::DisplayMessage("Movie End.", 2000);
tmpHeader.bFromSaveState = 0;
// we don't clear these things because otherwise we can't resume playback if we load a movie state later
//g_totalFrames = g_totalBytes = 0;
//delete tmpInput;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/Src/Movie.h
Expand Up @@ -113,6 +113,7 @@ bool IsAutoFiring();
bool IsRecordingInput();
bool IsRecordingInputFromSaveState();
bool IsJustStartingRecordingInputFromSaveState();
bool IsJustStartingPlayingInputFromSaveState();
bool IsPlayingInput();
bool IsReadOnly();
u64 GetRecordingStartTime();
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Src/State.cpp
Expand Up @@ -413,7 +413,7 @@ void LoadAs(const std::string& filename)
Core::DisplayMessage(StringFromFormat("Loaded state from %s", filename.c_str()).c_str(), 2000);
if (File::Exists(filename + ".dtm"))
Movie::LoadInput((filename + ".dtm").c_str());
else if (!Movie::IsJustStartingRecordingInputFromSaveState())
else if (!Movie::IsJustStartingRecordingInputFromSaveState() && !Movie::IsJustStartingPlayingInputFromSaveState())
Movie::EndPlayInput(false);
}
else
Expand Down

0 comments on commit 7f624cd

Please sign in to comment.