When reloading the sysconf file make sure that the m_Entries vector is cleared.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7278 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
bda0794adb
commit
1ae59b6dc3
|
@ -38,9 +38,10 @@ void SysConf::Clear()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_Entries.size() - 1; i++)
|
for (size_t i = 0; i < m_Entries.size() - 1; i++)
|
||||||
{
|
{
|
||||||
delete [] m_Entries.at(i).data;
|
delete [] m_Entries[i].data;
|
||||||
m_Entries.at(i).data = NULL;
|
m_Entries[i].data = NULL;
|
||||||
}
|
}
|
||||||
|
m_Entries.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SysConf::LoadFromFile(const char *filename)
|
bool SysConf::LoadFromFile(const char *filename)
|
||||||
|
@ -87,7 +88,7 @@ bool SysConf::LoadFromFileInternal(FILE *f)
|
||||||
// Last offset is an invalid entry. We ignore it throughout this class
|
// Last offset is an invalid entry. We ignore it throughout this class
|
||||||
for (size_t i = 0; i < m_Entries.size() - 1; i++)
|
for (size_t i = 0; i < m_Entries.size() - 1; i++)
|
||||||
{
|
{
|
||||||
SSysConfEntry& curEntry = m_Entries.at(i);
|
SSysConfEntry& curEntry = m_Entries[i];
|
||||||
if (fseeko(f, curEntry.offset, SEEK_SET) != 0) return false;
|
if (fseeko(f, curEntry.offset, SEEK_SET) != 0) return false;
|
||||||
|
|
||||||
u8 description = 0;
|
u8 description = 0;
|
||||||
|
@ -146,19 +147,19 @@ bool SysConf::SaveToFile(const char *filename)
|
||||||
for (size_t i = 0; i < m_Entries.size() - 1; i++)
|
for (size_t i = 0; i < m_Entries.size() - 1; i++)
|
||||||
{
|
{
|
||||||
// Seek to after the name of this entry
|
// Seek to after the name of this entry
|
||||||
if (fseeko(f, m_Entries.at(i).offset + m_Entries.at(i).nameLength + 1, SEEK_SET) != 0) return false;
|
if (fseeko(f, m_Entries[i].offset + m_Entries[i].nameLength + 1, SEEK_SET) != 0) return false;
|
||||||
// We may have to write array length value...
|
// We may have to write array length value...
|
||||||
if (m_Entries.at(i).type == Type_BigArray)
|
if (m_Entries[i].type == Type_BigArray)
|
||||||
{
|
{
|
||||||
u16 tmpDataLength = Common::swap16(m_Entries.at(i).dataLength);
|
u16 tmpDataLength = Common::swap16(m_Entries[i].dataLength);
|
||||||
if (fwrite(&tmpDataLength, 2, 1, f) != 1) return false;
|
if (fwrite(&tmpDataLength, 2, 1, f) != 1) return false;
|
||||||
}
|
}
|
||||||
else if (m_Entries.at(i).type == Type_SmallArray)
|
else if (m_Entries[i].type == Type_SmallArray)
|
||||||
{
|
{
|
||||||
if (fwrite(&m_Entries.at(i).dataLength, 1, 1, f) != 1) return false;
|
if (fwrite(&m_Entries[i].dataLength, 1, 1, f) != 1) return false;
|
||||||
}
|
}
|
||||||
// Now write the actual data
|
// Now write the actual data
|
||||||
if (fwrite(m_Entries.at(i).data, m_Entries.at(i).dataLength, 1, f) != 1) return false;
|
if (fwrite(m_Entries[i].data, m_Entries[i].dataLength, 1, f) != 1) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
|
@ -96,7 +96,7 @@ public:
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
for (; index < m_Entries.size() - 1; index++)
|
for (; index < m_Entries.size() - 1; index++)
|
||||||
{
|
{
|
||||||
if (strcmp(m_Entries.at(index).name, sectionName) == 0)
|
if (strcmp(m_Entries[index].name, sectionName) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (index == m_Entries.size() - 1)
|
if (index == m_Entries.size() - 1)
|
||||||
|
@ -105,7 +105,7 @@ public:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_Entries.at(index).GetData<T>();
|
return m_Entries[index].GetData<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetArrayData(const char* sectionName, u8* dest, u16 destSize)
|
bool GetArrayData(const char* sectionName, u8* dest, u16 destSize)
|
||||||
|
@ -119,7 +119,7 @@ public:
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
for (; index < m_Entries.size() - 1; index++)
|
for (; index < m_Entries.size() - 1; index++)
|
||||||
{
|
{
|
||||||
if (strcmp(m_Entries.at(index).name, sectionName) == 0)
|
if (strcmp(m_Entries[index].name, sectionName) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (index == m_Entries.size() - 1)
|
if (index == m_Entries.size() - 1)
|
||||||
|
@ -128,7 +128,7 @@ public:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_Entries.at(index).GetArrayData(dest, destSize);
|
return m_Entries[index].GetArrayData(dest, destSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetArrayData(const char* sectionName, u8* buffer, u16 bufferSize)
|
bool SetArrayData(const char* sectionName, u8* buffer, u16 bufferSize)
|
||||||
|
@ -139,7 +139,7 @@ public:
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
for (; index < m_Entries.size() - 1; index++)
|
for (; index < m_Entries.size() - 1; index++)
|
||||||
{
|
{
|
||||||
if (strcmp(m_Entries.at(index).name, sectionName) == 0)
|
if (strcmp(m_Entries[index].name, sectionName) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (index == m_Entries.size() - 1)
|
if (index == m_Entries.size() - 1)
|
||||||
|
@ -148,7 +148,7 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_Entries.at(index).SetArrayData(buffer, bufferSize);
|
return m_Entries[index].SetArrayData(buffer, bufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -160,7 +160,7 @@ public:
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
for (; index < m_Entries.size() - 1; index++)
|
for (; index < m_Entries.size() - 1; index++)
|
||||||
{
|
{
|
||||||
if (strcmp(m_Entries.at(index).name, sectionName) == 0)
|
if (strcmp(m_Entries[index].name, sectionName) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (index == m_Entries.size() - 1)
|
if (index == m_Entries.size() - 1)
|
||||||
|
@ -169,7 +169,7 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(T*)m_Entries.at(index).data = newValue;
|
*(T*)m_Entries[index].data = newValue;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue