From 6ce8b40afb562ee09907ac69980916b874abf818 Mon Sep 17 00:00:00 2001 From: Daribon Date: Thu, 4 Jul 2024 00:26:53 +0200 Subject: [PATCH 1/4] Added MySQL to find creature names. --- WaypointCreatorGen2/App.config | 38 ++++++++++- .../Properties/Settings.Designer.cs | 66 +++++++++++++++---- .../Properties/Settings.settings | 26 ++++++-- WaypointCreatorGen2/WaypointCreator.cs | 41 +++++++++++- .../WaypointCreatorGen2.csproj | 53 +++++++++++++++ WaypointCreatorGen2/packages.config | 19 ++++++ 6 files changed, 221 insertions(+), 22 deletions(-) create mode 100644 WaypointCreatorGen2/packages.config diff --git a/WaypointCreatorGen2/App.config b/WaypointCreatorGen2/App.config index 56efbc7..89f90fc 100644 --- a/WaypointCreatorGen2/App.config +++ b/WaypointCreatorGen2/App.config @@ -1,6 +1,42 @@ - + + + +
+ + + + + + + + + + + + + + + + + + 127.0.0.1 + + + 3306 + + + world + + + trinity + + + trinity + + + \ No newline at end of file diff --git a/WaypointCreatorGen2/Properties/Settings.Designer.cs b/WaypointCreatorGen2/Properties/Settings.Designer.cs index b65d852..81246fc 100644 --- a/WaypointCreatorGen2/Properties/Settings.Designer.cs +++ b/WaypointCreatorGen2/Properties/Settings.Designer.cs @@ -8,22 +8,64 @@ // //------------------------------------------------------------------------------ - -namespace WaypointCreatorGen2.Properties -{ +namespace WaypointCreatorGen2.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("127.0.0.1")] + public string host { + get { + return ((string)(this["host"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("3306")] + public string port { + get { + return ((string)(this["port"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("world")] + public string database { + get { + return ((string)(this["database"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("trinity")] + public string username { + get { + return ((string)(this["username"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("trinity")] + public string password { + get { + return ((string)(this["password"])); + } + } } } diff --git a/WaypointCreatorGen2/Properties/Settings.settings b/WaypointCreatorGen2/Properties/Settings.settings index 3964565..0212b8c 100644 --- a/WaypointCreatorGen2/Properties/Settings.settings +++ b/WaypointCreatorGen2/Properties/Settings.settings @@ -1,7 +1,21 @@  - - - - - - + + + + + 127.0.0.1 + + + 3306 + + + world + + + trinity + + + trinity + + + \ No newline at end of file diff --git a/WaypointCreatorGen2/WaypointCreator.cs b/WaypointCreatorGen2/WaypointCreator.cs index 0d92fd7..ba5644e 100644 --- a/WaypointCreatorGen2/WaypointCreator.cs +++ b/WaypointCreatorGen2/WaypointCreator.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; +using MySql.Data.MySqlClient; namespace WaypointCreatorGen2 { @@ -22,6 +23,17 @@ public partial class WaypointCreator : Form private const int SEQUENCE_TO_CHECK_FOR_DUPLICATES = 3; + private string GetConnectionString() + { + var host = Properties.Settings.Default.host; + var database = Properties.Settings.Default.database; + var username = Properties.Settings.Default.username; + var password = Properties.Settings.Default.password; + var port = Properties.Settings.Default.port; + + return $"server={host};user={username};database={database};port={port};password={password};"; + } + public WaypointCreator() { InitializeComponent(); @@ -213,22 +225,45 @@ private void ListEntries(UInt32 creatureId) { foreach (var waypointsByEntry in WaypointDatabyCreatureEntry) { - CreatureNamesByEntry.TryGetValue(waypointsByEntry.Key, out var name); + var name = GetCreatureName(waypointsByEntry.Key); foreach (var waypointsByGuid in waypointsByEntry.Value) EditorListBox.Items.Add($"{waypointsByEntry.Key} - {name} ({waypointsByGuid.Key})"); } - } else { if (WaypointDatabyCreatureEntry.ContainsKey(creatureId)) { - CreatureNamesByEntry.TryGetValue(creatureId, out var name); + var name = GetCreatureName(creatureId); foreach (var waypointsByGuid in WaypointDatabyCreatureEntry[creatureId]) EditorListBox.Items.Add($"{creatureId} - {name} ({waypointsByGuid.Key.ToString()})"); } + } + } + + private string GetCreatureName(UInt32 entry) + { + string name = string.Empty; + string query = "SELECT `name` FROM `creature_template` WHERE `entry` = @entry"; + using (MySqlConnection conn = new MySqlConnection(GetConnectionString())) + { + conn.Open(); + using (MySqlCommand cmd = new MySqlCommand(query, conn)) + { + cmd.Parameters.AddWithValue("@entry", entry); + + using (MySqlDataReader reader = cmd.ExecuteReader()) + { + if (reader.Read()) + { + name = reader["name"].ToString(); + } + } + } } + + return name; } private void ShowWaypointDataForCreature(UInt32 creatureId, UInt64 lowGUID) diff --git a/WaypointCreatorGen2/WaypointCreatorGen2.csproj b/WaypointCreatorGen2/WaypointCreatorGen2.csproj index 6547645..6bece20 100644 --- a/WaypointCreatorGen2/WaypointCreatorGen2.csproj +++ b/WaypointCreatorGen2/WaypointCreatorGen2.csproj @@ -33,8 +33,57 @@ 4 + + ..\packages\BouncyCastle.Cryptography.2.3.1\lib\net461\BouncyCastle.Cryptography.dll + + + ..\packages\Google.Protobuf.3.26.1\lib\net45\Google.Protobuf.dll + + + ..\packages\K4os.Compression.LZ4.1.3.8\lib\net462\K4os.Compression.LZ4.dll + + + ..\packages\K4os.Compression.LZ4.Streams.1.3.8\lib\net462\K4os.Compression.LZ4.Streams.dll + + + ..\packages\K4os.Hash.xxHash.1.0.8\lib\net462\K4os.Hash.xxHash.dll + + + ..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\MySql.Data.9.0.0\lib\net462\MySql.Data.dll + + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + + ..\packages\System.Configuration.ConfigurationManager.8.0.0\lib\net462\System.Configuration.ConfigurationManager.dll + + + ..\packages\System.Diagnostics.DiagnosticSource.8.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.IO.Pipelines.5.0.2\lib\net461\System.IO.Pipelines.dll + + + + ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + @@ -45,6 +94,9 @@ + + ..\packages\ZstdSharp.Port.0.8.0\lib\net462\ZstdSharp.dll + @@ -63,6 +115,7 @@ Designer Resources.Designer.cs + SettingsSingleFileGenerator Settings.Designer.cs diff --git a/WaypointCreatorGen2/packages.config b/WaypointCreatorGen2/packages.config new file mode 100644 index 0000000..ca00d0d --- /dev/null +++ b/WaypointCreatorGen2/packages.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 641aeed657e5032c9be1d0f53e1f758e354c0961 Mon Sep 17 00:00:00 2001 From: Daribon Date: Fri, 5 Jul 2024 00:02:53 +0200 Subject: [PATCH 2/4] Switch to MySqlConnector. --- WaypointCreatorGen2/App.config | 2 +- WaypointCreatorGen2/WaypointCreator.cs | 4 +- .../WaypointCreatorGen2.csproj | 38 +++---------------- WaypointCreatorGen2/packages.config | 14 ++----- 4 files changed, 12 insertions(+), 46 deletions(-) diff --git a/WaypointCreatorGen2/App.config b/WaypointCreatorGen2/App.config index 89f90fc..dc561f4 100644 --- a/WaypointCreatorGen2/App.config +++ b/WaypointCreatorGen2/App.config @@ -1,7 +1,7 @@  - +
diff --git a/WaypointCreatorGen2/WaypointCreator.cs b/WaypointCreatorGen2/WaypointCreator.cs index ba5644e..b33878b 100644 --- a/WaypointCreatorGen2/WaypointCreator.cs +++ b/WaypointCreatorGen2/WaypointCreator.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; -using MySql.Data.MySqlClient; +using MySqlConnector; namespace WaypointCreatorGen2 { @@ -26,10 +26,10 @@ public partial class WaypointCreator : Form private string GetConnectionString() { var host = Properties.Settings.Default.host; + var port = Properties.Settings.Default.port; var database = Properties.Settings.Default.database; var username = Properties.Settings.Default.username; var password = Properties.Settings.Default.password; - var port = Properties.Settings.Default.port; return $"server={host};user={username};database={database};port={port};password={password};"; } diff --git a/WaypointCreatorGen2/WaypointCreatorGen2.csproj b/WaypointCreatorGen2/WaypointCreatorGen2.csproj index 6bece20..4703c88 100644 --- a/WaypointCreatorGen2/WaypointCreatorGen2.csproj +++ b/WaypointCreatorGen2/WaypointCreatorGen2.csproj @@ -33,43 +33,20 @@ 4 - - ..\packages\BouncyCastle.Cryptography.2.3.1\lib\net461\BouncyCastle.Cryptography.dll + + ..\packages\Microsoft.Extensions.Logging.Abstractions.7.0.1\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll - - ..\packages\Google.Protobuf.3.26.1\lib\net45\Google.Protobuf.dll - - - ..\packages\K4os.Compression.LZ4.1.3.8\lib\net462\K4os.Compression.LZ4.dll - - - ..\packages\K4os.Compression.LZ4.Streams.1.3.8\lib\net462\K4os.Compression.LZ4.Streams.dll - - - ..\packages\K4os.Hash.xxHash.1.0.8\lib\net462\K4os.Hash.xxHash.dll - - - ..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll - - - ..\packages\MySql.Data.9.0.0\lib\net462\MySql.Data.dll + + ..\packages\MySqlConnector.2.3.7\lib\net471\MySqlConnector.dll ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll - - - ..\packages\System.Configuration.ConfigurationManager.8.0.0\lib\net462\System.Configuration.ConfigurationManager.dll - - - ..\packages\System.Diagnostics.DiagnosticSource.8.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll + + ..\packages\System.Diagnostics.DiagnosticSource.7.0.2\lib\net462\System.Diagnostics.DiagnosticSource.dll - - ..\packages\System.IO.Pipelines.5.0.2\lib\net461\System.IO.Pipelines.dll - - ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll @@ -94,9 +71,6 @@ - - ..\packages\ZstdSharp.Port.0.8.0\lib\net462\ZstdSharp.dll - diff --git a/WaypointCreatorGen2/packages.config b/WaypointCreatorGen2/packages.config index ca00d0d..7766db9 100644 --- a/WaypointCreatorGen2/packages.config +++ b/WaypointCreatorGen2/packages.config @@ -1,19 +1,11 @@  - - - - - - - + + - - - + - \ No newline at end of file From bc1b74e40265ab4beaab76b6c13f2ac1849a237a Mon Sep 17 00:00:00 2001 From: Daribon Date: Fri, 5 Jul 2024 00:17:53 +0200 Subject: [PATCH 3/4] Added horizontal scrollbar for EditorListBox. --- WaypointCreatorGen2/WaypointCreator.Designer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/WaypointCreatorGen2/WaypointCreator.Designer.cs b/WaypointCreatorGen2/WaypointCreator.Designer.cs index 723a636..f57f676 100644 --- a/WaypointCreatorGen2/WaypointCreator.Designer.cs +++ b/WaypointCreatorGen2/WaypointCreator.Designer.cs @@ -363,6 +363,7 @@ private void InitializeComponent() // EditorListBox // this.EditorListBox.FormattingEnabled = true; + this.EditorListBox.HorizontalScrollbar = true; this.EditorListBox.Location = new System.Drawing.Point(7, 14); this.EditorListBox.Name = "EditorListBox"; this.EditorListBox.Size = new System.Drawing.Size(194, 472); From 7900720fc64b566c20a0012205c16ccc505a7ceb Mon Sep 17 00:00:00 2001 From: Daribon Date: Fri, 5 Jul 2024 01:45:41 +0200 Subject: [PATCH 4/4] Fix SQL output. --- WaypointCreatorGen2/WaypointCreator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WaypointCreatorGen2/WaypointCreator.cs b/WaypointCreatorGen2/WaypointCreator.cs index b33878b..4ee2f11 100644 --- a/WaypointCreatorGen2/WaypointCreator.cs +++ b/WaypointCreatorGen2/WaypointCreator.cs @@ -457,7 +457,7 @@ private void GenerateSQLStripMenuItem_Click(object sender, EventArgs e) { // Generates the SQL output. // waypoint_data - CreatureNamesByEntry.TryGetValue(_selectedCreatureId, out string name); + string name = GetCreatureName(_selectedCreatureId); var velocity = "NULL"; SQLOutputTextBox.AppendText("SET @MOVERGUID := @CGUID+xxxxxxxx;\r\n");