mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 01:24:18 +00:00
Move/rename variable declarations in config_store
This commit is contained in:
parent
e8bd26857b
commit
8258effb33
|
@ -9,8 +9,6 @@
|
||||||
void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
|
void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
|
||||||
{
|
{
|
||||||
IOHANDLE File = pStorage->OpenFile(pConfigName, IOFLAG_READ | IOFLAG_SKIP_BOM, IStorage::TYPE_ABSOLUTE);
|
IOHANDLE File = pStorage->OpenFile(pConfigName, IOFLAG_READ | IOFLAG_SKIP_BOM, IStorage::TYPE_ABSOLUTE);
|
||||||
std::vector<char *> vLines;
|
|
||||||
char *pSettings = NULL;
|
|
||||||
if(!File)
|
if(!File)
|
||||||
{
|
{
|
||||||
dbg_msg("config_store", "config '%s' not found", pConfigName);
|
dbg_msg("config_store", "config '%s' not found", pConfigName);
|
||||||
|
@ -22,6 +20,7 @@ void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
|
||||||
|
|
||||||
char *pLine;
|
char *pLine;
|
||||||
int TotalLength = 0;
|
int TotalLength = 0;
|
||||||
|
std::vector<char *> vLines;
|
||||||
while((pLine = LineReader.Get()))
|
while((pLine = LineReader.Get()))
|
||||||
{
|
{
|
||||||
int Length = str_length(pLine) + 1;
|
int Length = str_length(pLine) + 1;
|
||||||
|
@ -32,7 +31,7 @@ void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
|
||||||
}
|
}
|
||||||
io_close(File);
|
io_close(File);
|
||||||
|
|
||||||
pSettings = (char *)malloc(maximum(1, TotalLength));
|
char *pSettings = (char *)malloc(maximum(1, TotalLength));
|
||||||
int Offset = 0;
|
int Offset = 0;
|
||||||
for(auto &Line : vLines)
|
for(auto &Line : vLines)
|
||||||
{
|
{
|
||||||
|
@ -52,19 +51,18 @@ void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
|
||||||
bool FoundInfo = false;
|
bool FoundInfo = false;
|
||||||
for(int i = 0; i < Reader.NumItems(); i++)
|
for(int i = 0; i < Reader.NumItems(); i++)
|
||||||
{
|
{
|
||||||
int TypeID;
|
int Type, ID;
|
||||||
int ItemID;
|
int *pItem = (int *)Reader.GetItem(i, &Type, &ID);
|
||||||
int *pData = (int *)Reader.GetItem(i, &TypeID, &ItemID);
|
|
||||||
int Size = Reader.GetItemSize(i);
|
int Size = Reader.GetItemSize(i);
|
||||||
CMapItemInfoSettings MapInfo;
|
CMapItemInfoSettings MapInfo;
|
||||||
if(TypeID == MAPITEMTYPE_INFO && ItemID == 0)
|
if(Type == MAPITEMTYPE_INFO && ID == 0)
|
||||||
{
|
{
|
||||||
FoundInfo = true;
|
FoundInfo = true;
|
||||||
CMapItemInfoSettings *pInfo = (CMapItemInfoSettings *)pData;
|
CMapItemInfoSettings *pInfo = (CMapItemInfoSettings *)pItem;
|
||||||
if(Size >= (int)sizeof(CMapItemInfoSettings))
|
if(Size >= (int)sizeof(CMapItemInfoSettings))
|
||||||
{
|
{
|
||||||
MapInfo = *pInfo;
|
MapInfo = *pInfo;
|
||||||
pData = (int *)&MapInfo;
|
pItem = (int *)&MapInfo;
|
||||||
Size = sizeof(MapInfo);
|
Size = sizeof(MapInfo);
|
||||||
if(pInfo->m_Settings > -1)
|
if(pInfo->m_Settings > -1)
|
||||||
{
|
{
|
||||||
|
@ -83,7 +81,7 @@ void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
|
||||||
{
|
{
|
||||||
MapInfo = *pInfo;
|
MapInfo = *pInfo;
|
||||||
MapInfo.m_Settings = SettingsIndex;
|
MapInfo.m_Settings = SettingsIndex;
|
||||||
pData = (int *)&MapInfo;
|
pItem = (int *)&MapInfo;
|
||||||
Size = sizeof(MapInfo);
|
Size = sizeof(MapInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,11 +89,11 @@ void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
|
||||||
{
|
{
|
||||||
*(CMapItemInfo *)&MapInfo = *(CMapItemInfo *)pInfo;
|
*(CMapItemInfo *)&MapInfo = *(CMapItemInfo *)pInfo;
|
||||||
MapInfo.m_Settings = SettingsIndex;
|
MapInfo.m_Settings = SettingsIndex;
|
||||||
pData = (int *)&MapInfo;
|
pItem = (int *)&MapInfo;
|
||||||
Size = sizeof(MapInfo);
|
Size = sizeof(MapInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Writer.AddItem(TypeID, ItemID, Size, pData);
|
Writer.AddItem(Type, ID, Size, pItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!FoundInfo)
|
if(!FoundInfo)
|
||||||
|
|
Loading…
Reference in a new issue