refactor(Core): apply clang-tidy modernize-loop-convert (#3822)

This commit is contained in:
Francesco Borzì
2020-12-07 19:04:19 +01:00
committed by GitHub
parent 0b7b36f20c
commit 0b8ec1f6ee
16 changed files with 125 additions and 130 deletions

View File

@@ -406,11 +406,11 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
//============================================
bool fullAreaData = false;
uint32 areaId = area_ids[0][0];
for (int y = 0; y < ADT_CELLS_PER_GRID; ++y)
for (auto & area_id : area_ids)
{
for (int x = 0; x < ADT_CELLS_PER_GRID; ++x)
{
if (area_ids[y][x] != areaId)
if (area_id[x] != areaId)
{
fullAreaData = true;
break;
@@ -511,11 +511,11 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
//============================================
float maxHeight = -20000;
float minHeight = 20000;
for (int y = 0; y < ADT_GRID_SIZE; y++)
for (auto & y : V8)
{
for (int x = 0; x < ADT_GRID_SIZE; x++)
{
float h = V8[y][x];
float h = y[x];
if (maxHeight < h) maxHeight = h;
if (minHeight > h) minHeight = h;
}
@@ -533,10 +533,10 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
// Check for allow limit minimum height (not store height in deep ochean - allow save some memory)
if (CONF_allow_height_limit && minHeight < CONF_use_minHeight)
{
for (int y = 0; y < ADT_GRID_SIZE; y++)
for (auto & y : V8)
for (int x = 0; x < ADT_GRID_SIZE; x++)
if (V8[y][x] < CONF_use_minHeight)
V8[y][x] = CONF_use_minHeight;
if (y[x] < CONF_use_minHeight)
y[x] = CONF_use_minHeight;
for (int y = 0; y <= ADT_GRID_SIZE; y++)
for (int x = 0; x <= ADT_GRID_SIZE; x++)
if (V9[y][x] < CONF_use_minHeight)
@@ -1006,13 +1006,13 @@ void ExtractDBCFiles(int locale, bool basicLocale)
std::set<std::string> dbcfiles;
// get DBC file list
for (ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end(); ++i)
for (auto & gOpenArchive : gOpenArchives)
{
vector<string> files;
(*i)->GetFileListTo(files);
for (vector<string>::iterator iter = files.begin(); iter != files.end(); ++iter)
if (iter->rfind(".dbc") == iter->length() - strlen(".dbc"))
dbcfiles.insert(*iter);
gOpenArchive->GetFileListTo(files);
for (auto & file : files)
if (file.rfind(".dbc") == file.length() - strlen(".dbc"))
dbcfiles.insert(file);
}
std::string path = output_path;
@@ -1035,15 +1035,15 @@ void ExtractDBCFiles(int locale, bool basicLocale)
// extract DBCs
uint32 count = 0;
for (set<string>::iterator iter = dbcfiles.begin(); iter != dbcfiles.end(); ++iter)
for (const auto & dbcfile : dbcfiles)
{
string filename = path;
filename += (iter->c_str() + strlen("DBFilesClient\\"));
filename += (dbcfile.c_str() + strlen("DBFilesClient\\"));
if (FileExists(filename.c_str()))
continue;
if (ExtractFile(iter->c_str(), filename))
if (ExtractFile(dbcfile.c_str(), filename))
++count;
}
printf("Extracted %u DBC files\n\n", count);
@@ -1082,7 +1082,7 @@ void LoadCommonMPQFiles()
inline void CloseMPQFiles()
{
for (ArchiveSet::iterator j = gOpenArchives.begin(); j != gOpenArchives.end(); ++j) (*j)->close();
for (auto & gOpenArchive : gOpenArchives) gOpenArchive->close();
gOpenArchives.clear();
}