|
29 | 29 | #include "Timer.h" |
30 | 30 | #include "Util.h" |
31 | 31 | #include "World.h" |
| 32 | +#include <algorithm> |
32 | 33 | #include <array> |
33 | 34 | #include <bitset> |
34 | 35 | #include <boost/filesystem/directory.hpp> |
@@ -1030,6 +1031,15 @@ uint32 DB2Manager::LoadStores(std::string const& dataPath, LocaleConstant defaul |
1030 | 1031 | return 0; |
1031 | 1032 | } |
1032 | 1033 |
|
| 1034 | + TC_LOG_INFO("server.loading", ">> Initialized {} DB2 data stores in {} ms", _stores.size(), GetMSTimeDiffToNow(oldMSTime)); |
| 1035 | + |
| 1036 | + return availableDb2Locales.to_ulong(); |
| 1037 | +} |
| 1038 | + |
| 1039 | +void DB2Manager::IndexLoadedStores() |
| 1040 | +{ |
| 1041 | + uint32 oldMSTime = getMSTime(); |
| 1042 | + |
1033 | 1043 | for (AreaGroupMemberEntry const* areaGroupMember : sAreaGroupMemberStore) |
1034 | 1044 | _areaGroupMembers[areaGroupMember->AreaGroupID].push_back(areaGroupMember->AreaID); |
1035 | 1045 |
|
@@ -1060,10 +1070,7 @@ uint32 DB2Manager::LoadStores(std::string const& dataPath, LocaleConstant defaul |
1060 | 1070 | for (AzeriteItemMilestonePowerEntry const* azeriteItemMilestonePower : sAzeriteItemMilestonePowerStore) |
1061 | 1071 | _azeriteItemMilestonePowers.push_back(azeriteItemMilestonePower); |
1062 | 1072 |
|
1063 | | - std::sort(_azeriteItemMilestonePowers.begin(), _azeriteItemMilestonePowers.end(), [](AzeriteItemMilestonePowerEntry const* a1, AzeriteItemMilestonePowerEntry const* a2) |
1064 | | - { |
1065 | | - return a1->RequiredLevel < a2->RequiredLevel; |
1066 | | - }); |
| 1073 | + std::ranges::sort(_azeriteItemMilestonePowers, {}, &AzeriteItemMilestonePowerEntry::RequiredLevel); |
1067 | 1074 |
|
1068 | 1075 | { |
1069 | 1076 | uint32 azeriteEssenceSlot = 0; |
@@ -1120,8 +1127,8 @@ uint32 DB2Manager::LoadStores(std::string const& dataPath, LocaleConstant defaul |
1120 | 1127 | for (ChrClassesXPowerTypesEntry const* power : sChrClassesXPowerTypesStore) |
1121 | 1128 | powers.insert(power); |
1122 | 1129 |
|
1123 | | - for (std::size_t i = 0; i < _powersByClass.size(); ++i) |
1124 | | - _powersByClass[i].fill(MAX_POWERS); |
| 1130 | + for (std::array<uint32, MAX_POWERS>& powersForClass : _powersByClass) |
| 1131 | + powersForClass.fill(MAX_POWERS); |
1125 | 1132 |
|
1126 | 1133 | for (ChrClassesXPowerTypesEntry const* power : powers) |
1127 | 1134 | { |
@@ -1271,10 +1278,10 @@ uint32 DB2Manager::LoadStores(std::string const& dataPath, LocaleConstant defaul |
1271 | 1278 |
|
1272 | 1279 | for (auto& [curveId, curvePoints] : unsortedPoints) |
1273 | 1280 | { |
1274 | | - std::sort(curvePoints.begin(), curvePoints.end(), [](CurvePointEntry const* point1, CurvePointEntry const* point2) { return point1->OrderIndex < point2->OrderIndex; }); |
| 1281 | + std::ranges::sort(curvePoints, {}, &CurvePointEntry::OrderIndex); |
1275 | 1282 | std::vector<DBCPosition2D>& points = _curvePoints[curveId]; |
1276 | 1283 | points.resize(curvePoints.size()); |
1277 | | - std::transform(curvePoints.begin(), curvePoints.end(), points.begin(), [](CurvePointEntry const* point) { return point->Pos; }); |
| 1284 | + std::ranges::transform(curvePoints, points.begin(), &CurvePointEntry::Pos); |
1278 | 1285 | } |
1279 | 1286 | } |
1280 | 1287 |
|
@@ -1355,10 +1362,7 @@ uint32 DB2Manager::LoadStores(std::string const& dataPath, LocaleConstant defaul |
1355 | 1362 | for (MapDifficultyXConditionEntry const* mapDifficultyCondition : sMapDifficultyXConditionStore) |
1356 | 1363 | mapDifficultyConditions.push_back(mapDifficultyCondition); |
1357 | 1364 |
|
1358 | | - std::sort(mapDifficultyConditions.begin(), mapDifficultyConditions.end(), [](MapDifficultyXConditionEntry const* left, MapDifficultyXConditionEntry const* right) |
1359 | | - { |
1360 | | - return left->OrderIndex < right->OrderIndex; |
1361 | | - }); |
| 1365 | + std::ranges::sort(mapDifficultyConditions, {}, &MapDifficultyXConditionEntry::OrderIndex); |
1362 | 1366 |
|
1363 | 1367 | for (MapDifficultyXConditionEntry const* mapDifficultyCondition : mapDifficultyConditions) |
1364 | 1368 | if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(mapDifficultyCondition->PlayerConditionID)) |
@@ -1549,8 +1553,7 @@ uint32 DB2Manager::LoadStores(std::string const& dataPath, LocaleConstant defaul |
1549 | 1553 | std::vector<uint32> pathLength; |
1550 | 1554 | pathLength.resize(pathCount); // 0 and some other indexes not used |
1551 | 1555 | for (TaxiPathNodeEntry const* entry : sTaxiPathNodeStore) |
1552 | | - if (pathLength[entry->PathID] < entry->NodeIndex + 1u) |
1553 | | - pathLength[entry->PathID] = entry->NodeIndex + 1u; |
| 1556 | + pathLength[entry->PathID] = std::max(pathLength[entry->PathID], entry->NodeIndex + 1u); |
1554 | 1557 |
|
1555 | 1558 | // Set path length |
1556 | 1559 | sTaxiPathNodesByPath.resize(pathCount); // 0 and some other indexes not used |
@@ -1709,9 +1712,7 @@ uint32 DB2Manager::LoadStores(std::string const& dataPath, LocaleConstant defaul |
1709 | 1712 | for (PVPStatEntry const* pvpStat : sPVPStatStore) |
1710 | 1713 | _pvpStatIdsByMap[pvpStat->MapID].insert(pvpStat->ID); |
1711 | 1714 |
|
1712 | | - TC_LOG_INFO("server.loading", ">> Initialized {} DB2 data stores in {} ms", _stores.size(), GetMSTimeDiffToNow(oldMSTime)); |
1713 | | - |
1714 | | - return availableDb2Locales.to_ulong(); |
| 1715 | + TC_LOG_INFO("server.loading", ">> Indexed DB2 data stores in {} ms", GetMSTimeDiffToNow(oldMSTime)); |
1715 | 1716 | } |
1716 | 1717 |
|
1717 | 1718 | DB2StorageBase const* DB2Manager::GetStorage(uint32 type) const |
|
0 commit comments