Fix config_store for old maps that don't contain MAPITEMTYPE_INFO

Just add one in this case.
This commit is contained in:
heinrich5991 2015-08-27 15:46:51 +02:00
parent f27ee72d2d
commit cc0d0fa728
2 changed files with 28 additions and 0 deletions

View file

@ -2574,6 +2574,7 @@ void CGameContext::OnMapChange(char *pNewMapName, int MapNameSize)
Writer.Init();
int SettingsIndex = Reader.NumData();
bool FoundInfo = false;
for(int i = 0; i < Reader.NumItems(); i++)
{
int TypeID;
@ -2584,6 +2585,7 @@ void CGameContext::OnMapChange(char *pNewMapName, int MapNameSize)
CMapItemInfoSettings MapInfo;
if(TypeID == MAPITEMTYPE_INFO && ItemID == 0)
{
FoundInfo = true;
CMapItemInfoSettings *pInfo = (CMapItemInfoSettings *)pData;
if(Size >= (int)sizeof(CMapItemInfoSettings))
{
@ -2618,6 +2620,18 @@ void CGameContext::OnMapChange(char *pNewMapName, int MapNameSize)
Writer.AddItem(TypeID, ItemID, Size, pData);
}
if(!FoundInfo)
{
CMapItemInfoSettings Info;
Info.m_Version = 1;
Info.m_Author = -1;
Info.m_MapVersion = -1;
Info.m_Credits = -1;
Info.m_License = -1;
Info.m_Settings = SettingsIndex;
Writer.AddItem(MAPITEMTYPE_INFO, 0, sizeof(Info), &Info);
}
for(int i = 0; i < Reader.NumData() || i == SettingsIndex; i++)
{
if(i == SettingsIndex)

View file

@ -47,6 +47,7 @@ void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
Writer.Init();
int SettingsIndex = Reader.NumData();
bool FoundInfo = false;
for(int i = 0; i < Reader.NumItems(); i++)
{
int TypeID;
@ -57,6 +58,7 @@ void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
CMapItemInfoSettings MapInfo;
if(TypeID == MAPITEMTYPE_INFO && ItemID == 0)
{
FoundInfo = true;
CMapItemInfoSettings *pInfo = (CMapItemInfoSettings *)pData;
if(Size >= (int)sizeof(CMapItemInfoSettings))
{
@ -94,6 +96,18 @@ void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
Writer.AddItem(TypeID, ItemID, Size, pData);
}
if(!FoundInfo)
{
CMapItemInfoSettings Info;
Info.m_Version = 1;
Info.m_Author = -1;
Info.m_MapVersion = -1;
Info.m_Credits = -1;
Info.m_License = -1;
Info.m_Settings = SettingsIndex;
Writer.AddItem(MAPITEMTYPE_INFO, 0, sizeof(Info), &Info);
}
for(int i = 0; i < Reader.NumData() || i == SettingsIndex; i++)
{
if(i == SettingsIndex)