mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Fix config_store for old maps that don't contain MAPITEMTYPE_INFO
Just add one in this case.
This commit is contained in:
parent
f27ee72d2d
commit
cc0d0fa728
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue