From f8384ec18ca4c10eee55f8d0939eea388d052a80 Mon Sep 17 00:00:00 2001 From: RedWine Date: Fri, 5 Jan 2024 10:25:47 -0500 Subject: [PATCH 1/4] Placed the AvailableSheets foreach loop of InvokeAsync in SqlExport in a try/catch to avoid having the whole process fail because certain sheets return "Unable to read beyond the end of the stream". --- SaintCoinach.Cmd/Commands/SqlExport.cs | 99 ++++++++++++++------------ 1 file changed, 53 insertions(+), 46 deletions(-) diff --git a/SaintCoinach.Cmd/Commands/SqlExport.cs b/SaintCoinach.Cmd/Commands/SqlExport.cs index ba755ff3..59e36eb4 100644 --- a/SaintCoinach.Cmd/Commands/SqlExport.cs +++ b/SaintCoinach.Cmd/Commands/SqlExport.cs @@ -179,56 +179,63 @@ public override async Task InvokeAsync(string[] paramList) // .Where(n => !n.Contains("quest/") && !n.Contains("custom/")) foreach (var name in _Realm.GameData.AvailableSheets) { - var sheet = _Realm.GameData.GetSheet(name); - var variant = sheet.Header.Variant; - var sheet2 = sheet as XivSheet2; - - Console.WriteLine($"Sheet: {name}, variant: {variant}"); - - if (sheet.Count == 0) - continue; - - var sb = new StringBuilder(); - - sb.AppendLine($"CREATE TABLE {GetTableName(sheet)} ("); - - // key meme - if (sheet.Header.Variant == 1) - { - sb.AppendLine($" `_Key` INT NOT NULL,"); - } - else - { - sb.AppendLine($" `_Key` INT NOT NULL,"); - sb.AppendLine($" `_SubKey` INT NOT NULL,"); - } - - // add cols - foreach (var column in sheet.Header.Columns) - { - var colName = column.Name; - if (string.IsNullOrEmpty(colName)) - colName = $"unk{column.Index}"; - - sb.AppendLine($" `{colName}` {GetSqlType(column.Reader.Type)},"); - } - - // primary key - if (sheet.Header.Variant == 1) + try { - sb.AppendLine($" PRIMARY KEY (`_Key`)"); + var sheet = _Realm.GameData.GetSheet(name); + var variant = sheet.Header.Variant; + var sheet2 = sheet as XivSheet2; + + Console.WriteLine($"Sheet: {name}, variant: {variant}"); + + if (sheet.Count == 0) + continue; + + var sb = new StringBuilder(); + + sb.AppendLine($"CREATE TABLE {GetTableName(sheet)} ("); + + // key meme + if (sheet.Header.Variant == 1) + { + sb.AppendLine($" `_Key` INT NOT NULL,"); + } + else + { + sb.AppendLine($" `_Key` INT NOT NULL,"); + sb.AppendLine($" `_SubKey` INT NOT NULL,"); + } + + // add cols + foreach (var column in sheet.Header.Columns) + { + var colName = column.Name; + if (string.IsNullOrEmpty(colName)) + colName = $"unk{column.Index}"; + + sb.AppendLine($" `{colName}` {GetSqlType(column.Reader.Type)},"); + } + + // primary key + if (sheet.Header.Variant == 1) + { + sb.AppendLine($" PRIMARY KEY (`_Key`)"); + } + else + { + sb.AppendLine($" PRIMARY KEY (`_Key`, `_SubKey`)"); + } + + sb.AppendLine(") COLLATE='utf8mb4_unicode_ci' ENGINE=MyISAM;"); + sb.AppendLine(); + + WriteRows(sheet, sb); + + imports.Add(sb.ToString()); } - else + catch (Exception e) { - sb.AppendLine($" PRIMARY KEY (`_Key`, `_SubKey`)"); + Console.WriteLine($"Failed to export {name}: {e}"); } - - sb.AppendLine(") COLLATE='utf8mb4_unicode_ci' ENGINE=MyISAM;"); - sb.AppendLine(); - - WriteRows(sheet, sb); - - imports.Add(sb.ToString()); } File.WriteAllText("schema.sql", string.Join(Environment.NewLine, imports)); From e54eb77fc7f04be0449dce5e8223e1af1e78cd03 Mon Sep 17 00:00:00 2001 From: RedWine82 Date: Fri, 5 Jan 2024 17:22:48 -0500 Subject: [PATCH 2/4] Added InclusionShop files --- SaintCoinach/Xiv/InclusionShop.cs | 33 +++++++++++++++++++++ SaintCoinach/Xiv/InclusionShopCategory.cs | 36 +++++++++++++++++++++++ SaintCoinach/Xiv/InclusionShopSeries.cs | 16 ++++++++++ 3 files changed, 85 insertions(+) create mode 100644 SaintCoinach/Xiv/InclusionShop.cs create mode 100644 SaintCoinach/Xiv/InclusionShopCategory.cs create mode 100644 SaintCoinach/Xiv/InclusionShopSeries.cs diff --git a/SaintCoinach/Xiv/InclusionShop.cs b/SaintCoinach/Xiv/InclusionShop.cs new file mode 100644 index 00000000..2e1b1cbd --- /dev/null +++ b/SaintCoinach/Xiv/InclusionShop.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using SaintCoinach.Ex.Relational; + +namespace SaintCoinach.Xiv; + +public class InclusionShop: XivRow +{ + private List _Categories; + + public IEnumerable Categories => _Categories ??= BuildCategories(); + + public bool IsValid => Categories.Any(); + + public byte UknownByte => As(1); + + private List BuildCategories() + { + var list = new List(); + for (var i = 0; i < 30; i++) + { + var cat = As($"Category[{i}]"); + if (cat.Key != 0) + list.Add(cat); + } + return list; + } + + public InclusionShop(IXivSheet sheet, IRelationalRow sourceRow) : base(sheet, sourceRow) + { + } +} \ No newline at end of file diff --git a/SaintCoinach/Xiv/InclusionShopCategory.cs b/SaintCoinach/Xiv/InclusionShopCategory.cs new file mode 100644 index 00000000..7e2c3615 --- /dev/null +++ b/SaintCoinach/Xiv/InclusionShopCategory.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using SaintCoinach.Ex.Relational; + +namespace SaintCoinach.Xiv; + +public class InclusionShopCategory : XivRow +{ + public string Name => AsString("Name"); + + public ClassJobCategory ClassJobCategory => As(); + + public IEnumerable Series => AsSubRows(); + + private IEnumerable AsSubRows() where T : XivSubRow + { + return AsSubRows(typeof(T).Name); + } + private IEnumerable AsSubRows(string rowName) where T :XivSubRow + { + var sheetName = typeof(T).Name; + var key = (ushort)GetRaw(rowName); + + var sheet = Sheet.Collection.GetSheet2(sheetName) + .Cast() + .Where(r => r.ParentKey == key) + .ToArray(); + + return sheet; + } + + public InclusionShopCategory(IXivSheet sheet, IRelationalRow sourceRow) : base(sheet, sourceRow) + { + } +} \ No newline at end of file diff --git a/SaintCoinach/Xiv/InclusionShopSeries.cs b/SaintCoinach/Xiv/InclusionShopSeries.cs new file mode 100644 index 00000000..744b46c2 --- /dev/null +++ b/SaintCoinach/Xiv/InclusionShopSeries.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; +using System.Linq; +using SaintCoinach.Ex.Relational; + +namespace SaintCoinach.Xiv; + +public class InclusionShopSeries: XivSubRow +{ + public SpecialShop SpecialShop => As(); + + public IEnumerable Items => SpecialShop.Items.SelectMany(i=> i.Rewards.Select(i=> i.Item)); + + public InclusionShopSeries(IXivSheet sheet, IRelationalRow sourceRow) : base(sheet, sourceRow) + { + } +} \ No newline at end of file From b3fe1b0a67696b1c77a952e8852d852560b502d2 Mon Sep 17 00:00:00 2001 From: RedWine Date: Wed, 17 Jul 2024 13:43:28 -0400 Subject: [PATCH 3/4] Updated _Currencies for DW --- SaintCoinach/Xiv/SpecialShopListing.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/SaintCoinach/Xiv/SpecialShopListing.cs b/SaintCoinach/Xiv/SpecialShopListing.cs index 77c5be90..0c5d3ddd 100644 --- a/SaintCoinach/Xiv/SpecialShopListing.cs +++ b/SaintCoinach/Xiv/SpecialShopListing.cs @@ -10,10 +10,20 @@ public class SpecialShopListing : IShopListing { private static Dictionary _Currencies = new Dictionary() { { 1, 28 }, - { 2, 25199 }, - { 4, 25200 }, - { 6, 33913 }, - { 7, 33914 } + + // 6.0 + /* + { 2, 25199 }, // White Crafters Scrips + { 4, 25200 }, // White Gatherers Scrips + { 6, 33913 }, // Purple Crafters Scrips + { 7, 33914 } // Purple Gatherers Scrips + */ + + // 7.0 + { 2, 33913 }, // Purple Crafters Scrips + { 4, 33914 }, // Purple Gatherers Scrips + { 6, 41784 }, // Orange Crafters Scrips + { 7, 41785 } // Orange Gatherers Scrips }; private static Dictionary _Tomestones; @@ -129,7 +139,7 @@ public SpecialShopListing(SpecialShop shop, int index) { } hq = false; } - + var collectabilityRating = shop.AsInt16("CollectabilityRating{Cost}", index, i); costs.Add(new ShopListingItem(this, item, count, hq, collectabilityRating)); @@ -161,4 +171,4 @@ public SpecialShopListing(SpecialShop shop, int index) { #endregion } -} +} \ No newline at end of file From 8eb3e87d94e4cc8f3e65645512f5f107183a613c Mon Sep 17 00:00:00 2001 From: RedWine Date: Thu, 1 Aug 2024 14:42:08 -0400 Subject: [PATCH 4/4] Added AchievementUnlock --- SaintCoinach/Xiv/SpecialShopListing.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SaintCoinach/Xiv/SpecialShopListing.cs b/SaintCoinach/Xiv/SpecialShopListing.cs index 0c5d3ddd..8a37d9da 100644 --- a/SaintCoinach/Xiv/SpecialShopListing.cs +++ b/SaintCoinach/Xiv/SpecialShopListing.cs @@ -103,6 +103,8 @@ public SpecialShopListing(SpecialShop shop, int index) { _Rewards = rewards.ToArray(); Quest = shop.As("Quest{Item}", index); + AchievementUnlock = shop.As("AchievementUnlock", index); + int UseCurrencyType = shop.As("UseCurrencyType"); const int CostCount = 3; @@ -147,6 +149,8 @@ public SpecialShopListing(SpecialShop shop, int index) { _Costs = costs.ToArray(); } + public Achievement AchievementUnlock { get; set; } + #endregion ///