mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
refactor(Core): apply clang-tidy modernize-loop-convert (#3822)
This commit is contained in:
@@ -369,7 +369,7 @@ protected:
|
||||
maxObjects(0xFFFFFFFF), sumDepth(0), minDepth(0x0FFFFFFF),
|
||||
maxDepth(0xFFFFFFFF), numBVH2(0)
|
||||
{
|
||||
for (int i = 0; i < 6; ++i) numLeavesN[i] = 0;
|
||||
for (int & i : numLeavesN) i = 0;
|
||||
}
|
||||
|
||||
void updateInner() { numNodes++; }
|
||||
|
||||
@@ -239,32 +239,32 @@ inline bool isNumericOrSpace(wchar_t wchar)
|
||||
|
||||
inline bool isBasicLatinString(const std::wstring& wstr, bool numericOrSpace)
|
||||
{
|
||||
for (size_t i = 0; i < wstr.size(); ++i)
|
||||
if (!isBasicLatinCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
|
||||
for (wchar_t i : wstr)
|
||||
if (!isBasicLatinCharacter(i) && (!numericOrSpace || !isNumericOrSpace(i)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool isExtendedLatinString(const std::wstring& wstr, bool numericOrSpace)
|
||||
{
|
||||
for (size_t i = 0; i < wstr.size(); ++i)
|
||||
if (!isExtendedLatinCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
|
||||
for (wchar_t i : wstr)
|
||||
if (!isExtendedLatinCharacter(i) && (!numericOrSpace || !isNumericOrSpace(i)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool isCyrillicString(const std::wstring& wstr, bool numericOrSpace)
|
||||
{
|
||||
for (size_t i = 0; i < wstr.size(); ++i)
|
||||
if (!isCyrillicCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
|
||||
for (wchar_t i : wstr)
|
||||
if (!isCyrillicCharacter(i) && (!numericOrSpace || !isNumericOrSpace(i)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool isEastAsianString(const std::wstring& wstr, bool numericOrSpace)
|
||||
{
|
||||
for (size_t i = 0; i < wstr.size(); ++i)
|
||||
if (!isEastAsianCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
|
||||
for (wchar_t i : wstr)
|
||||
if (!isEastAsianCharacter(i) && (!numericOrSpace || !isNumericOrSpace(i)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ public:
|
||||
AuctionHouseObject() { next = AuctionsMap.begin(); }
|
||||
~AuctionHouseObject()
|
||||
{
|
||||
for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
|
||||
delete itr->second;
|
||||
for (auto & itr : AuctionsMap)
|
||||
delete itr.second;
|
||||
}
|
||||
|
||||
typedef std::map<uint32, AuctionEntry*> AuctionEntryMap;
|
||||
|
||||
@@ -229,10 +229,8 @@ public:
|
||||
if (threatList.empty())
|
||||
return;
|
||||
|
||||
for (ThreatContainer::StorageType::iterator itr = threatList.begin(); itr != threatList.end(); ++itr)
|
||||
for (auto ref : threatList)
|
||||
{
|
||||
HostileReference* ref = (*itr);
|
||||
|
||||
if (predicate(ref->getTarget()))
|
||||
{
|
||||
ref->setThreat(0);
|
||||
|
||||
@@ -390,8 +390,8 @@ struct TrainerSpell
|
||||
{
|
||||
TrainerSpell() : spell(0), spellCost(0), reqSkill(0), reqSkillValue(0), reqLevel(0)
|
||||
{
|
||||
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||
learnedSpell[i] = 0;
|
||||
for (unsigned int & i : learnedSpell)
|
||||
i = 0;
|
||||
}
|
||||
|
||||
uint32 spell;
|
||||
|
||||
@@ -844,8 +844,8 @@ public:
|
||||
void AddToSkillupList(uint32 PlayerGuidLow) { m_SkillupList.push_back(PlayerGuidLow); }
|
||||
[[nodiscard]] bool IsInSkillupList(uint32 PlayerGuidLow) const
|
||||
{
|
||||
for (std::list<uint32>::const_iterator i = m_SkillupList.begin(); i != m_SkillupList.end(); ++i)
|
||||
if (*i == PlayerGuidLow)
|
||||
for (unsigned int i : m_SkillupList)
|
||||
if (i == PlayerGuidLow)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -264,7 +264,7 @@ struct PlayerClassInfo
|
||||
|
||||
struct PlayerLevelInfo
|
||||
{
|
||||
PlayerLevelInfo() { for (uint8 i = 0; i < MAX_STATS; ++i) stats[i] = 0; }
|
||||
PlayerLevelInfo() { for (unsigned char & stat : stats) stat = 0; }
|
||||
|
||||
uint8 stats[MAX_STATS];
|
||||
};
|
||||
@@ -689,8 +689,8 @@ struct EquipmentSet
|
||||
{
|
||||
EquipmentSet() : Guid(0), IgnoreMask(0), state(EQUIPMENT_SET_NEW)
|
||||
{
|
||||
for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
|
||||
Items[i] = 0;
|
||||
for (unsigned int & Item : Items)
|
||||
Item = 0;
|
||||
}
|
||||
|
||||
uint64 Guid;
|
||||
@@ -1876,8 +1876,8 @@ public:
|
||||
{
|
||||
Unit::SetPvP(state);
|
||||
if (!m_Controlled.empty())
|
||||
for (ControlSet::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
|
||||
(*itr)->SetPvP(state);
|
||||
for (auto itr : m_Controlled)
|
||||
itr->SetPvP(state);
|
||||
}
|
||||
void UpdatePvP(bool state, bool _override = false);
|
||||
void UpdateZone(uint32 newZone, uint32 newArea);
|
||||
@@ -2272,8 +2272,8 @@ public:
|
||||
|
||||
[[nodiscard]] bool InBattlegroundQueue() const
|
||||
{
|
||||
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (m_bgBattlegroundQueueID[i] != BATTLEGROUND_QUEUE_NONE)
|
||||
for (auto i : m_bgBattlegroundQueueID)
|
||||
if (i != BATTLEGROUND_QUEUE_NONE)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -2308,18 +2308,18 @@ public:
|
||||
|
||||
bool HasFreeBattlegroundQueueId()
|
||||
{
|
||||
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (m_bgBattlegroundQueueID[i] == BATTLEGROUND_QUEUE_NONE)
|
||||
for (auto & i : m_bgBattlegroundQueueID)
|
||||
if (i == BATTLEGROUND_QUEUE_NONE)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void RemoveBattlegroundQueueId(BattlegroundQueueTypeId val)
|
||||
{
|
||||
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
|
||||
if (m_bgBattlegroundQueueID[i] == val)
|
||||
for (auto & i : m_bgBattlegroundQueueID)
|
||||
if (i == val)
|
||||
{
|
||||
m_bgBattlegroundQueueID[i] = BATTLEGROUND_QUEUE_NONE;
|
||||
i = BATTLEGROUND_QUEUE_NONE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -3031,10 +3031,8 @@ template <class T> T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T& bas
|
||||
if (m_spellModTakingSpell)
|
||||
spell = m_spellModTakingSpell;
|
||||
|
||||
for (SpellModList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr)
|
||||
for (auto mod : m_spellMods[op])
|
||||
{
|
||||
SpellModifier* mod = *itr;
|
||||
|
||||
// Charges can be set only for mods with auras
|
||||
if (!mod->ownerAura)
|
||||
ASSERT(mod->charges == 0);
|
||||
|
||||
@@ -511,7 +511,7 @@ typedef std::pair<QuestRelations::const_iterator, QuestRelations::const_iterator
|
||||
|
||||
struct PetLevelInfo
|
||||
{
|
||||
PetLevelInfo() : health(0), mana(0), armor(0), min_dmg(0), max_dmg(0) { for (uint8 i = 0; i < MAX_STATS; ++i) stats[i] = 0; }
|
||||
PetLevelInfo() : health(0), mana(0), armor(0), min_dmg(0), max_dmg(0) { for (unsigned short & stat : stats) stat = 0; }
|
||||
|
||||
uint16 stats[MAX_STATS];
|
||||
uint16 health;
|
||||
@@ -1076,9 +1076,9 @@ public:
|
||||
if (map_itr == _mailLevelRewardStore.end())
|
||||
return nullptr;
|
||||
|
||||
for (MailLevelRewardList::const_iterator set_itr = map_itr->second.begin(); set_itr != map_itr->second.end(); ++set_itr)
|
||||
if (set_itr->raceMask & raceMask)
|
||||
return &*set_itr;
|
||||
for (const auto & set_itr : map_itr->second)
|
||||
if (set_itr.raceMask & raceMask)
|
||||
return &set_itr;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -906,11 +906,11 @@ struct FactionTemplateEntry
|
||||
|
||||
if (entry.faction)
|
||||
{
|
||||
for (uint8 i = 0; i < MAX_FACTION_RELATIONS; ++i)
|
||||
if (enemyFaction[i] == entry.faction)
|
||||
for (unsigned int i : enemyFaction)
|
||||
if (i == entry.faction)
|
||||
return false;
|
||||
for (uint8 i = 0; i < MAX_FACTION_RELATIONS; ++i)
|
||||
if (friendFaction[i] == entry.faction)
|
||||
for (unsigned int i : friendFaction)
|
||||
if (i == entry.faction)
|
||||
return true;
|
||||
}
|
||||
return (friendlyMask & entry.ourMask) || (ourMask & entry.friendlyMask);
|
||||
@@ -919,11 +919,11 @@ struct FactionTemplateEntry
|
||||
{
|
||||
if (entry.faction)
|
||||
{
|
||||
for (uint8 i = 0; i < MAX_FACTION_RELATIONS; ++i)
|
||||
if (enemyFaction[i] == entry.faction)
|
||||
for (unsigned int i : enemyFaction)
|
||||
if (i == entry.faction)
|
||||
return true;
|
||||
for (uint8 i = 0; i < MAX_FACTION_RELATIONS; ++i)
|
||||
if (friendFaction[i] == entry.faction)
|
||||
for (unsigned int i : friendFaction)
|
||||
if (i == entry.faction)
|
||||
return false;
|
||||
}
|
||||
return (hostileMask & entry.ourMask) != 0;
|
||||
@@ -931,8 +931,8 @@ struct FactionTemplateEntry
|
||||
[[nodiscard]] bool IsHostileToPlayers() const { return (hostileMask & FACTION_MASK_PLAYER) != 0; }
|
||||
[[nodiscard]] bool IsNeutralToAll() const
|
||||
{
|
||||
for (uint8 i = 0; i < MAX_FACTION_RELATIONS; ++i)
|
||||
if (enemyFaction[i] != 0)
|
||||
for (unsigned int i : enemyFaction)
|
||||
if (i != 0)
|
||||
return false;
|
||||
return hostileMask == 0 && friendlyMask == 0;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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_t filenum;
|
||||
if (libmpq__file_number(mpq_a, filename, &filenum)) continue;
|
||||
|
||||
@@ -75,10 +75,10 @@ namespace MMAP
|
||||
/**************************************************************************/
|
||||
MapBuilder::~MapBuilder()
|
||||
{
|
||||
for (TileList::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it)
|
||||
for (auto & m_tile : m_tiles)
|
||||
{
|
||||
(*it).m_tiles->clear();
|
||||
delete (*it).m_tiles;
|
||||
m_tile.m_tiles->clear();
|
||||
delete m_tile.m_tiles;
|
||||
}
|
||||
|
||||
delete m_terrainBuilder;
|
||||
@@ -94,9 +94,9 @@ namespace MMAP
|
||||
|
||||
printf("Discovering maps... ");
|
||||
getDirContents(files, "maps");
|
||||
for (uint32 i = 0; i < files.size(); ++i)
|
||||
for (auto & file : files)
|
||||
{
|
||||
mapID = uint32(atoi(files[i].substr(0, files[i].size() - 8).c_str()));
|
||||
mapID = uint32(atoi(file.substr(0, file.size() - 8).c_str()));
|
||||
if (std::find(m_tiles.begin(), m_tiles.end(), mapID) == m_tiles.end())
|
||||
{
|
||||
m_tiles.emplace_back(MapTiles(mapID, new std::set<uint32>));
|
||||
@@ -106,9 +106,9 @@ namespace MMAP
|
||||
|
||||
files.clear();
|
||||
getDirContents(files, "vmaps", "*.vmtree");
|
||||
for (uint32 i = 0; i < files.size(); ++i)
|
||||
for (auto & file : files)
|
||||
{
|
||||
mapID = uint32(atoi(files[i].substr(0, files[i].size() - 7).c_str()));
|
||||
mapID = uint32(atoi(file.substr(0, file.size() - 7).c_str()));
|
||||
if (std::find(m_tiles.begin(), m_tiles.end(), mapID) == m_tiles.end())
|
||||
{
|
||||
m_tiles.emplace_back(MapTiles(mapID, new std::set<uint32>));
|
||||
@@ -119,20 +119,20 @@ namespace MMAP
|
||||
|
||||
count = 0;
|
||||
printf("Discovering tiles... ");
|
||||
for (TileList::iterator itr = m_tiles.begin(); itr != m_tiles.end(); ++itr)
|
||||
for (auto & m_tile : m_tiles)
|
||||
{
|
||||
std::set<uint32>* tiles = (*itr).m_tiles;
|
||||
mapID = (*itr).m_mapId;
|
||||
std::set<uint32>* tiles = m_tile.m_tiles;
|
||||
mapID = m_tile.m_mapId;
|
||||
|
||||
sprintf(filter, "%03u*.vmtile", mapID);
|
||||
files.clear();
|
||||
getDirContents(files, "vmaps", filter);
|
||||
for (uint32 i = 0; i < files.size(); ++i)
|
||||
for (auto & file : files)
|
||||
{
|
||||
fsize = files[i].size();
|
||||
fsize = file.size();
|
||||
|
||||
tileY = uint32(atoi(files[i].substr(fsize - 12, 2).c_str()));
|
||||
tileX = uint32(atoi(files[i].substr(fsize - 9, 2).c_str()));
|
||||
tileY = uint32(atoi(file.substr(fsize - 12, 2).c_str()));
|
||||
tileX = uint32(atoi(file.substr(fsize - 9, 2).c_str()));
|
||||
tileID = StaticMapTree::packTileID(tileY, tileX);
|
||||
|
||||
tiles->insert(tileID);
|
||||
@@ -142,12 +142,12 @@ namespace MMAP
|
||||
sprintf(filter, "%03u*", mapID);
|
||||
files.clear();
|
||||
getDirContents(files, "maps", filter);
|
||||
for (uint32 i = 0; i < files.size(); ++i)
|
||||
for (auto & file : files)
|
||||
{
|
||||
fsize = files[i].size();
|
||||
fsize = file.size();
|
||||
|
||||
tileY = uint32(atoi(files[i].substr(fsize - 8, 2).c_str()));
|
||||
tileX = uint32(atoi(files[i].substr(fsize - 6, 2).c_str()));
|
||||
tileY = uint32(atoi(file.substr(fsize - 8, 2).c_str()));
|
||||
tileX = uint32(atoi(file.substr(fsize - 6, 2).c_str()));
|
||||
tileID = StaticMapTree::packTileID(tileX, tileY);
|
||||
|
||||
if (tiles->insert(tileID).second)
|
||||
@@ -171,10 +171,10 @@ namespace MMAP
|
||||
printf("found %u.\n\n", count);
|
||||
|
||||
// Calculate tiles to process in total
|
||||
for (TileList::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it)
|
||||
for (auto & m_tile : m_tiles)
|
||||
{
|
||||
if (!shouldSkipMap(it->m_mapId))
|
||||
m_totalTiles += it->m_tiles->size();
|
||||
if (!shouldSkipMap(m_tile.m_mapId))
|
||||
m_totalTiles += m_tile.m_tiles->size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,9 +205,9 @@ namespace MMAP
|
||||
return a.m_tiles->size() > b.m_tiles->size();
|
||||
});
|
||||
|
||||
for (TileList::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it)
|
||||
for (auto & m_tile : m_tiles)
|
||||
{
|
||||
uint32 mapId = it->m_mapId;
|
||||
uint32 mapId = m_tile.m_mapId;
|
||||
if (!shouldSkipMap(mapId))
|
||||
{
|
||||
if (threads > 0)
|
||||
@@ -423,14 +423,14 @@ namespace MMAP
|
||||
|
||||
// now start building mmtiles for each tile
|
||||
printf("[Map %03i] We have %u tiles. \n", mapID, (unsigned int)tiles->size());
|
||||
for (std::set<uint32>::iterator it = tiles->begin(); it != tiles->end(); ++it)
|
||||
for (unsigned int tile : *tiles)
|
||||
{
|
||||
// percentageDone - increment tiles built
|
||||
m_totalTilesBuilt++;
|
||||
uint32 tileX, tileY;
|
||||
|
||||
// unpack tile coords
|
||||
StaticMapTree::unpackTileID((*it), tileX, tileY);
|
||||
StaticMapTree::unpackTileID(tile, tileX, tileY);
|
||||
|
||||
if (shouldSkipTile(mapID, tileX, tileY))
|
||||
continue;
|
||||
@@ -503,9 +503,9 @@ namespace MMAP
|
||||
/*** calculate bounds of map ***/
|
||||
|
||||
uint32 tileXMin = 64, tileYMin = 64, tileXMax = 0, tileYMax = 0, tileX, tileY;
|
||||
for (std::set<uint32>::iterator it = tiles->begin(); it != tiles->end(); ++it)
|
||||
for (unsigned int tile : *tiles)
|
||||
{
|
||||
StaticMapTree::unpackTileID(*it, tileX, tileY);
|
||||
StaticMapTree::unpackTileID(tile, tileX, tileY);
|
||||
|
||||
if (tileX > tileXMax)
|
||||
tileXMax = tileX;
|
||||
|
||||
@@ -686,14 +686,14 @@ namespace MMAP
|
||||
position.x -= 32 * GRID_SIZE;
|
||||
position.y -= 32 * GRID_SIZE;
|
||||
|
||||
for (std::vector<GroupModel>::iterator it = groupModels.begin(); it != groupModels.end(); ++it)
|
||||
for (auto & groupModel : groupModels)
|
||||
{
|
||||
std::vector<G3D::Vector3> tempVertices;
|
||||
std::vector<G3D::Vector3> transformedVertices;
|
||||
std::vector<MeshTriangle> tempTriangles;
|
||||
WmoLiquid* liquid = nullptr;
|
||||
|
||||
it->getMeshData(tempVertices, tempTriangles, liquid);
|
||||
groupModel.getMeshData(tempVertices, tempTriangles, liquid);
|
||||
|
||||
// first handle collision mesh
|
||||
transform(tempVertices, transformedVertices, scale, rotation, position);
|
||||
@@ -778,9 +778,9 @@ namespace MMAP
|
||||
}
|
||||
|
||||
uint32 liqOffset = meshData.liquidVerts.size() / 3;
|
||||
for (uint32 j = 0; j < liqVerts.size(); ++j)
|
||||
for (auto & liqVert : liqVerts)
|
||||
{
|
||||
meshData.liquidVerts.append(liqVerts[j].y, liqVerts[j].z, liqVerts[j].x);
|
||||
meshData.liquidVerts.append(liqVert.y, liqVert.z, liqVert.x);
|
||||
}
|
||||
|
||||
for (uint32 j = 0; j < liqTris.size() / 3; ++j)
|
||||
@@ -802,10 +802,10 @@ namespace MMAP
|
||||
/**************************************************************************/
|
||||
void TerrainBuilder::transform(std::vector<G3D::Vector3>& source, std::vector<G3D::Vector3>& transformedVertices, float scale, G3D::Matrix3& rotation, G3D::Vector3& position)
|
||||
{
|
||||
for (std::vector<G3D::Vector3>::iterator it = source.begin(); it != source.end(); ++it)
|
||||
for (auto & it : source)
|
||||
{
|
||||
// apply tranform, then mirror along the horizontal axes
|
||||
G3D::Vector3 v((*it) * rotation * scale + position);
|
||||
G3D::Vector3 v(it * rotation * scale + position);
|
||||
v.x *= -1.f;
|
||||
v.y *= -1.f;
|
||||
transformedVertices.push_back(v);
|
||||
@@ -815,11 +815,11 @@ namespace MMAP
|
||||
/**************************************************************************/
|
||||
void TerrainBuilder::copyVertices(std::vector<G3D::Vector3>& source, G3D::Array<float>& dest)
|
||||
{
|
||||
for (std::vector<G3D::Vector3>::iterator it = source.begin(); it != source.end(); ++it)
|
||||
for (auto & it : source)
|
||||
{
|
||||
dest.push_back((*it).y);
|
||||
dest.push_back((*it).z);
|
||||
dest.push_back((*it).x);
|
||||
dest.push_back(it.y);
|
||||
dest.push_back(it.z);
|
||||
dest.push_back(it.x);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -828,20 +828,20 @@ namespace MMAP
|
||||
{
|
||||
if (flip)
|
||||
{
|
||||
for (std::vector<MeshTriangle>::iterator it = source.begin(); it != source.end(); ++it)
|
||||
for (auto & it : source)
|
||||
{
|
||||
dest.push_back((*it).idx2 + offset);
|
||||
dest.push_back((*it).idx1 + offset);
|
||||
dest.push_back((*it).idx0 + offset);
|
||||
dest.push_back(it.idx2 + offset);
|
||||
dest.push_back(it.idx1 + offset);
|
||||
dest.push_back(it.idx0 + offset);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (std::vector<MeshTriangle>::iterator it = source.begin(); it != source.end(); ++it)
|
||||
for (auto & it : source)
|
||||
{
|
||||
dest.push_back((*it).idx0 + offset);
|
||||
dest.push_back((*it).idx1 + offset);
|
||||
dest.push_back((*it).idx2 + offset);
|
||||
dest.push_back(it.idx0 + offset);
|
||||
dest.push_back(it.idx1 + offset);
|
||||
dest.push_back(it.idx2 + offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user