Core/Misc: Add helper table phase_name and improve .npc info and .gps

Port From (https://github.com/TrinityCore/TrinityCore/commit/833e17998571a57ada61f5ca92341dc242114458)
This commit is contained in:
hondacrx
2021-12-07 20:56:05 -05:00
parent 753faaeee1
commit 2a086b6d3c
4 changed files with 3148 additions and 7 deletions
+32 -5
View File
@@ -9923,7 +9923,33 @@ namespace Game
} while (result.NextRow());
Log.outInfo(LogFilter.ServerLoading, $"Loaded {_jumpChargeParams.Count} Player Choice locale strings in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
Log.outInfo(LogFilter.ServerLoading, $"Loaded {_jumpChargeParams.Count} Jump Charge Params in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
}
public void LoadPhaseNames()
{
uint oldMSTime = Time.GetMSTime();
_phaseNameStorage.Clear();
// 0 1
SQLResult result = DB.World.Query("SELECT `ID`, `Name` FROM `phase_name`");
if (result.IsEmpty())
{
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 phase names. DB table `phase_name` is empty.");
return;
}
uint count = 0;
do
{
uint phaseId = result.Read<uint>(0);
string name = result.Read<string>(1);
_phaseNameStorage[phaseId] = name;
++count;
} while (result.NextRow());
Log.outInfo(LogFilter.ServerLoading, $"Loaded {count} phase names in {Time.GetMSTimeDiffToNow(oldMSTime)} ms.");
}
public MailLevelReward GetMailLevelReward(uint level, ulong raceMask)
@@ -10297,27 +10323,27 @@ namespace Game
}
return null;
}
public SceneTemplate GetSceneTemplate(uint sceneId)
{
return _sceneTemplateStorage.LookupByKey(sceneId);
}
public List<TempSummonData> GetSummonGroup(uint summonerId, SummonerType summonerType, byte group)
{
Tuple<uint, SummonerType, byte> key = Tuple.Create(summonerId, summonerType, group);
return _tempSummonDataStorage.LookupByKey(key);
}
public bool IsReservedName(string name)
{
return _reservedNamesStorage.Contains(name.ToLower());
}
public JumpChargeParams GetJumpChargeParams(int id)
{
return _jumpChargeParams.LookupByKey(id);
}
public string GetPhaseName(uint phaseId)
{
return _phaseNameStorage.TryGetValue(phaseId, out string value) ? value : "Unknown Name";
}
//Vehicles
public void LoadVehicleTemplate()
@@ -10477,6 +10503,7 @@ namespace Game
List<string> _reservedNamesStorage = new();
Dictionary<uint, SceneTemplate> _sceneTemplateStorage = new();
Dictionary<int, JumpChargeParams> _jumpChargeParams = new();
Dictionary<uint, string> _phaseNameStorage = new();
Dictionary<byte, RaceUnlockRequirement> _raceUnlockRequirementStorage = new();
List<RaceClassAvailability> _classExpansionRequirementStorage = new();
+3 -2
View File
@@ -540,12 +540,13 @@ namespace Game
string personal = Global.ObjectMgr.GetCypherString(CypherStrings.PhaseFlagPersonal, chat.GetSessionDbcLocale());
foreach (var pair in phaseShift.Phases)
{
phases.Append(pair.Key);
phases.Append("\r\n");
phases.Append(" ");
phases.Append($"{pair.Key} ({Global.ObjectMgr.GetPhaseName(pair.Key)})'");
if (pair.Value.Flags.HasFlag(PhaseFlags.Cosmetic))
phases.Append(' ' + '(' + cosmetic + ')');
if (pair.Value.Flags.HasFlag(PhaseFlags.Personal))
phases.Append(' ' + '(' + personal + ')');
phases.Append(", ");
}
chat.SendSysMessage(CypherStrings.PhaseshiftPhases, phases.ToString());
+3
View File
@@ -1079,6 +1079,9 @@ namespace Game
Log.outInfo(LogFilter.ServerLoading, "Loading scenario poi data");
Global.ScenarioMgr.LoadScenarioPOI();
Log.outInfo(LogFilter.ServerLoading, "Loading phase names...");
Global.ObjectMgr.LoadPhaseNames();
// Preload all cells, if required for the base maps
if (WorldConfig.GetBoolValue(WorldCfg.BasemapLoadGrids))
{
File diff suppressed because one or more lines are too long