Skip to content

Commit

Permalink
Added SQL output for UIMap questlines (#881)
Browse files Browse the repository at this point in the history
  • Loading branch information
meji46 authored Sep 19, 2024
1 parent f375a11 commit 47216a9
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 3 deletions.
2 changes: 1 addition & 1 deletion WowPacketParser/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
20: Classic
21: WotlkClassic
22: CataClassic
22: CataClassic
-->
<add key="TargetedDatabase" value="2"/>

Expand Down
1 change: 1 addition & 0 deletions WowPacketParser/DBC/DBC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static class DBC
public static Storage<ItemSparseEntry> ItemSparse { get; set; }
public static Storage<MapEntry> Map { get; set; }
public static Storage<MapDifficultyEntry> MapDifficulty { get; set; }
public static Storage<QuestLineXQuestEntry> QuestLineXQuest { get; set; }
public static Storage<PhaseEntry> Phase { get; set; }
public static Storage<PhaseXPhaseGroupEntry> PhaseXPhaseGroup { get; set; }
public static Storage<SpellEffectEntry> SpellEffect { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using DBFileReaderLib.Attributes;

namespace WowPacketParser.DBC.Structures.TheWarWithin
{
[DBFile("QuestLineXQuest")]
public sealed class QuestLineXQuestEntry
{
[Index(true)]
public int ID;
public uint QuestLineID;
public uint QuestID;
public uint OrderIndex;
public int Flags;
}
}
31 changes: 31 additions & 0 deletions WowPacketParser/SQL/Builders/QuestMisc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,37 @@ public static string QuestRequestItemsConditional()
return SQLUtil.Compare(Storage.QuestRequestItemsConditional, templatesDb, StoreNameType.Quest);
}

[BuilderMethod]
public static string UIMapQuestLines()
{
if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.quest_template))
return string.Empty;

if (Storage.UIMapQuestLines.IsEmpty())
return string.Empty;

var templatesDb = SQLDatabase.Get(Storage.UIMapQuestLines);

return SQLUtil.Compare(Storage.UIMapQuestLines, templatesDb, StoreNameType.None);
}

[BuilderMethod]
public static string UIMapQuests()
{
if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.quest_template))
return string.Empty;

if (Storage.UIMapQuests.IsEmpty())
return string.Empty;

var templatesDb = SQLDatabase.Get(Storage.UIMapQuests);

return SQLUtil.Compare(Storage.UIMapQuests, templatesDb, x =>
{
return $"{StoreGetters.GetName(StoreNameType.Quest, (int)x.QuestId, false)}";
});
}

[BuilderMethod]
public static string CreatureQuestStarters()
{
Expand Down
19 changes: 19 additions & 0 deletions WowPacketParser/Store/Objects/UIMapQuest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using WowPacketParser.Enums;
using WowPacketParser.Misc;
using WowPacketParser.SQL;

namespace WowPacketParser.Store.Objects
{
[DBTableName("ui_map_quest", TargetedDatabaseFlag.SinceTheWarWithin)]
public sealed record UIMapQuest : IDataModel
{
[DBFieldName("UIMapId", true)]
public uint? UIMapId;

[DBFieldName("QuestId", true)]
public uint? QuestId;

[DBFieldName("VerifiedBuild")]
public int? VerifiedBuild = ClientVersion.BuildInt;
}
}
19 changes: 19 additions & 0 deletions WowPacketParser/Store/Objects/UIMapQuestLine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using WowPacketParser.Enums;
using WowPacketParser.Misc;
using WowPacketParser.SQL;

namespace WowPacketParser.Store.Objects
{
[DBTableName("ui_map_quest_line", TargetedDatabaseFlag.SinceTheWarWithin)]
public sealed record UIMapQuestLine : IDataModel
{
[DBFieldName("UIMapId", true)]
public uint? UIMapId;

[DBFieldName("QuestLineId", true)]
public uint? QuestLineId;

[DBFieldName("VerifiedBuild")]
public int? VerifiedBuild = ClientVersion.BuildInt;
}
}
4 changes: 4 additions & 0 deletions WowPacketParser/Store/Storage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ public static class Storage
public static readonly DataBag<QuestCompletionLogConditional> QuestCompletionLogConditional = new DataBag<QuestCompletionLogConditional>(new List<SQLOutput> { SQLOutput.quest_template });
public static readonly DataBag<QuestOfferRewardConditional> QuestOfferRewardConditional = new DataBag<QuestOfferRewardConditional>(new List<SQLOutput> { SQLOutput.quest_template });
public static readonly DataBag<QuestRequestItemsConditional> QuestRequestItemsConditional = new DataBag<QuestRequestItemsConditional>(new List<SQLOutput> { SQLOutput.quest_template });
public static readonly DataBag<UIMapQuestLine> UIMapQuestLines = new DataBag<UIMapQuestLine>(new List<SQLOutput> { SQLOutput.quest_template });
public static readonly DataBag<UIMapQuest> UIMapQuests = new DataBag<UIMapQuest>(new List<SQLOutput> { SQLOutput.quest_template });

// Names
public static readonly DataBag<ObjectName> ObjectNames = new DataBag<ObjectName>();
Expand Down Expand Up @@ -1654,6 +1656,8 @@ public static void ClearContainers()
QuestCompletionLogConditional.Clear();
QuestOfferRewardConditional.Clear();
QuestRequestItemsConditional.Clear();
UIMapQuestLines.Clear();
UIMapQuests.Clear();

ObjectNames.Clear();

Expand Down
47 changes: 46 additions & 1 deletion WowPacketParserModule.V10_0_0_46181/Parsers/QuestHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

using WowPacketParser.DBC;
using WowPacketParser.Enums;
using WowPacketParser.Misc;
using WowPacketParser.Parsing;
Expand Down Expand Up @@ -349,5 +349,50 @@ public static void QueryQuestItemUsability(Packet packet)
for (var i = 0; i < itemGuidCount; ++i)
packet.ReadPackedGuid128("ItemGUID", i);
}

