[Project64] Handle saves from 2.2

This commit is contained in:
zilmar 2016-08-11 17:53:01 +10:00
parent 4733420dfa
commit 725ca8bcbe
1 changed files with 16 additions and 6 deletions

View File

@ -16,7 +16,7 @@
#include <Project64-core/N64System/N64Class.h>
#include <Project64-core/3rdParty/zip.h>
CSystemTimer::CSystemTimer( int32_t & NextTimer ) :
CSystemTimer::CSystemTimer(int32_t & NextTimer) :
m_NextTimer(NextTimer),
m_inFixTimer(false)
{
@ -331,7 +331,7 @@ void CSystemTimer::SaveData(CFile & file) const
{
uint32_t TimerDetailsSize = sizeof(TIMER_DETAILS);
uint32_t Entries = sizeof(m_TimerDetatils) / sizeof(m_TimerDetatils[0]);
file.Write(&TimerDetailsSize, sizeof(TimerDetailsSize));
file.Write(&Entries, sizeof(Entries));
file.Write((void *)&m_TimerDetatils, sizeof(m_TimerDetatils));
@ -354,11 +354,21 @@ void CSystemTimer::LoadData(zipFile & file)
}
if (Entries != sizeof(m_TimerDetatils) / sizeof(m_TimerDetatils[0]))
{
g_Notify->BreakPoint(__FILE__, __LINE__);
return;
if (Entries < (sizeof(m_TimerDetatils) / sizeof(m_TimerDetatils[0])))
{
memset((void *)&m_TimerDetatils, 0, sizeof(m_TimerDetatils));
unzReadCurrentFile(file, (void *)&m_TimerDetatils, Entries * sizeof(m_TimerDetatils[0]));
}
else
{
g_Notify->BreakPoint(__FILE__, __LINE__);
return;
}
}
else
{
unzReadCurrentFile(file, (void *)&m_TimerDetatils, sizeof(m_TimerDetatils));
}
unzReadCurrentFile(file, (void *)&m_TimerDetatils, sizeof(m_TimerDetatils));
unzReadCurrentFile(file, (void *)&m_LastUpdate, sizeof(m_LastUpdate));
unzReadCurrentFile(file, &m_NextTimer, sizeof(m_NextTimer));
unzReadCurrentFile(file, (void *)&m_Current, sizeof(m_Current));