Skip to content

Commit

Permalink
Cleanup and misc movie fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
rog9 committed Nov 26, 2012
1 parent 0c6dad6 commit 1917f83
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 36 deletions.
62 changes: 26 additions & 36 deletions Source/Core/Core/Src/Movie.cpp
Expand Up @@ -136,6 +136,7 @@ void Init()
if (IsPlayingInput())
{
ReadHeader();
std::thread md5thread(CheckMD5);
if ((strncmp((char *)tmpHeader.gameID, Core::g_CoreStartupParameter.GetUniqueID().c_str(), 6)))
{
PanicAlert("The recorded game (%s) is not the same as the selected game (%s)", tmpHeader.gameID, Core::g_CoreStartupParameter.GetUniqueID().c_str());
Expand Down Expand Up @@ -164,8 +165,6 @@ void Init()
g_currentLagCount = 0;
g_currentInputCount = 0;
}
else
std::thread md5thread(CheckMD5);
}

void InputUpdate()
Expand Down Expand Up @@ -388,7 +387,6 @@ bool BeginRecordingInput(int controllers)

State::SaveAs(tmpStateFilename.c_str());
g_bRecordingFromSaveState = true;
std::thread md5thread(CheckMD5);

// This is only done here if starting from save state because otherwise we won't have the titleid. Otherwise it's set in WII_IPC_HLE_Device_es.cpp.
// TODO: find a way to GetTitleDataPath() from Movie::Init()
Expand Down Expand Up @@ -638,7 +636,6 @@ void ReadHeader()
else
{
GetSettings();
bSaveConfig = false;
}

videoBackend.resize(ARRAYSIZE(tmpHeader.videoBackend));
Expand All @@ -658,9 +655,7 @@ void ReadHeader()
{
author[i] = tmpHeader.author[i];
}

for (int i = 0; i < 16; i++)
MD5[i] = tmpHeader.md5[i];
memcpy(MD5, tmpHeader.md5, 16);
}

bool PlayInput(const char *filename)
Expand Down Expand Up @@ -1083,8 +1078,7 @@ void SaveRecording(const char *filename)
header.bClearSave = g_bClearSave;
strncpy((char *)header.discChange, g_discChange.c_str(),ARRAYSIZE(header.discChange));
strncpy((char *)header.author, author.c_str(),ARRAYSIZE(header.author));
for (int i = 0; i < 16;i++)
header.md5[i] = MD5[i];
memcpy(header.md5,MD5,16);

// TODO
header.uniqueID = 0;
Expand Down Expand Up @@ -1142,45 +1136,41 @@ void GetSettings()
if (!Core::g_CoreStartupParameter.bWii)
g_bClearSave = !File::Exists(SConfig::GetInstance().m_strMemoryCardA);
bMemcard = SConfig::GetInstance().m_EXIDevice[0] == EXIDEVICE_MEMORYCARD;
std::thread md5thread(GetMD5);
}

void CheckMD5()
{
if (IsRecordingInput())
{
Core::DisplayMessage("Calculating checksum of game file...", 2000);
for (int i = 0; i < 16; i++)
MD5[i] = 0;
}
else
for (int i=0, n=0; i<16; i++)
{
for (int i=0; i<16; i++)
{
if (tmpHeader.md5[i] != 0)
continue;
if (i == 15)
return;
}
Core::DisplayMessage("Verifying checksum...", 2000);
if (tmpHeader.md5[i] != 0)
continue;
n++;
if (n == 16)
return;
}
Core::DisplayMessage("Verifying checksum...", 2000);

unsigned char gameMD5[16];
char game[255];
memcpy(game, SConfig::GetInstance().m_LastFilename.c_str(), SConfig::GetInstance().m_LastFilename.size());
md5_file(game, gameMD5);

if (IsPlayingInput())
{
if (memcmp(gameMD5,MD5,16) == 0)
Core::DisplayMessage("Checksum of current game matches the recorded game.", 2000);
else
PanicAlert("Checksum of current game does not match the recorded game!");
}
if (memcmp(gameMD5,MD5,16) == 0)
Core::DisplayMessage("Checksum of current game matches the recorded game.", 2000);
else
{
memcpy(MD5, gameMD5,16);
Core::DisplayMessage("Finished calculating checksum.", 2000);
}
PanicAlert("Checksum of current game does not match the recorded game!");
}

void GetMD5()
{
Core::DisplayMessage("Calculating checksum of game file...", 2000);
for (int i = 0; i < 16; i++)
MD5[i] = 0;
char game[255];
memcpy(game, SConfig::GetInstance().m_LastFilename.c_str(), SConfig::GetInstance().m_LastFilename.size());
md5_file(game, MD5);
Core::DisplayMessage("Finished calculating checksum.", 2000);
}

void Shutdown()
Expand All @@ -1189,4 +1179,4 @@ void Shutdown()
delete [] tmpInput;
tmpInput = NULL;
}
};
};
1 change: 1 addition & 0 deletions Source/Core/Core/Src/Movie.h
Expand Up @@ -177,6 +177,7 @@ void EndPlayInput(bool cont);
void SaveRecording(const char *filename);
void DoState(PointerWrap &p);
void CheckMD5();
void GetMD5();
void Shutdown();

std::string GetInputDisplay();
Expand Down

0 comments on commit 1917f83

Please sign in to comment.