diff --git a/WowPacketParser/SQL/Builders/QuestMisc.cs b/WowPacketParser/SQL/Builders/QuestMisc.cs index 874998c842..1aafcafdc8 100644 --- a/WowPacketParser/SQL/Builders/QuestMisc.cs +++ b/WowPacketParser/SQL/Builders/QuestMisc.cs @@ -126,6 +126,62 @@ public static string QuestRequestItems() return SQLUtil.Compare(Storage.QuestRequestItems, templatesDb, StoreNameType.Quest); } + [BuilderMethod] + public static string QuestDescriptionConditional() + { + if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.quest_template)) + return string.Empty; + + if (Storage.QuestDescriptionConditional.IsEmpty()) + return string.Empty; + + var templatesDb = SQLDatabase.Get(Storage.QuestDescriptionConditional); + + return SQLUtil.Compare(Storage.QuestDescriptionConditional, templatesDb, StoreNameType.Quest); + } + + [BuilderMethod] + public static string QuestCompletionLogConditional() + { + if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.quest_template)) + return string.Empty; + + if (Storage.QuestCompletionLogConditional.IsEmpty()) + return string.Empty; + + var templatesDb = SQLDatabase.Get(Storage.QuestCompletionLogConditional); + + return SQLUtil.Compare(Storage.QuestCompletionLogConditional, templatesDb, StoreNameType.Quest); + } + + [BuilderMethod] + public static string QuestOfferRewardConditional() + { + if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.quest_template)) + return string.Empty; + + if (Storage.QuestOfferRewardConditional.IsEmpty()) + return string.Empty; + + var templatesDb = SQLDatabase.Get(Storage.QuestOfferRewardConditional); + + return SQLUtil.Compare(Storage.QuestOfferRewardConditional, templatesDb, StoreNameType.Quest); + } + + [BuilderMethod] + public static string QuestRequestItemsConditional() + { + if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.quest_template)) + return string.Empty; + + if (Storage.QuestRequestItemsConditional.IsEmpty()) + return string.Empty; + + var templatesDb = SQLDatabase.Get(Storage.QuestRequestItemsConditional); + + return SQLUtil.Compare(Storage.QuestRequestItemsConditional, templatesDb, StoreNameType.Quest); + } + [BuilderMethod] public static string CreatureQuestStarters() { diff --git a/WowPacketParser/Store/Objects/QuestTextConditional.cs b/WowPacketParser/Store/Objects/QuestTextConditional.cs new file mode 100644 index 0000000000..3158fec7a0 --- /dev/null +++ b/WowPacketParser/Store/Objects/QuestTextConditional.cs @@ -0,0 +1,69 @@ +using WowPacketParser.Enums; +using WowPacketParser.Misc; +using WowPacketParser.SQL; + +namespace WowPacketParser.Store.Objects +{ + public record QuestTextConditional : IDataModel + { + [DBFieldName("QuestId", true)] + public int? QuestId; + + [DBFieldName("PlayerConditionId", true)] + public int? PlayerConditionId; + + [DBFieldName("QuestgiverCreatureId", true)] + public int? QuestgiverCreatureId; + + [DBFieldName("locale", true)] + public string Locale = ClientLocale.PacketLocaleString; + + [DBFieldName("Text")] + public string Text; + + [DBFieldName("OrderIndex")] + public int? OrderIndex; + + [DBFieldName("VerifiedBuild")] + public int? VerifiedBuild = ClientVersion.BuildInt; + + public QuestTextConditional(QuestTextConditional questTextConditional) + { + QuestId = questTextConditional.QuestId; + PlayerConditionId = questTextConditional.PlayerConditionId; + QuestgiverCreatureId = questTextConditional.QuestgiverCreatureId; + Locale = ClientLocale.PacketLocaleString; + Text = questTextConditional.Text; + OrderIndex = questTextConditional.OrderIndex; + VerifiedBuild = ClientVersion.BuildInt; + } + } + + [DBTableName("quest_description_conditional", TargetedDatabaseFlag.SinceDragonflight)] + public sealed record QuestDescriptionConditional : QuestTextConditional + { + public QuestDescriptionConditional() { } + public QuestDescriptionConditional(QuestTextConditional questTextConditional) : base(questTextConditional) { } + } + + [DBTableName("quest_completion_log_conditional", TargetedDatabaseFlag.SinceDragonflight)] + public sealed record QuestCompletionLogConditional : QuestTextConditional + { + public QuestCompletionLogConditional() { } + public QuestCompletionLogConditional(QuestTextConditional questTextConditional) : base(questTextConditional) { } + } + + [DBTableName("quest_offer_reward_conditional", TargetedDatabaseFlag.SinceDragonflight)] + public sealed record QuestOfferRewardConditional : QuestTextConditional + { + public QuestOfferRewardConditional() { } + public QuestOfferRewardConditional(QuestTextConditional questTextConditional) : base(questTextConditional) { } + } + + [DBTableName("quest_request_items_conditional", TargetedDatabaseFlag.SinceDragonflight)] + public sealed record QuestRequestItemsConditional : QuestTextConditional + { + public QuestRequestItemsConditional() { } + public QuestRequestItemsConditional(QuestTextConditional questTextConditional) : base(questTextConditional) { } + } +} diff --git a/WowPacketParser/Store/Storage.cs b/WowPacketParser/Store/Storage.cs index 485415e316..7ad22f06e1 100644 --- a/WowPacketParser/Store/Storage.cs +++ b/WowPacketParser/Store/Storage.cs @@ -99,6 +99,10 @@ public static class Storage public static readonly DataBag QuestGreetings = new DataBag(new List { SQLOutput.quest_template }); public static readonly DataBag QuestDetails = new DataBag(new List { SQLOutput.quest_template }); public static readonly DataBag QuestRequestItems = new DataBag(new List { SQLOutput.quest_template }); + public static readonly DataBag QuestDescriptionConditional = new DataBag(new List { SQLOutput.quest_template }); + public static readonly DataBag QuestCompletionLogConditional = new DataBag(new List { SQLOutput.quest_template }); + public static readonly DataBag QuestOfferRewardConditional = new DataBag(new List { SQLOutput.quest_template }); + public static readonly DataBag QuestRequestItemsConditional = new DataBag(new List { SQLOutput.quest_template }); // Names public static readonly DataBag ObjectNames = new DataBag(); @@ -1206,6 +1210,10 @@ public static void ClearContainers() QuestGreetings.Clear(); QuestDetails.Clear(); QuestRequestItems.Clear(); + QuestDescriptionConditional.Clear(); + QuestCompletionLogConditional.Clear(); + QuestOfferRewardConditional.Clear(); + QuestRequestItemsConditional.Clear(); ObjectNames.Clear(); diff --git a/WowPacketParserModule.V10_0_0_46181/Parsers/QueryHandler.cs b/WowPacketParserModule.V10_0_0_46181/Parsers/QueryHandler.cs index 41c2651506..41ae5888f7 100644 --- a/WowPacketParserModule.V10_0_0_46181/Parsers/QueryHandler.cs +++ b/WowPacketParserModule.V10_0_0_46181/Parsers/QueryHandler.cs @@ -236,10 +236,10 @@ public static void HandleQuestQueryResponse(Packet packet) quest.QuestCompletionLog = packet.ReadWoWString("QuestCompletionLog", questCompletionLogLen); for (int i = 0; i < conditionalQuestDescriptionCount; i++) - QuestHandler.ReadConditionalQuestText(packet, "ConditionalQuestDescription", i); + QuestHandler.ReadConditionalQuestText(packet, id.Key, i, QuestHandler.ConditionalTextType.Description, i, "ConditionalDescriptionText"); for (int i = 0; i < conditionalQuestCompletionLogCount; i++) - QuestHandler.ReadConditionalQuestText(packet, "ConditionalQuestCompletionLog", i); + QuestHandler.ReadConditionalQuestText(packet, id.Key, i, QuestHandler.ConditionalTextType.CompletionLog, i, "ConditionalCompletionLogText"); ObjectName objectName = new ObjectName { diff --git a/WowPacketParserModule.V10_0_0_46181/Parsers/QuestHandler.cs b/WowPacketParserModule.V10_0_0_46181/Parsers/QuestHandler.cs index 850a5fb105..3e073f2c83 100644 --- a/WowPacketParserModule.V10_0_0_46181/Parsers/QuestHandler.cs +++ b/WowPacketParserModule.V10_0_0_46181/Parsers/QuestHandler.cs @@ -1,5 +1,4 @@  -using Org.BouncyCastle.Crypto.Operators; using WowPacketParser.Enums; using WowPacketParser.Misc; using WowPacketParser.Parsing; @@ -12,14 +11,49 @@ namespace WowPacketParserModule.V10_0_0_46181.Parsers { public static class QuestHandler { - public static void ReadConditionalQuestText(Packet packet, params object[] indexes) + public enum ConditionalTextType { - packet.ReadInt32("PlayerConditionID", indexes); - packet.ReadInt32("QuestGiverCreatureID", indexes); + Description = 0, + CompletionLog = 1, + OfferReward = 2, + RequestItems = 3 + } + + public static void ReadConditionalQuestText(Packet packet, int questId, int idx, ConditionalTextType type, params object[] indexes) + { + var playerConditionId = packet.ReadInt32("PlayerConditionID", indexes); + var questgiverCreatureId = packet.ReadInt32("QuestGiverCreatureID", indexes); packet.ResetBitReader(); var textLength = packet.ReadBits(12); - packet.ReadWoWString("Text", textLength, indexes); + var text = packet.ReadWoWString("Text", textLength, indexes); + + QuestTextConditional questTextConditional = new QuestTextConditional + { + QuestId = questId, + PlayerConditionId = playerConditionId, + QuestgiverCreatureId = questgiverCreatureId, + Text = text, + OrderIndex = idx + }; + + switch (type) + { + case ConditionalTextType.Description: + Storage.QuestDescriptionConditional.Add(new QuestDescriptionConditional(questTextConditional), packet.TimeSpan); + break; + case ConditionalTextType.CompletionLog: + Storage.QuestCompletionLogConditional.Add(new QuestCompletionLogConditional(questTextConditional), packet.TimeSpan); + break; + case ConditionalTextType.OfferReward: + Storage.QuestOfferRewardConditional.Add(new QuestOfferRewardConditional(questTextConditional), packet.TimeSpan); + break; + case ConditionalTextType.RequestItems: + Storage.QuestRequestItemsConditional.Add(new QuestRequestItemsConditional(questTextConditional), packet.TimeSpan); + break; + default: + break; + } } [Parser(Opcode.SMSG_QUEST_GIVER_QUEST_DETAILS)] @@ -100,7 +134,7 @@ public static void HandleQuestGiverQuestDetails(Packet packet) packet.ReadWoWString("PortraitTurnInName", portraitTurnInNameLen); for (int i = 0; i < conditionalDescriptionTextCount; i++) - ReadConditionalQuestText(packet, "ConditionalDescriptionText"); + ReadConditionalQuestText(packet, id, i, ConditionalTextType.Description, i, "ConditionalDescriptionText"); Storage.QuestDetails.Add(questDetails, packet.TimeSpan); } @@ -177,7 +211,7 @@ public static void HandleQuestGiverRequestItems(Packet packet) completionTextLen = packet.ReadBits(12); for (int i = 0; i < conditionalCompletionTextCount; i++) - ReadConditionalQuestText(packet, "ConditionalCompletionText"); + ReadConditionalQuestText(packet, id, i, ConditionalTextType.RequestItems, i, "ConditionalCompletionText"); requestItems.QuestTitle = packet.ReadWoWString("QuestTitle", questTitleLen); string completionText = requestItems.CompletionText = packet.ReadWoWString("CompletionText", completionTextLen); @@ -258,7 +292,7 @@ public static void QuestGiverOfferReward(Packet packet) uint portraitTurnInNameLen = packet.ReadBits(8); for (int i = 0; i < conditionalRewardTextCount; i++) - ReadConditionalQuestText(packet, "ConditionalRewardText"); + ReadConditionalQuestText(packet, (int)questOfferReward.ID, i, ConditionalTextType.OfferReward, i, "ConditionalRewardText"); packet.ReadWoWString("QuestTitle", questTitleLen); questOfferReward.RewardText = packet.ReadWoWString("RewardText", rewardTextLen);