aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-04-29 00:25:31 +0200
committerShauren <shauren.trinity@gmail.com>2023-04-29 00:25:31 +0200
commit7f5e47c396e49da2530aabac05f7ca3c0f177298 (patch)
treed9fc6de0e3cee034186237ebb0b8515c16e16326 /src/server/shared
parent5138418364ad59ae9c185b8a16e20706b35c40dc (diff)
Core/Realms: Remove duplicate realm names storage
Diffstat (limited to 'src/server/shared')
-rw-r--r--src/server/shared/Realm/RealmList.cpp17
-rw-r--r--src/server/shared/Realm/RealmList.h1
2 files changed, 14 insertions, 4 deletions
diff --git a/src/server/shared/Realm/RealmList.cpp b/src/server/shared/Realm/RealmList.cpp
index 361e87872e2..c43b12ae241 100644
--- a/src/server/shared/Realm/RealmList.cpp
+++ b/src/server/shared/Realm/RealmList.cpp
@@ -23,6 +23,7 @@
#include "Errors.h"
#include "IoContext.h"
#include "Log.h"
+#include "MapUtils.h"
#include "ProtobufJSON.h"
#include "Resolver.h"
#include "Util.h"
@@ -224,11 +225,19 @@ void RealmList::UpdateRealms(boost::system::error_code const& error)
Realm const* RealmList::GetRealm(Battlenet::RealmHandle const& id) const
{
std::shared_lock<std::shared_mutex> lock(_realmsMutex);
- auto itr = _realms.find(id);
- if (itr != _realms.end())
- return &itr->second;
+ return Trinity::Containers::MapGetValuePtr(_realms, id);
+}
- return nullptr;
+bool RealmList::GetRealmNames(Battlenet::RealmHandle const& id, std::string* name, std::string* normalizedName) const
+{
+ std::shared_lock<std::shared_mutex> lock(_realmsMutex);
+ Realm const* realm = Trinity::Containers::MapGetValuePtr(_realms, id);
+ if (!realm)
+ return false;
+
+ *name = realm->Name;
+ *normalizedName = realm->NormalizedName;
+ return true;
}
RealmBuildInfo const* RealmList::GetBuildInfo(uint32 build) const
diff --git a/src/server/shared/Realm/RealmList.h b/src/server/shared/Realm/RealmList.h
index 9bf64270589..3d820120c37 100644
--- a/src/server/shared/Realm/RealmList.h
+++ b/src/server/shared/Realm/RealmList.h
@@ -82,6 +82,7 @@ public:
void Close();
Realm const* GetRealm(Battlenet::RealmHandle const& id) const;
+ bool GetRealmNames(Battlenet::RealmHandle const& id, std::string* name, std::string* normalizedName) const;
RealmBuildInfo const* GetBuildInfo(uint32 build) const;
uint32 GetMinorMajorBugfixVersionForBuild(uint32 build) const;