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)
|
||||
{
|
||||
IOHANDLE File = pStorage->OpenFile(pConfigName, IOFLAG_READ | IOFLAG_SKIP_BOM, IStorage::TYPE_ABSOLUTE);
|
||||
std::vector<char *> vLines;
|
||||
char *pSettings = NULL;
|
||||
if(!File)
|
||||
{
|
||||
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;
|
||||
int TotalLength = 0;
|
||||
std::vector<char *> vLines;
|
||||
while((pLine = LineReader.Get()))
|
||||
{
|
||||
int Length = str_length(pLine) + 1;
|
||||
|
@ -32,7 +31,7 @@ void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
|
|||
}
|
||||
io_close(File);
|
||||
|
||||
pSettings = (char *)malloc(maximum(1, TotalLength));
|
||||
char *pSettings = (char *)malloc(maximum(1, TotalLength));
|
||||
int Offset = 0;
|
||||
for(auto &Line : vLines)
|
||||
{
|
||||
|
@ -52,19 +51,18 @@ void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
|
|||
bool FoundInfo = false;
|
||||
for(int i = 0; i < Reader.NumItems(); i++)
|
||||
{
|
||||
int TypeID;
|
||||
int ItemID;
|
||||
int *pData = (int *)Reader.GetItem(i, &TypeID, &ItemID);
|
||||
int Type, ID;
|
||||
int *pItem = (int *)Reader.GetItem(i, &Type, &ID);
|
||||
int Size = Reader.GetItemSize(i);
|
||||
CMapItemInfoSettings MapInfo;
|
||||
if(TypeID == MAPITEMTYPE_INFO && ItemID == 0)
|
||||
if(Type == MAPITEMTYPE_INFO && ID == 0)
|
||||
{
|
||||
FoundInfo = true;
|
||||
CMapItemInfoSettings *pInfo = (CMapItemInfoSettings *)pData;
|
||||
CMapItemInfoSettings *pInfo = (CMapItemInfoSettings *)pItem;
|
||||
if(Size >= (int)sizeof(CMapItemInfoSettings))
|
||||
{
|
||||
MapInfo = *pInfo;
|
||||
pData = (int *)&MapInfo;
|
||||
pItem = (int *)&MapInfo;
|
||||
Size = sizeof(MapInfo);
|
||||
if(pInfo->m_Settings > -1)
|
||||
{
|
||||
|
@ -83,7 +81,7 @@ void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
|
|||
{
|
||||
MapInfo = *pInfo;
|
||||
MapInfo.m_Settings = SettingsIndex;
|
||||
pData = (int *)&MapInfo;
|
||||
pItem = (int *)&MapInfo;
|
||||
Size = sizeof(MapInfo);
|
||||
}
|
||||
}
|
||||
|
@ -91,11 +89,11 @@ void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
|
|||
{
|
||||
*(CMapItemInfo *)&MapInfo = *(CMapItemInfo *)pInfo;
|
||||
MapInfo.m_Settings = SettingsIndex;
|
||||
pData = (int *)&MapInfo;
|
||||
pItem = (int *)&MapInfo;
|
||||
Size = sizeof(MapInfo);
|
||||
}
|
||||
}
|
||||
Writer.AddItem(TypeID, ItemID, Size, pData);
|
||||
Writer.AddItem(Type, ID, Size, pItem);
|
||||
}
|
||||
|
||||
if(!FoundInfo)
|
||||
|
|
Loading…
Reference in a new issue