[Parser(Opcode.SMSG_UI_MAP_QUEST_LINES_RESPONSE)]
public static void HandleUiMapQuestLinesResponse(Packet packet)
{
var uiMap = packet.ReadInt32("UiMapID");
var questLineXQuestCount = packet.ReadUInt32();
var questCount = packet.ReadUInt32();

for (int i = 0; i < questLineXQuestCount; i++)
{
var questLineXQuestId = packet.ReadUInt32();

if (Settings.UseDBC && DBC.QuestLineXQuest.ContainsKey((int)questLineXQuestId))
{
if (DBC.QuestLineXQuest.TryGetValue((int)questLineXQuestId, out var questLineXQuest))
{
var questLineId = questLineXQuest.QuestLineID;
var questId = questLineXQuest.QuestID;

UIMapQuestLine uiMapQuestLine = new()
{
UIMapId = (uint)uiMap,
QuestLineId = questLineId
};
Storage.UIMapQuestLines.Add(uiMapQuestLine, packet.TimeSpan);

packet.WriteLine($"[{i}] QuestLineXQuestID: {questLineXQuestId} (QuestID: {questId} QuestLineID: {questLineId})");
}
}
else
packet.AddValue($"QuestLineXQuestID", questLineXQuestId, i);
}

for (int i = 0; i < questCount; i++)
{
var questId = packet.ReadUInt32<QuestId>("QuestID", i);

UIMapQuest uiMapQuest = new UIMapQuest
{
UIMapId = (uint)uiMap,
QuestId = questId
};
Storage.UIMapQuests.Add(uiMapQuest, packet.TimeSpan);
}
}
}
}
61 changes: 60 additions & 1 deletion WowPacketParserModule.V11_0_0_55666/Parsers/QuestHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using WowPacketParser.Enums;
using WowPacketParser.DBC;
using WowPacketParser.Enums;
using WowPacketParser.Misc;
using WowPacketParser.Parsing;
using WowPacketParser.Store;
Expand Down Expand Up @@ -282,5 +283,63 @@ public static void QuestGiverOfferReward(Packet packet)
Storage.LocalesQuestOfferRewards.Add(localesQuestOfferReward, packet.TimeSpan);
}
}

[Parser(Opcode.SMSG_UI_MAP_QUEST_LINES_RESPONSE)]
public static void HandleUiMapQuestLinesResponse(Packet packet)
{
var uiMap = packet.ReadInt32("UiMapID");
var questLineXQuestCount = packet.ReadUInt32();
var questCount = packet.ReadUInt32();
var questLineCount = packet.ReadUInt32();

for (int i = 0; i < questLineXQuestCount; i++)
{
var questLineXQuestId = packet.ReadUInt32();

if (Settings.UseDBC && DBC.QuestLineXQuest.ContainsKey((int)questLineXQuestId))
{
if (DBC.QuestLineXQuest.TryGetValue((int)questLineXQuestId, out var questLineXQuest))
{
var questLineId = questLineXQuest.QuestLineID;
var questId = questLineXQuest.QuestID;

UIMapQuestLine uiMapQuestLine = new()
{
UIMapId = (uint)uiMap,
QuestLineId = questLineId
};
Storage.UIMapQuestLines.Add(uiMapQuestLine, packet.TimeSpan);

packet.WriteLine($"[{i}] QuestLineXQuestID: {questLineXQuestId} (QuestID: {questId} QuestLineID: {questLineId})");
}
}
else
packet.AddValue($"QuestLineXQuestID", questLineXQuestId, i);
}

for (int i = 0; i < questCount; i++)
{
var questId = packet.ReadUInt32<QuestId>("QuestID", i);

UIMapQuest uiMapQuest = new UIMapQuest
{
UIMapId = (uint)uiMap,
QuestId = questId
};
Storage.UIMapQuests.Add(uiMapQuest, packet.TimeSpan);
}

for (int i = 0; i < questLineCount; i++)
{
var questLineId = packet.ReadUInt32("QuestLineID", i);

UIMapQuestLine uiMapQuestLine = new()
{
UIMapId = (uint)uiMap,
QuestLineId = questLineId
};
Storage.UIMapQuestLines.Add(uiMapQuestLine, packet.TimeSpan);
}
}
}
}

0 comments on commit 47216a9

Please sign in to comment.