Move/rename variable declarations in config_retrieve

This commit is contained in:
Robert Müller 2022-06-04 10:00:35 +02:00
parent 081881efcc
commit e8bd26857b

View file

@ -5,21 +5,21 @@
void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName) void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
{ {
CDataFileReader Map; CDataFileReader Reader;
if(!Map.Open(pStorage, pMapName, IStorage::TYPE_ABSOLUTE)) if(!Reader.Open(pStorage, pMapName, IStorage::TYPE_ABSOLUTE))
{ {
dbg_msg("config_retrieve", "error opening map '%s'", pMapName); dbg_msg("config_retrieve", "error opening map '%s'", pMapName);
return; return;
} }
bool ConfigFound = false; bool ConfigFound = false;
int Start, Num; int Start, Num;
Map.GetType(MAPITEMTYPE_INFO, &Start, &Num); Reader.GetType(MAPITEMTYPE_INFO, &Start, &Num);
for(int i = Start; i < Start + Num; i++) for(int i = Start; i < Start + Num; i++)
{ {
int ItemID; int ID;
CMapItemInfoSettings *pItem = (CMapItemInfoSettings *)Map.GetItem(i, 0, &ItemID); CMapItemInfoSettings *pItem = (CMapItemInfoSettings *)Reader.GetItem(i, nullptr, &ID);
int ItemSize = Map.GetItemSize(i); int ItemSize = Reader.GetItemSize(i);
if(!pItem || ItemID != 0) if(!pItem || ID != 0)
continue; continue;
if(ItemSize < (int)sizeof(CMapItemInfoSettings)) if(ItemSize < (int)sizeof(CMapItemInfoSettings))
@ -32,11 +32,12 @@ void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
if(!Config) if(!Config)
{ {
dbg_msg("config_retrieve", "error opening config for writing '%s'", pConfigName); dbg_msg("config_retrieve", "error opening config for writing '%s'", pConfigName);
Reader.Close();
return; return;
} }
int Size = Map.GetDataSize(pItem->m_Settings); int Size = Reader.GetDataSize(pItem->m_Settings);
char *pSettings = (char *)Map.GetData(pItem->m_Settings); char *pSettings = (char *)Reader.GetData(pItem->m_Settings);
char *pNext = pSettings; char *pNext = pSettings;
while(pNext < pSettings + Size) while(pNext < pSettings + Size)
{ {
@ -45,11 +46,11 @@ void Process(IStorage *pStorage, const char *pMapName, const char *pConfigName)
io_write_newline(Config); io_write_newline(Config);
pNext += StrSize; pNext += StrSize;
} }
Map.UnloadData(pItem->m_Settings); Reader.UnloadData(pItem->m_Settings);
io_close(Config); io_close(Config);
break; break;
} }
Map.Close(); Reader.Close();
if(!ConfigFound) if(!ConfigFound)
{ {
fs_remove(pConfigName); fs_remove(pConfigName);