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

@@ -63,9 +63,9 @@ void ExtractGameobjectModels()
return;
}
for (DBCFile::Iterator it = dbc.begin(); it != dbc.end(); ++it)
for (const auto & it : dbc)
{
path = it->getString(1);
path = it.getString(1);
if (path.length() < 4)
continue;
@@ -97,7 +97,7 @@ void ExtractGameobjectModels()
if (result)
{
uint32 displayId = it->getUInt(0);
uint32 displayId = it.getUInt(0);
uint32 path_length = strlen(name);
fwrite(&displayId, sizeof(uint32), 1, model_list);
fwrite(&path_length, sizeof(uint32), 1, model_list);

View File

@@ -54,9 +54,9 @@ MPQFile::MPQFile(const char* filename):
pointer(0),
size(0)
{
for (ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end(); ++i)
for (auto & gOpenArchive : gOpenArchives)
{
mpq_archive* mpq_a = (*i)->mpq_a;
mpq_archive* mpq_a = gOpenArchive->mpq_a;
uint32 filenum;
if (libmpq__file_number(mpq_a, filename, &filenum)) continue;

View File

@@ -152,9 +152,8 @@ bool ExtractSingleWmo(std::string& fname)
{
char cpy[4];
memcpy(cpy, rchr, 4);
for (int i = 0; i < 4; ++i)
for (int m : cpy)
{
int m = cpy[i];
if (isdigit(m))
p++;
}
@@ -314,27 +313,27 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames)
searchLocales.emplace_back("esMX");
searchLocales.emplace_back("ruRU");
for (std::vector<std::string>::iterator i = searchLocales.begin(); i != searchLocales.end(); ++i)
for (auto & searchLocale : searchLocales)
{
std::string localePath = in_path + *i;
std::string localePath = in_path + searchLocale;
// check if locale exists:
struct stat status;
if (stat(localePath.c_str(), &status))
continue;
if ((status.st_mode & S_IFDIR) == 0)
continue;
printf("Found locale '%s'\n", i->c_str());
locales.push_back(*i);
printf("Found locale '%s'\n", searchLocale.c_str());
locales.push_back(searchLocale);
}
printf("\n");
// open locale expansion and common files
printf("Adding data files from locale directories.\n");
for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); ++i)
for (auto & locale : locales)
{
pArchiveNames.push_back(in_path + *i + "/locale-" + *i + ".MPQ");
pArchiveNames.push_back(in_path + *i + "/expansion-locale-" + *i + ".MPQ");
pArchiveNames.push_back(in_path + *i + "/lichking-locale-" + *i + ".MPQ");
pArchiveNames.push_back(in_path + locale + "/locale-" + locale + ".MPQ");
pArchiveNames.push_back(in_path + locale + "/expansion-locale-" + locale + ".MPQ");
pArchiveNames.push_back(in_path + locale + "/lichking-locale-" + locale + ".MPQ");
}
// open expansion and common files
@@ -357,10 +356,10 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames)
// now, scan for the patch levels in locale dirs
printf("Scanning patch levels from locale directories.\n");
bool foundOne = false;
for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); ++i)
for (auto & locale : locales)
{
printf("Locale: %s\n", i->c_str());
int ret2 = snprintf(path, 512, "%s%s/patch-%s", input_path, i->c_str(), i->c_str());
printf("Locale: %s\n", locale.c_str());
int ret2 = snprintf(path, 512, "%s%s/patch-%s", input_path, locale.c_str(), locale.c_str());
if (ret2 < 0)
{
printf("Error when formatting string");
@@ -481,9 +480,9 @@ int main(int argc, char** argv)
// prepare archive name list
std::vector<std::string> archiveNames;
fillArchiveNameVector(archiveNames);
for (size_t i = 0; i < archiveNames.size(); ++i)
for (auto & archiveName : archiveNames)
{
MPQArchive* archive = new MPQArchive(archiveNames[i].c_str());
MPQArchive* archive = new MPQArchive(archiveName.c_str());
if (gOpenArchives.empty() || gOpenArchives.front() != archive)
delete archive;
}