Only delete old save file being saved.

Saving compressed file deletes uncompressed save and vice versa.

Also if uncompressed file exists, it loads uncompressed save instead of compressed save.
This commit is contained in:
Frank-74 2016-11-21 16:33:13 +00:00 committed by GitHub
parent 29c2a6932b
commit 2c8e412a66
1 changed files with 8 additions and 6 deletions

View File

@ -1518,11 +1518,6 @@ bool CN64System::SaveState()
SaveFile.DirectoryCreate(); SaveFile.DirectoryCreate();
} }
//delete any old save
ExtraInfo.Delete();
SaveFile.Delete();
ZipFile.Delete();
//Open the file //Open the file
if (g_Settings->LoadDword(Game_FuncLookupMode) == FuncFind_ChangeMemory) if (g_Settings->LoadDword(Game_FuncLookupMode) == FuncFind_ChangeMemory)
{ {
@ -1538,6 +1533,7 @@ bool CN64System::SaveState()
uint32_t NextViTimer = m_SystemTimer.GetTimer(CSystemTimer::ViTimer); uint32_t NextViTimer = m_SystemTimer.GetTimer(CSystemTimer::ViTimer);
if (g_Settings->LoadDword(Setting_AutoZipInstantSave)) if (g_Settings->LoadDword(Setting_AutoZipInstantSave))
{ {
ZipFile.Delete();
zipFile file = zipOpen(ZipFile, 0); zipFile file = zipOpen(ZipFile, 0);
zipOpenNewFileInZip(file, SaveFile.GetNameExtension().c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION); zipOpenNewFileInZip(file, SaveFile.GetNameExtension().c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION);
zipWriteInFileInZip(file, &SaveID_0, sizeof(SaveID_0)); zipWriteInFileInZip(file, &SaveID_0, sizeof(SaveID_0));
@ -1579,6 +1575,8 @@ bool CN64System::SaveState()
} }
else else
{ {
ExtraInfo.Delete();
SaveFile.Delete();
CFile hSaveFile(SaveFile, CFileBase::modeWrite | CFileBase::modeCreate); CFile hSaveFile(SaveFile, CFileBase::modeWrite | CFileBase::modeCreate);
if (!hSaveFile.IsOpen()) if (!hSaveFile.IsOpen())
{ {
@ -1662,6 +1660,10 @@ bool CN64System::LoadState()
CPath ZipFileName; CPath ZipFileName;
ZipFileName = (const std::string &)FileName + ".zip"; ZipFileName = (const std::string &)FileName + ".zip";
if (g_Settings->LoadDword(Setting_AutoZipInstantSave))
{
FileName=ZipFileName;
}
if ((g_Settings->LoadDword(Setting_AutoZipInstantSave) && ZipFileName.Exists()) || FileName.Exists()) if ((g_Settings->LoadDword(Setting_AutoZipInstantSave) && ZipFileName.Exists()) || FileName.Exists())
{ {
if (LoadState(FileName)) if (LoadState(FileName))
@ -2183,4 +2185,4 @@ void CN64System::TLB_Changed()
{ {
g_Debugger->TLBChanged(); g_Debugger->TLBChanged();
} }
} }