Core/Realms: Remove duplicate realm names storage
Port From (https://github.com/TrinityCore/TrinityCore/commit/7f5e47c396e49da2530aabac05f7ca3c0f177298)
This commit is contained in:
@@ -139,7 +139,21 @@ public class RealmManager : Singleton<RealmManager>
|
|||||||
return _realms.LookupByKey(id);
|
return _realms.LookupByKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RealmBuildInfo GetBuildInfo(uint build)
|
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)
|
foreach (var clientBuild in _builds)
|
||||||
if (clientBuild.Build == build)
|
if (clientBuild.Build == build)
|
||||||
|
|||||||
@@ -436,32 +436,6 @@ namespace Game
|
|||||||
else
|
else
|
||||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 class expansion requirements. DB table `class_expansion_requirement` is empty.");
|
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)
|
public string GetCypherString(uint entry, Locale locale = Locale.enUS)
|
||||||
{
|
{
|
||||||
@@ -482,21 +456,6 @@ namespace Game
|
|||||||
return GetCypherString((uint)cmd, locale);
|
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 Dictionary<byte, RaceUnlockRequirement> GetRaceUnlockRequirements() { return _raceUnlockRequirementStorage; }
|
||||||
public RaceUnlockRequirement GetRaceUnlockRequirement(Race race) { return _raceUnlockRequirementStorage.LookupByKey((byte)race); }
|
public RaceUnlockRequirement GetRaceUnlockRequirement(Race race) { return _raceUnlockRequirementStorage.LookupByKey((byte)race); }
|
||||||
public List<RaceClassAvailability> GetClassExpansionRequirements() { return _classExpansionRequirementStorage; }
|
public List<RaceClassAvailability> GetClassExpansionRequirements() { return _classExpansionRequirementStorage; }
|
||||||
@@ -11000,7 +10959,6 @@ namespace Game
|
|||||||
|
|
||||||
Dictionary<byte, RaceUnlockRequirement> _raceUnlockRequirementStorage = new();
|
Dictionary<byte, RaceUnlockRequirement> _raceUnlockRequirementStorage = new();
|
||||||
List<RaceClassAvailability> _classExpansionRequirementStorage = new();
|
List<RaceClassAvailability> _classExpansionRequirementStorage = new();
|
||||||
Dictionary<uint, string> _realmNameStorage = new();
|
|
||||||
|
|
||||||
//Quest
|
//Quest
|
||||||
Dictionary<uint, Quest> _questTemplates = new();
|
Dictionary<uint, Quest> _questTemplates = new();
|
||||||
|
|||||||
@@ -346,11 +346,11 @@ namespace Game
|
|||||||
realmQueryResponse.VirtualRealmAddress = queryRealmName.VirtualRealmAddress;
|
realmQueryResponse.VirtualRealmAddress = queryRealmName.VirtualRealmAddress;
|
||||||
|
|
||||||
RealmId realmHandle = new(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.LookupState = (byte)ResponseCodes.Success;
|
||||||
realmQueryResponse.NameInfo.IsInternalRealm = false;
|
realmQueryResponse.NameInfo.IsInternalRealm = false;
|
||||||
realmQueryResponse.NameInfo.IsLocal = queryRealmName.VirtualRealmAddress == Global.WorldMgr.GetRealm().Id.GetAddress();
|
realmQueryResponse.NameInfo.IsLocal = queryRealmName.VirtualRealmAddress == Global.WorldMgr.GetVirtualRealmAddress();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
realmQueryResponse.LookupState = (byte)ResponseCodes.Failure;
|
realmQueryResponse.LookupState = (byte)ResponseCodes.Failure;
|
||||||
|
|||||||
@@ -1104,9 +1104,6 @@ namespace Game
|
|||||||
Log.outInfo(LogFilter.ServerLoading, "Loading character templates...");
|
Log.outInfo(LogFilter.ServerLoading, "Loading character templates...");
|
||||||
Global.CharacterTemplateDataStorage.LoadCharacterTemplates();
|
Global.CharacterTemplateDataStorage.LoadCharacterTemplates();
|
||||||
|
|
||||||
Log.outInfo(LogFilter.ServerLoading, "Loading realm names...");
|
|
||||||
Global.ObjectMgr.LoadRealmNames();
|
|
||||||
|
|
||||||
Log.outInfo(LogFilter.ServerLoading, "Loading battle pets info...");
|
Log.outInfo(LogFilter.ServerLoading, "Loading battle pets info...");
|
||||||
BattlePetMgr.Initialize();
|
BattlePetMgr.Initialize();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user