Core/Conversations: Dropped time fields and calculate them using db2 data

Port From (https://github.com/TrinityCore/TrinityCore/commit/94b14e4f6355a7bab8004dcc2ecadadbc52833de)
This commit is contained in:
hondacrx
2021-11-03 11:44:33 -04:00
parent a715622d94
commit 0bfef874de
10 changed files with 153 additions and 26 deletions
+2
View File
@@ -93,6 +93,7 @@ namespace Game.DataStorage
BattlePetSpeciesStateStorage = ReadDB2<BattlePetSpeciesStateRecord>("BattlePetSpeciesState.db2", HotfixStatements.SEL_BATTLE_PET_SPECIES_STATE);
BattlemasterListStorage = ReadDB2<BattlemasterListRecord>("BattlemasterList.db2", HotfixStatements.SEL_BATTLEMASTER_LIST, HotfixStatements.SEL_BATTLEMASTER_LIST_LOCALE);
BroadcastTextStorage = ReadDB2<BroadcastTextRecord>("BroadcastText.db2", HotfixStatements.SEL_BROADCAST_TEXT, HotfixStatements.SEL_BROADCAST_TEXT_LOCALE);
BroadcastTextDurationStorage = ReadDB2<BroadcastTextDurationRecord>("BroadcastTextDuration.db2", HotfixStatements.SEL_BROADCAST_TEXT_DURATION);
CfgRegionsStorage = ReadDB2<Cfg_RegionsRecord>("Cfg_Regions.db2", HotfixStatements.SEL_CFG_REGIONS);
CharTitlesStorage = ReadDB2<CharTitlesRecord>("CharTitles.db2", HotfixStatements.SEL_CHAR_TITLES, HotfixStatements.SEL_CHAR_TITLES_LOCALE);
CharacterLoadoutStorage = ReadDB2<CharacterLoadoutRecord>("CharacterLoadout.db2", HotfixStatements.SEL_CHARACTER_LOADOUT);
@@ -466,6 +467,7 @@ namespace Game.DataStorage
public static DB6Storage<BattlePetSpeciesStateRecord> BattlePetSpeciesStateStorage;
public static DB6Storage<BattlemasterListRecord> BattlemasterListStorage;
public static DB6Storage<BroadcastTextRecord> BroadcastTextStorage;
public static DB6Storage<BroadcastTextDurationRecord> BroadcastTextDurationStorage;
public static DB6Storage<Cfg_RegionsRecord> CfgRegionsStorage;
public static DB6Storage<CharTitlesRecord> CharTitlesStorage;
public static DB6Storage<CharacterLoadoutRecord> CharacterLoadoutStorage;
@@ -35,7 +35,7 @@ namespace Game.DataStorage
Dictionary<uint, ConversationActor[]> actorsByConversation = new();
Dictionary<uint, ulong[]> actorGuidsByConversation = new();
SQLResult lineTemplates = DB.World.Query("SELECT Id, StartTime, UiCameraID, ActorIdx, Flags FROM conversation_line_template");
SQLResult lineTemplates = DB.World.Query("SELECT Id, UiCameraID, ActorIdx, Flags FROM conversation_line_template");
if (!lineTemplates.IsEmpty())
{
uint oldMSTime = Time.GetMSTime();
@@ -52,10 +52,9 @@ namespace Game.DataStorage
ConversationLineTemplate conversationLine = new();
conversationLine.Id = id;
conversationLine.StartTime = lineTemplates.Read<uint>(1);
conversationLine.UiCameraID = lineTemplates.Read<uint>(2);
conversationLine.ActorIdx = lineTemplates.Read<byte>(3);
conversationLine.Flags = lineTemplates.Read<byte>(4);
conversationLine.UiCameraID = lineTemplates.Read<uint>(1);
conversationLine.ActorIdx = lineTemplates.Read<byte>(2);
conversationLine.Flags = lineTemplates.Read<byte>(3);
_conversationLineTemplateStorage[id] = conversationLine;
}
@@ -140,7 +139,7 @@ namespace Game.DataStorage
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 Conversation actors. DB table `conversation_actors` is empty.");
}
SQLResult templateResult = DB.World.Query("SELECT Id, FirstLineId, LastLineEndTime, TextureKitId, ScriptName FROM conversation_template");
SQLResult templateResult = DB.World.Query("SELECT Id, FirstLineId, TextureKitId, ScriptName FROM conversation_template");
if (!templateResult.IsEmpty())
{
uint oldMSTime = Time.GetMSTime();
@@ -150,8 +149,7 @@ namespace Game.DataStorage
ConversationTemplate conversationTemplate = new();
conversationTemplate.Id = templateResult.Read<uint>(0);
conversationTemplate.FirstLineId = templateResult.Read<uint>(1);
conversationTemplate.LastLineEndTime = templateResult.Read<uint>(2);
conversationTemplate.TextureKitId = templateResult.Read<uint>(3);
conversationTemplate.TextureKitId = templateResult.Read<uint>(2);
conversationTemplate.ScriptId = Global.ObjectMgr.GetScriptId(templateResult.Read<string>(3));
conversationTemplate.Actors = actorsByConversation.TryGetValue(conversationTemplate.Id, out var actors) ? actors.ToList() : null;
@@ -211,7 +209,6 @@ namespace Game.DataStorage
public class ConversationLineTemplate
{
public uint Id; // Link to ConversationLine.db2
public uint StartTime; // Time in ms after conversation creation the line is displayed
public uint UiCameraID; // Link to UiCamera.db2
public byte ActorIdx; // Index from conversation_actors
public byte Flags;
@@ -222,7 +219,6 @@ namespace Game.DataStorage
{
public uint Id;
public uint FirstLineId; // Link to ConversationLine.db2
public uint LastLineEndTime; // Time in ms after conversation creation the last line fades out
public uint TextureKitId; // Background texture
public uint ScriptId;
+10
View File
@@ -123,6 +123,10 @@ namespace Game.DataStorage
}
}
foreach (var broadcastTextDuration in BroadcastTextDurationStorage.Values)
_broadcastTextDurations[(broadcastTextDuration.BroadcastTextID, (CascLocaleBit)broadcastTextDuration.Locale)] = broadcastTextDuration.Duration;
foreach (var uiDisplay in ChrClassUIDisplayStorage.Values)
{
Cypher.Assert(uiDisplay.ChrClassesID < (byte)Class.Max);
@@ -943,6 +947,11 @@ namespace Game.DataStorage
return broadcastText.Text[SharedConst.DefaultLocale];
}
public int GetBroadcastTextDuration(int broadcastTextId, Locale locale = Locale.enUS)
{
return _broadcastTextDurations.LookupByKey((broadcastTextId, SharedConst.WowLocaleToCascLocaleBit[(int)locale]));
}
public ChrClassUIDisplayRecord GetUiDisplayForClass(Class unitClass)
{
Cypher.Assert(unitClass < Class.Max);
@@ -2306,6 +2315,7 @@ namespace Game.DataStorage
MultiMap<uint, AzeritePowerSetMemberRecord> _azeritePowers = new();
Dictionary<(uint azeriteUnlockSetId, ItemContext itemContext), byte[]> _azeriteTierUnlockLevels = new();
Dictionary<(uint itemId, ItemContext itemContext), AzeriteUnlockMappingRecord> _azeriteUnlockMappings = new();
Dictionary<(int broadcastTextId, CascLocaleBit cascLocaleBit), int> _broadcastTextDurations = new();
ChrClassUIDisplayRecord[] _uiDisplayByClass = new ChrClassUIDisplayRecord[(int)Class.Max];
uint[][] _powersByClass = new uint[(int)Class.Max][];
MultiMap<uint, ChrCustomizationChoiceRecord> _chrCustomizationChoicesByOption = new();
@@ -121,4 +121,12 @@ namespace Game.DataStorage
public ushort[] EmoteID = new ushort[3];
public ushort[] EmoteDelay = new ushort[3];
}
public sealed class BroadcastTextDurationRecord
{
public uint Id;
public int BroadcastTextID;
public int Locale;
public int Duration;
}
}