Core/Realms: Remove duplicate realm names storage

Port From (https://github.com/TrinityCore/TrinityCore/commit/7f5e47c396e49da2530aabac05f7ca3c0f177298)
This commit is contained in:
hondacrx
2023-05-02 17:22:16 -04:00
parent 1e297b7cab
commit 42a902c118
4 changed files with 17 additions and 48 deletions
+14
View File
@@ -139,6 +139,20 @@ public class RealmManager : Singleton<RealmManager>
return _realms.LookupByKey(id);
}
public bool GetRealmNames(RealmId id, out string name, out string normalizedName)
{
name = null;
normalizedName = null;
Realm realm = GetRealm(id);
if (realm == null)
return false;
name = realm.Name;
normalizedName = realm.NormalizedName;
return true;
}
public RealmBuildInfo GetBuildInfo(uint build)
{
foreach (var clientBuild in _builds)
-42
View File
@@ -436,32 +436,6 @@ namespace Game
else
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 class expansion requirements. DB table `class_expansion_requirement` is empty.");
}
public void LoadRealmNames()
{
uint oldMSTime = Time.GetMSTime();
_realmNameStorage.Clear();
// 0 1
SQLResult result = DB.Login.Query("SELECT id, name FROM `realmlist`");
if (result.IsEmpty())
{
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 realm names. DB table `realmlist` is empty.");
return;
}
uint count = 0;
do
{
uint realm = result.Read<uint>(0);
string realmName = result.Read<string>(1);
_realmNameStorage[realm] = realmName;
++count;
}
while (result.NextRow());
Log.outInfo(LogFilter.ServerLoading, "Loaded {0} realm names in {1} ms.", count, Time.GetMSTimeDiffToNow(oldMSTime));
}
public string GetCypherString(uint entry, Locale locale = Locale.enUS)
{
@@ -482,21 +456,6 @@ namespace Game
return GetCypherString((uint)cmd, locale);
}
public string GetRealmName(uint realm)
{
return _realmNameStorage.LookupByKey(realm);
}
public bool GetRealmName(uint realmId, ref string name, ref string normalizedName)
{
var realmName = _realmNameStorage.LookupByKey(realmId);
if (realmName != null)
{
name = realmName;
normalizedName = realmName.Normalize();
return true;
}
return false;
}
public Dictionary<byte, RaceUnlockRequirement> GetRaceUnlockRequirements() { return _raceUnlockRequirementStorage; }
public RaceUnlockRequirement GetRaceUnlockRequirement(Race race) { return _raceUnlockRequirementStorage.LookupByKey((byte)race); }
public List<RaceClassAvailability> GetClassExpansionRequirements() { return _classExpansionRequirementStorage; }
@@ -11000,7 +10959,6 @@ namespace Game
Dictionary<byte, RaceUnlockRequirement> _raceUnlockRequirementStorage = new();
List<RaceClassAvailability> _classExpansionRequirementStorage = new();
Dictionary<uint, string> _realmNameStorage = new();
//Quest
Dictionary<uint, Quest> _questTemplates = new();
+2 -2
View File
@@ -346,11 +346,11 @@ namespace Game
realmQueryResponse.VirtualRealmAddress = queryRealmName.VirtualRealmAddress;
RealmId realmHandle = new(queryRealmName.VirtualRealmAddress);
if (Global.ObjectMgr.GetRealmName(realmHandle.Index, ref realmQueryResponse.NameInfo.RealmNameActual, ref realmQueryResponse.NameInfo.RealmNameNormalized))
if (Global.RealmMgr.GetRealmNames(realmHandle, out realmQueryResponse.NameInfo.RealmNameActual, out realmQueryResponse.NameInfo.RealmNameNormalized))
{
realmQueryResponse.LookupState = (byte)ResponseCodes.Success;
realmQueryResponse.NameInfo.IsInternalRealm = false;
realmQueryResponse.NameInfo.IsLocal = queryRealmName.VirtualRealmAddress == Global.WorldMgr.GetRealm().Id.GetAddress();
realmQueryResponse.NameInfo.IsLocal = queryRealmName.VirtualRealmAddress == Global.WorldMgr.GetVirtualRealmAddress();
}
else
realmQueryResponse.LookupState = (byte)ResponseCodes.Failure;
-3
View File
@@ -1104,9 +1104,6 @@ namespace Game
Log.outInfo(LogFilter.ServerLoading, "Loading character templates...");
Global.CharacterTemplateDataStorage.LoadCharacterTemplates();
Log.outInfo(LogFilter.ServerLoading, "Loading realm names...");
Global.ObjectMgr.LoadRealmNames();
Log.outInfo(LogFilter.ServerLoading, "Loading battle pets info...");
BattlePetMgr.Initialize();