diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/Collision/Management/MMapManager.cpp | 4 | ||||
-rw-r--r-- | src/common/Collision/Management/VMapManager2.cpp | 8 | ||||
-rw-r--r-- | src/common/Collision/Maps/MapTree.cpp | 8 | ||||
-rw-r--r-- | src/common/Logging/Log.cpp | 4 | ||||
-rw-r--r-- | src/common/Logging/Logger.cpp | 6 | ||||
-rw-r--r-- | src/common/Utilities/EventMap.cpp | 12 | ||||
-rw-r--r-- | src/common/Utilities/Util.cpp | 14 | ||||
-rw-r--r-- | src/server/database/Database/QueryHolder.cpp | 4 | ||||
-rw-r--r-- | src/server/game/AI/CoreAI/CombatAI.cpp | 29 | ||||
-rw-r--r-- | src/tools/vmap4_assembler/TileAssembler.cpp | 8 |
10 files changed, 48 insertions, 49 deletions
diff --git a/src/common/Collision/Management/MMapManager.cpp b/src/common/Collision/Management/MMapManager.cpp index fc5f013a310..da3bc28e4f6 100644 --- a/src/common/Collision/Management/MMapManager.cpp +++ b/src/common/Collision/Management/MMapManager.cpp @@ -28,8 +28,8 @@ namespace MMAP // ######################## MMapManager ######################## MMapManager::~MMapManager() { - for (MMapDataSet::iterator i = loadedMMaps.begin(); i != loadedMMaps.end(); ++i) - delete i->second; + for (std::pair<uint32 const, MMapData*>& loadedMMap : loadedMMaps) + delete loadedMMap.second; // by now we should not have maps loaded // if we had, tiles in MMapData->mmapLoadedTiles, their actual data is lost! diff --git a/src/common/Collision/Management/VMapManager2.cpp b/src/common/Collision/Management/VMapManager2.cpp index d235b458681..d86b254604a 100644 --- a/src/common/Collision/Management/VMapManager2.cpp +++ b/src/common/Collision/Management/VMapManager2.cpp @@ -59,11 +59,11 @@ namespace VMAP VMapManager2::~VMapManager2() { - for (auto i = iInstanceMapTrees.begin(); i != iInstanceMapTrees.end(); ++i) - delete i->second; + for (std::pair<uint32 const, StaticMapTree*>& iInstanceMapTree : iInstanceMapTrees) + delete iInstanceMapTree.second; - for (auto i = iLoadedModelFiles.begin(); i != iLoadedModelFiles.end(); ++i) - delete i->second; + for (std::pair<std::string const, ManagedModel*>& iLoadedModelFile : iLoadedModelFiles) + delete iLoadedModelFile.second; } InstanceTreeMap::const_iterator VMapManager2::GetMapTree(uint32 mapId) const diff --git a/src/common/Collision/Maps/MapTree.cpp b/src/common/Collision/Maps/MapTree.cpp index f7023d82c65..8aca904092f 100644 --- a/src/common/Collision/Maps/MapTree.cpp +++ b/src/common/Collision/Maps/MapTree.cpp @@ -351,12 +351,12 @@ namespace VMAP void StaticMapTree::UnloadMap(VMapManager2* vm) { - for (loadedSpawnMap::iterator i = iLoadedSpawns.begin(); i != iLoadedSpawns.end(); ++i) + for (std::pair<uint32 const, uint32>& iLoadedSpawn : iLoadedSpawns) { - for (uint32 refCount = 0; refCount < i->second; ++refCount) - vm->releaseModelInstance(iTreeValues[i->first].getWorldModel()->GetName()); + for (uint32 refCount = 0; refCount < iLoadedSpawn.second; ++refCount) + vm->releaseModelInstance(iTreeValues[iLoadedSpawn.first].getWorldModel()->GetName()); - iTreeValues[i->first].setUnloaded(); + iTreeValues[iLoadedSpawn.first].setUnloaded(); } iLoadedSpawns.clear(); iLoadedTiles.clear(); diff --git a/src/common/Logging/Log.cpp b/src/common/Logging/Log.cpp index 169dfbe80ba..59baea2c143 100644 --- a/src/common/Logging/Log.cpp +++ b/src/common/Logging/Log.cpp @@ -339,8 +339,8 @@ void Log::outCharDump(char const* str, uint32 accountId, uint64 guid, char const void Log::SetRealmId(uint32 id) { - for (auto it = appenders.begin(); it != appenders.end(); ++it) - it->second->setRealmId(id); + for (std::pair<uint8 const, std::unique_ptr<Appender>>& appender : appenders) + appender.second->setRealmId(id); } void Log::Close() diff --git a/src/common/Logging/Logger.cpp b/src/common/Logging/Logger.cpp index 8e2927c08bd..63653770ade 100644 --- a/src/common/Logging/Logger.cpp +++ b/src/common/Logging/Logger.cpp @@ -54,7 +54,7 @@ void Logger::write(LogMessage* message) const return; } - for (auto it = appenders.begin(); it != appenders.end(); ++it) - if (it->second) - it->second->write(message); + for (std::pair<uint8 const, Appender*> const& appender : appenders) + if (appender.second) + appender.second->write(message); } diff --git a/src/common/Utilities/EventMap.cpp b/src/common/Utilities/EventMap.cpp index 3f6a92869bf..5df8de92c43 100644 --- a/src/common/Utilities/EventMap.cpp +++ b/src/common/Utilities/EventMap.cpp @@ -135,18 +135,18 @@ uint32 EventMap::GetNextEventTime(uint32 eventId) const if (Empty()) return 0; - for (EventStore::const_iterator itr = _eventMap.begin(); itr != _eventMap.end(); ++itr) - if (eventId == (itr->second & 0x0000FFFF)) - return itr->first; + for (std::pair<uint32 const, uint32> const& itr : _eventMap) + if (eventId == (itr.second & 0x0000FFFF)) + return itr.first; return 0; } uint32 EventMap::GetTimeUntilEvent(uint32 eventId) const { - for (EventStore::const_iterator itr = _eventMap.begin(); itr != _eventMap.end(); ++itr) - if (eventId == (itr->second & 0x0000FFFF)) - return itr->first - _time; + for (std::pair<uint32 const, uint32> const& itr : _eventMap) + if (eventId == (itr.second & 0x0000FFFF)) + return itr.first - _time; return std::numeric_limits<uint32>::max(); } diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index 9322cad14ac..c8898faeed3 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -220,16 +220,16 @@ int64 MoneyStringToMoney(std::string const& moneyString) return 0; // Bad format Tokenizer tokens(moneyString, ' '); - for (Tokenizer::const_iterator itr = tokens.begin(); itr != tokens.end(); ++itr) + for (char const* token : tokens) { - std::string tokenString(*itr); + std::string tokenString(token); size_t gCount = std::count(tokenString.begin(), tokenString.end(), 'g'); size_t sCount = std::count(tokenString.begin(), tokenString.end(), 's'); size_t cCount = std::count(tokenString.begin(), tokenString.end(), 'c'); if (gCount + sCount + cCount != 1) return 0; - uint64 amount = strtoull(*itr, nullptr, 10); + uint64 amount = strtoull(token, nullptr, 10); if (gCount == 1) money += amount * 100 * 100; else if (sCount == 1) @@ -247,16 +247,16 @@ uint32 TimeStringToSecs(std::string const& timestring) uint32 buffer = 0; uint32 multiplier = 0; - for (std::string::const_iterator itr = timestring.begin(); itr != timestring.end(); ++itr) + for (char itr : timestring) { - if (isdigit(*itr)) + if (isdigit(itr)) { buffer *= 10; - buffer += *itr - '0'; + buffer += itr - '0'; } else { - switch (*itr) + switch (itr) { case 'd': multiplier = DAY; break; case 'h': multiplier = HOUR; break; diff --git a/src/server/database/Database/QueryHolder.cpp b/src/server/database/Database/QueryHolder.cpp index 92877c97ded..dacd12913da 100644 --- a/src/server/database/Database/QueryHolder.cpp +++ b/src/server/database/Database/QueryHolder.cpp @@ -57,11 +57,11 @@ void SQLQueryHolderBase::SetPreparedResult(size_t index, PreparedResultSet* resu SQLQueryHolderBase::~SQLQueryHolderBase() { - for (size_t i = 0; i < m_queries.size(); i++) + for (std::pair<PreparedStatementBase*, PreparedQueryResult>& query : m_queries) { /// if the result was never used, free the resources /// results used already (getresult called) are expected to be deleted - delete m_queries[i].first; + delete query.first; } } diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp index e5bbab8139d..919215e91b4 100644 --- a/src/server/game/AI/CoreAI/CombatAI.cpp +++ b/src/server/game/AI/CoreAI/CombatAI.cpp @@ -55,9 +55,9 @@ void AggressorAI::UpdateAI(uint32 /*diff*/) void CombatAI::InitializeAI() { - for (uint32 i = 0; i < MAX_CREATURE_SPELLS; ++i) - if (me->m_spells[i] && sSpellMgr->GetSpellInfo(me->m_spells[i], me->GetMap()->GetDifficultyID())) - Spells.push_back(me->m_spells[i]); + for (uint32 spell : me->m_spells) + if (spell && sSpellMgr->GetSpellInfo(spell, me->GetMap()->GetDifficultyID())) + Spells.push_back(spell); CreatureAI::InitializeAI(); } @@ -69,22 +69,22 @@ void CombatAI::Reset() void CombatAI::JustDied(Unit* killer) { - for (SpellVector::iterator i = Spells.begin(); i != Spells.end(); ++i) - if (AISpellInfoType const* info = GetAISpellInfo(*i, me->GetMap()->GetDifficultyID())) + for (uint32 spell : Spells) + if (AISpellInfoType const* info = GetAISpellInfo(spell, me->GetMap()->GetDifficultyID())) if (info->condition == AICOND_DIE) - me->CastSpell(killer, *i, true); + me->CastSpell(killer, spell, true); } void CombatAI::JustEngagedWith(Unit* who) { - for (SpellVector::iterator i = Spells.begin(); i != Spells.end(); ++i) + for (uint32 spell : Spells) { - if (AISpellInfoType const* info = GetAISpellInfo(*i, me->GetMap()->GetDifficultyID())) + if (AISpellInfoType const* info = GetAISpellInfo(spell, me->GetMap()->GetDifficultyID())) { if (info->condition == AICOND_AGGRO) - me->CastSpell(who, *i, false); + me->CastSpell(who, spell, false); else if (info->condition == AICOND_COMBAT) - Events.ScheduleEvent(*i, info->cooldown + rand32() % info->cooldown); + Events.ScheduleEvent(spell, info->cooldown + rand32() % info->cooldown); } } } @@ -124,12 +124,11 @@ void CasterAI::InitializeAI() _attackDistance = 30.0f; - for (SpellVector::iterator itr = Spells.begin(); itr != Spells.end(); ++itr) - if (AISpellInfoType const* info = GetAISpellInfo(*itr, me->GetMap()->GetDifficultyID())) + for (uint32 spell : Spells) + if (AISpellInfoType const* info = GetAISpellInfo(spell, me->GetMap()->GetDifficultyID())) if (info->condition == AICOND_COMBAT && _attackDistance > info->maxRange) _attackDistance = info->maxRange; - if (_attackDistance == 30.0f) _attackDistance = MELEE_RANGE; } @@ -327,8 +326,8 @@ void VehicleAI::CheckConditions(uint32 diff) { if (Vehicle * vehicleKit = me->GetVehicleKit()) { - for (SeatMap::iterator itr = vehicleKit->Seats.begin(); itr != vehicleKit->Seats.end(); ++itr) - if (Unit * passenger = ObjectAccessor::GetUnit(*me, itr->second.Passenger.Guid)) + for (std::pair<int8 const, VehicleSeat>& Seat : vehicleKit->Seats) + if (Unit* passenger = ObjectAccessor::GetUnit(*me, Seat.second.Passenger.Guid)) { if (Player * player = passenger->ToPlayer()) { diff --git a/src/tools/vmap4_assembler/TileAssembler.cpp b/src/tools/vmap4_assembler/TileAssembler.cpp index 8a42467b8ee..b439dbf25ce 100644 --- a/src/tools/vmap4_assembler/TileAssembler.cpp +++ b/src/tools/vmap4_assembler/TileAssembler.cpp @@ -171,12 +171,12 @@ namespace VMAP exportGameobjectModels(); // export objects std::cout << "\nConverting Model Files" << std::endl; - for (std::set<std::string>::iterator mfile = spawnedModelFiles.begin(); mfile != spawnedModelFiles.end(); ++mfile) + for (std::string const& spawnedModelFile : spawnedModelFiles) { - std::cout << "Converting " << *mfile << std::endl; - if (!convertRawFile(*mfile)) + std::cout << "Converting " << spawnedModelFile << std::endl; + if (!convertRawFile(spawnedModelFile)) { - std::cout << "error converting " << *mfile << std::endl; + std::cout << "error converting " << spawnedModelFile << std::endl; success = false; break; } |