From a42f1a093b1b8391027fac67c0212ea9635ca2f7 Mon Sep 17 00:00:00 2001 From: harliq <30803300+harliq@users.noreply.github.com> Date: Sun, 24 Oct 2021 01:42:27 -0400 Subject: [PATCH 1/6] Ver 720 --- WeenieFab/WeenieFab/WeenieFab.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WeenieFab/WeenieFab/WeenieFab.csproj b/WeenieFab/WeenieFab/WeenieFab.csproj index 8a95b5b..4ac2647 100644 --- a/WeenieFab/WeenieFab/WeenieFab.csproj +++ b/WeenieFab/WeenieFab/WeenieFab.csproj @@ -6,7 +6,7 @@ true 0.9.9.701 WeenieFabAppIcon.ico - 0.9.9.701 + 0.9.9.720 0.9.9.701 From 0d6304b25fd6a6fbaa5266f04db7664892db2acf Mon Sep 17 00:00:00 2001 From: harliq <30803300+harliq@users.noreply.github.com> Date: Tue, 26 Oct 2021 20:01:32 -0400 Subject: [PATCH 2/6] code change --- WeenieFab/WeenieFab/TableToSql.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WeenieFab/WeenieFab/TableToSql.cs b/WeenieFab/WeenieFab/TableToSql.cs index b520e87..da11ad4 100644 --- a/WeenieFab/WeenieFab/TableToSql.cs +++ b/WeenieFab/WeenieFab/TableToSql.cs @@ -534,7 +534,7 @@ public static string ConvertIidTable(DataTable dt, string wcid, string header) int iidValue = 0; string checkHex = row[1].ToString(); if (checkHex.Contains("x") || checkHex.Contains("X")) - iidValue = (int) MainWindow.ConvertToDecimal(checkHex); + iidValue = (int)MainWindow.ConvertToDecimal(checkHex); else iidValue = MainWindow.ConvertToInteger(checkHex); From 713659c1e99b9688f93b63628051d17d244c947b Mon Sep 17 00:00:00 2001 From: harliq <30803300+harliq@users.noreply.github.com> Date: Thu, 4 Nov 2021 00:03:26 -0400 Subject: [PATCH 3/6] Fixed Reading Hex from DID and IID --- WeenieFab/WeenieFab/Decode.cs | 24 +++++++++++-- WeenieFab/WeenieFab/FileOps.cs | 49 ++++++++++++++++++++++++-- WeenieFab/WeenieFab/MainWindow.xaml.cs | 21 +++++++++-- 3 files changed, 86 insertions(+), 8 deletions(-) diff --git a/WeenieFab/WeenieFab/Decode.cs b/WeenieFab/WeenieFab/Decode.cs index 03fd7f8..1e3ac5d 100644 --- a/WeenieFab/WeenieFab/Decode.cs +++ b/WeenieFab/WeenieFab/Decode.cs @@ -65,11 +65,29 @@ public static DataTable DecodeInstanceID(string integerblob, string pattern) // Check for Hex int iidValue = 0; - string checkHex = match.Groups[3].ToString(); - if (checkHex.Contains("x") || checkHex.Contains("X")) - iidValue = (int)MainWindow.ConvertToDecimal(checkHex); + string checkHex = ""; + if (match.Groups[3].ToString().Contains("0x")) + { + checkHex = match.Groups[3].ToString().Replace("0x", ""); + iidValue = MainWindow.ConvertHexToDecimal(checkHex); + } + else if (match.Groups[3].ToString().Contains("0X")) + { + checkHex = match.Groups[3].ToString().Replace("0X", ""); + iidValue = MainWindow.ConvertHexToDecimal(checkHex); + } else + { iidValue = MainWindow.ConvertToInteger(checkHex); + } + + + //string checkHex = match.Groups[3].ToString().Replace("0x" || "0X", ""); + + //if (checkHex.Contains("x") || checkHex.Contains("X")) + // iidValue = MainWindow.ConvertHexToDecimal(checkHex); + //else + // iidValue = MainWindow.ConvertToInteger(checkHex); dr[0] = MainWindow.ConvertToInteger(match.Groups[2].ToString()); dr[1] = iidValue; diff --git a/WeenieFab/WeenieFab/FileOps.cs b/WeenieFab/WeenieFab/FileOps.cs index ffd75bb..16f03b7 100644 --- a/WeenieFab/WeenieFab/FileOps.cs +++ b/WeenieFab/WeenieFab/FileOps.cs @@ -195,7 +195,11 @@ public void ReadSQLFile(string filepath) var floatPattern = @"\((\d+),\s*(\d+),\s*([-+]?[0-9]*\.[0-9]+|[0-9]+)\)\s*\/\*\s*(.*)\s*\*\/*.*$"; // Spells also uses same pattern. var stringPattern = @"\((\d+),\s*(\d+),\s*'(.*)'\)\s*\/\*\s*(.*)\s*\*\/.*.*$"; // var stringPattern = @"\((\d+),\s*(\d+),\s*'([a-zA-Z0-9_ .!?]*)'\)\s*\/\*\s*(.*)\s*\*\/.*.*$"; - var didPattern = @"\((\d+),\s*(\d+),\s*(-?\d+)\) \/\*(.*)\*\/*.*$"; + // var didPattern = @"\((\d+),\s*(\d+),\s*(-?\d+)\) \/\*(.*)\*\/*.*$"; + // var didPattern = @"\((\d+),\s*(\d+),\s*(-?\d+)\) \/\*(.*)\*\/*.*$|\((\d+),\s*(\d+),\s*(-?0[xX][0-9a-fA-F]+)\) \/\*(.*)\*\/*.*$"; + + var didPattern = @"\((\d+),\s*(\d+),\s*(-?[a-zA-Z0-9_.-]*)\) \/\*(.*)\*\/*.*$"; + var attribPattern = @"\((\d+),\s*(\d+),\s*(\d+),\s*(\d+),\s*(\d+)\) \/\*(.*)\*\/*.*$"; var attrib2Pattern = @"\((\d+),\s*(\d+),\s*(\d+),\s*(\d+),\s*(\d+),\s*(\d+)\) \/\*(.*)\*\/*.*$"; var skillsPattern = @"\((\d+),\s*(\d+),\s*(\d+),\s*(\d+),\s*(\d+),\s*(\d+),\s*(\d+),\s*([-+]?[0-9]*\.[0-9]+|[-+]?[0-9]+)\) \/\*(.*)\*\/*.*$"; @@ -269,7 +273,7 @@ public void ReadSQLFile(string filepath) else if (line.Contains("INSERT INTO `weenie_properties_d_i_d`")) { didBlob = ReadBlob(sr); - didDataTable = DecodeSql.DecodeThreeValuesInt(didBlob, didPattern); + didDataTable = DecodeSql.DecodeInstanceID(didBlob, didPattern); didDataTable.AcceptChanges(); didDataTable = ResortDataTable(didDataTable, "Property", "ASC"); dgDiD.DataContext = didDataTable; @@ -708,6 +712,47 @@ private async void ProgressBarClearAnimation() pgBarOne.BeginAnimation(ProgressBar.ValueProperty, null); } + public static bool IsHexProperty(int property) + { + switch (property) + { + + case 43: //PropertyDataId.AccountHouseId: + case 57: //PropertyDataId.AlternateCurrency: + case 56: //PropertyDataId.AugmentationCreateItem: + case 54: //PropertyDataId.AugmentationEffect: + case 58: //PropertyDataId.BlueSurgeSpell: + case 39: //PropertyDataId.DeathSpell: + case 35: //PropertyDataId.DeathTreasureType: + case 42: //PropertyDataId.HouseId: + case 37: //PropertyDataId.ItemSkillLimit: + case 41: //PropertyDataId.ItemSpecializedOnly: + case 47: //PropertyDataId.LastPortal: + case 31: //PropertyDataId.LinkedPortalOne: + case 48: //PropertyDataId.LinkedPortalTwo: + case 61: //PropertyDataId.OlthoiDeathTreasureType: + case 49: //PropertyDataId.OriginalPortal: + case 30: //PropertyDataId.PhysicsScript: + case 55: //PropertyDataId.ProcSpell: + case 60: //PropertyDataId.RedSurgeSpell: + case 44: //PropertyDataId.RestrictionEffect: + case 28: //PropertyDataId.Spell: + case 29: //PropertyDataId.SpellComponent: + case 38: //PropertyDataId.UseCreateItem: + case 23: //PropertyDataId.UseSound: + case 40: //PropertyDataId.VendorsClassId: + case 32: //PropertyDataId.WieldedTreasureType: + case 59: //PropertyDataId.YellowSurgeSpell: + + case int i when i >= 8001: + return false; + + + default: + return true; + } + + } } } diff --git a/WeenieFab/WeenieFab/MainWindow.xaml.cs b/WeenieFab/WeenieFab/MainWindow.xaml.cs index 55f6132..3d587ea 100644 --- a/WeenieFab/WeenieFab/MainWindow.xaml.cs +++ b/WeenieFab/WeenieFab/MainWindow.xaml.cs @@ -286,10 +286,25 @@ public static decimal ConvertToDecimal(string text) decimal.TryParse(text, out i); return i; } - public static decimal ConvertHexToDecimal(string text) + public static int ConvertHexToDecimal(string hexValue) { - decimal i = 0; - decimal.TryParse(text, out i); + //decimal i = 0; + //decimal.TryParse(text, out i); + //return i; + int i = 0; + //int i = int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber); + Int32.TryParse(hexValue, out i); + + try + { + i = int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber); + } + catch (Exception) + { + + throw; + } + return i; } // UI Stuff From fc964a5bb6687b16aec9e55d31b8db142856b79a Mon Sep 17 00:00:00 2001 From: harliq <30803300+harliq@users.noreply.github.com> Date: Thu, 4 Nov 2021 00:46:14 -0400 Subject: [PATCH 4/6] Writes Hex for correct fields --- WeenieFab/WeenieFab/FileOps.cs | 42 +--------- WeenieFab/WeenieFab/MainWindow.xaml.cs | 10 +++ WeenieFab/WeenieFab/TableToSql.cs | 102 ++++++++++++++++++++++++- 3 files changed, 110 insertions(+), 44 deletions(-) diff --git a/WeenieFab/WeenieFab/FileOps.cs b/WeenieFab/WeenieFab/FileOps.cs index 16f03b7..f81d305 100644 --- a/WeenieFab/WeenieFab/FileOps.cs +++ b/WeenieFab/WeenieFab/FileOps.cs @@ -465,7 +465,7 @@ public void WriteSQLFile(string filename) // DiD header = $"INSERT INTO `weenie_properties_d_i_d` (`object_Id`, `type`, `value`)"; - body += TableToSql.ConvertTriValueTable(didDataTable, tbWCID.Text, header); + body += TableToSql.ConvertDidTable(didDataTable, tbWCID.Text, header); // IiD header = $"INSERT INTO `weenie_properties_i_i_d` (`object_Id`, `type`, `value`)"; @@ -712,47 +712,7 @@ private async void ProgressBarClearAnimation() pgBarOne.BeginAnimation(ProgressBar.ValueProperty, null); } - public static bool IsHexProperty(int property) - { - switch (property) - { - case 43: //PropertyDataId.AccountHouseId: - case 57: //PropertyDataId.AlternateCurrency: - case 56: //PropertyDataId.AugmentationCreateItem: - case 54: //PropertyDataId.AugmentationEffect: - case 58: //PropertyDataId.BlueSurgeSpell: - case 39: //PropertyDataId.DeathSpell: - case 35: //PropertyDataId.DeathTreasureType: - case 42: //PropertyDataId.HouseId: - case 37: //PropertyDataId.ItemSkillLimit: - case 41: //PropertyDataId.ItemSpecializedOnly: - case 47: //PropertyDataId.LastPortal: - case 31: //PropertyDataId.LinkedPortalOne: - case 48: //PropertyDataId.LinkedPortalTwo: - case 61: //PropertyDataId.OlthoiDeathTreasureType: - case 49: //PropertyDataId.OriginalPortal: - case 30: //PropertyDataId.PhysicsScript: - case 55: //PropertyDataId.ProcSpell: - case 60: //PropertyDataId.RedSurgeSpell: - case 44: //PropertyDataId.RestrictionEffect: - case 28: //PropertyDataId.Spell: - case 29: //PropertyDataId.SpellComponent: - case 38: //PropertyDataId.UseCreateItem: - case 23: //PropertyDataId.UseSound: - case 40: //PropertyDataId.VendorsClassId: - case 32: //PropertyDataId.WieldedTreasureType: - case 59: //PropertyDataId.YellowSurgeSpell: - - case int i when i >= 8001: - return false; - - - default: - return true; - } - - } } } diff --git a/WeenieFab/WeenieFab/MainWindow.xaml.cs b/WeenieFab/WeenieFab/MainWindow.xaml.cs index 3d587ea..12cd65e 100644 --- a/WeenieFab/WeenieFab/MainWindow.xaml.cs +++ b/WeenieFab/WeenieFab/MainWindow.xaml.cs @@ -307,6 +307,16 @@ public static int ConvertHexToDecimal(string hexValue) return i; } + public static string ConvertToHex(string value) + { + + int i = ConvertToInteger(value); + string hexValue = i.ToString("X8"); + + return hexValue; + + } + // UI Stuff public void ClearAllDataTables() { diff --git a/WeenieFab/WeenieFab/TableToSql.cs b/WeenieFab/WeenieFab/TableToSql.cs index da11ad4..c203397 100644 --- a/WeenieFab/WeenieFab/TableToSql.cs +++ b/WeenieFab/WeenieFab/TableToSql.cs @@ -531,13 +531,67 @@ public static string ConvertIidTable(DataTable dt, string wcid, string header) foreach (DataRow row in dt.Rows) { // Check for Hex - int iidValue = 0; + string iidValue = ""; + //int iidValue = 0; string checkHex = row[1].ToString(); if (checkHex.Contains("x") || checkHex.Contains("X")) - iidValue = (int)MainWindow.ConvertToDecimal(checkHex); + { + // iidValue = (int)MainWindow.ConvertToDecimal(checkHex); + iidValue = checkHex; + } else - iidValue = MainWindow.ConvertToInteger(checkHex); + { + iidValue = "0x" + MainWindow.ConvertToHex(checkHex); + } + + if (counter == 1 && counter == rowcount) + sqltext += $" ({wcid},{row[0],4},{iidValue,11}) /* {row[2]} */;\n"; + else if (counter == 1) + sqltext += $" ({wcid},{row[0],4},{iidValue,11}) /* {row[2]} */\n"; + else + { + if (counter == rowcount) + sqltext += $" , ({wcid},{row[0],4},{iidValue,11}) /* {row[2]} */;\n"; + else + sqltext += $" , ({wcid},{row[0],4},{iidValue,11}) /* {row[2]} */\n"; + } + counter++; + } + } + if (rowcount > 0) + sqltext += $"\n"; + else + { + } + return sqltext; + } + public static string ConvertDidTable(DataTable dt, string wcid, string header) + { + string sqltext = ""; + int counter = 1; + int rowcount = dt.Rows.Count; + + if (rowcount > 0) + { + sqltext = header + $"\nVALUES"; + foreach (DataRow row in dt.Rows) + { + int propertyValue = MainWindow.ConvertToInteger(row[0].ToString()); + // Check for Hex + string iidValue = ""; + //int iidValue = 0; + string checkHex = row[1].ToString(); + if (checkHex.Contains("x") || checkHex.Contains("X")) + { + // iidValue = (int)MainWindow.ConvertToDecimal(checkHex); + iidValue = checkHex; + } + else + { + if (IsHexProperty(propertyValue)) + iidValue = "0x" + MainWindow.ConvertToHex(checkHex); + } if (counter == 1 && counter == rowcount) sqltext += $" ({wcid},{row[0],4},{iidValue,11}) /* {row[2]} */;\n"; @@ -560,5 +614,47 @@ public static string ConvertIidTable(DataTable dt, string wcid, string header) } return sqltext; } + public static bool IsHexProperty(int property) + { + switch (property) + { + + case 43: //PropertyDataId.AccountHouseId: + case 57: //PropertyDataId.AlternateCurrency: + case 56: //PropertyDataId.AugmentationCreateItem: + case 54: //PropertyDataId.AugmentationEffect: + case 58: //PropertyDataId.BlueSurgeSpell: + case 39: //PropertyDataId.DeathSpell: + case 35: //PropertyDataId.DeathTreasureType: + case 42: //PropertyDataId.HouseId: + case 37: //PropertyDataId.ItemSkillLimit: + case 41: //PropertyDataId.ItemSpecializedOnly: + case 47: //PropertyDataId.LastPortal: + case 31: //PropertyDataId.LinkedPortalOne: + case 48: //PropertyDataId.LinkedPortalTwo: + case 61: //PropertyDataId.OlthoiDeathTreasureType: + case 49: //PropertyDataId.OriginalPortal: + case 30: //PropertyDataId.PhysicsScript: + case 55: //PropertyDataId.ProcSpell: + case 60: //PropertyDataId.RedSurgeSpell: + case 44: //PropertyDataId.RestrictionEffect: + case 28: //PropertyDataId.Spell: + case 29: //PropertyDataId.SpellComponent: + case 38: //PropertyDataId.UseCreateItem: + case 23: //PropertyDataId.UseSound: + case 40: //PropertyDataId.VendorsClassId: + case 32: //PropertyDataId.WieldedTreasureType: + case 59: //PropertyDataId.YellowSurgeSpell: + + case int i when i >= 8001: + return false; + + + default: + return true; + } + + } + } } From d5d95632e8ba230ccefa7c419d879249effdb456 Mon Sep 17 00:00:00 2001 From: harliq <30803300+harliq@users.noreply.github.com> Date: Thu, 4 Nov 2021 00:49:00 -0400 Subject: [PATCH 5/6] Ver 731 --- WeenieFab/WeenieFab/WeenieFab.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WeenieFab/WeenieFab/WeenieFab.csproj b/WeenieFab/WeenieFab/WeenieFab.csproj index 4ac2647..87d2e2b 100644 --- a/WeenieFab/WeenieFab/WeenieFab.csproj +++ b/WeenieFab/WeenieFab/WeenieFab.csproj @@ -4,10 +4,10 @@ WinExe netcoreapp3.1 true - 0.9.9.701 + 0.9.9.731 WeenieFabAppIcon.ico - 0.9.9.720 - 0.9.9.701 + 0.9.9.731 + 0.9.9.731 From 4eebae25b9e849f493159cdcf5a76e02b08b31db Mon Sep 17 00:00:00 2001 From: harliq <30803300+harliq@users.noreply.github.com> Date: Thu, 4 Nov 2021 22:10:35 -0400 Subject: [PATCH 6/6] Cleanup --- WeenieFab/WeenieFab/Decode.cs | 42 ---------------------------------- WeenieFab/WeenieFab/FileOps.cs | 5 ---- 2 files changed, 47 deletions(-) diff --git a/WeenieFab/WeenieFab/Decode.cs b/WeenieFab/WeenieFab/Decode.cs index 1e3ac5d..1474a5a 100644 --- a/WeenieFab/WeenieFab/Decode.cs +++ b/WeenieFab/WeenieFab/Decode.cs @@ -81,14 +81,6 @@ public static DataTable DecodeInstanceID(string integerblob, string pattern) iidValue = MainWindow.ConvertToInteger(checkHex); } - - //string checkHex = match.Groups[3].ToString().Replace("0x" || "0X", ""); - - //if (checkHex.Contains("x") || checkHex.Contains("X")) - // iidValue = MainWindow.ConvertHexToDecimal(checkHex); - //else - // iidValue = MainWindow.ConvertToInteger(checkHex); - dr[0] = MainWindow.ConvertToInteger(match.Groups[2].ToString()); dr[1] = iidValue; dr[2] = description.Trim(); @@ -99,18 +91,7 @@ public static DataTable DecodeInstanceID(string integerblob, string pattern) public static DataTable DecodeInt64(string integerblob, string pattern) { - //DataTable tempDataTable = new DataTable(); - - //DataColumn propertyInt = new DataColumn("Property"); - //DataColumn valueInt = new DataColumn("Value"); - //DataColumn descript = new DataColumn("Description"); - - //propertyInt.DataType = Type.GetType("System.Int32"); - //valueInt.DataType = Type.GetType("System.Int32"); - //tempDataTable.Columns.Add(propertyInt); - //tempDataTable.Columns.Add(valueInt); - //tempDataTable.Columns.Add(descript); DataTable tempDataTable = MainWindow.integer64DataTable.Clone(); tempDataTable.Clear(); @@ -164,17 +145,6 @@ public static DataTable DecodeThreeValuesBool(string boolblob, string pattern) { DataTable tempDataTable = MainWindow.boolDataTable.Clone(); tempDataTable.Clear(); - //DataTable tempDataTable = new DataTable(); - - //DataColumn propertyInt = new DataColumn("Property"); - //DataColumn valueBool = new DataColumn("Value"); - //DataColumn descript = new DataColumn("Description"); - //propertyInt.DataType = Type.GetType("System.Int32"); - //valueBool.DataType = Type.GetType("System.Boolean"); - - //tempDataTable.Columns.Add(propertyInt); - //tempDataTable.Columns.Add(valueBool); - //tempDataTable.Columns.Add(descript); foreach (var blobLine in boolblob.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { @@ -202,18 +172,6 @@ public static DataTable DecodeThreeValuesString(string floatblob, string pattern DataTable tempDataTable = MainWindow.stringDataTable.Clone(); tempDataTable.Clear(); - //DataTable tempDataTable = new DataTable(); - - //DataColumn propertyInt = new DataColumn("Property"); - //DataColumn valueString = new DataColumn("Value"); - //DataColumn descript = new DataColumn("Description"); - //propertyInt.DataType = Type.GetType("System.Int32"); - //valueString.DataType = Type.GetType("System.String"); - - //tempDataTable.Columns.Add(propertyInt); - //tempDataTable.Columns.Add(valueString); - //tempDataTable.Columns.Add(descript); - foreach (var blobLine in floatblob.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { if (blobLine.Contains("\"")) diff --git a/WeenieFab/WeenieFab/FileOps.cs b/WeenieFab/WeenieFab/FileOps.cs index f81d305..bcaf02d 100644 --- a/WeenieFab/WeenieFab/FileOps.cs +++ b/WeenieFab/WeenieFab/FileOps.cs @@ -385,11 +385,6 @@ public void ReadSQLFile(string filepath) dgCreateItems.DataContext = createListDataTable; dgCreateItems.Items.Refresh(); - //createListDataTable = DecodeSql.DecodeThreeValuesFloat(createListBlob, createListPattern); - //createListDataTable.AcceptChanges(); - //// createListDataTable = ResortDataTable(spellDataTable, "Property", "ASC"); - //dgCreateItems.DataContext = createListDataTable; - } }