From 3b309103cdeb9b6cd40d20c4f80d627934576f2f Mon Sep 17 00:00:00 2001 From: McMistrzYT <56406996+McMistrzYT@users.noreply.github.com> Date: Sat, 28 Jan 2023 14:34:45 +0100 Subject: [PATCH 1/6] Added support for trailing slashes Trailing slahes (LITTLEBIGPLANETPS3_XML/) now get automatically removed. --- UnionPatcher.Gui/Forms/FilePatchForm.cs | 10 +++++++++- UnionPatcher.Gui/Forms/RemotePatchForm.cs | 10 +++++++++- UnionPatcher/Patcher.cs | 6 ++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/UnionPatcher.Gui/Forms/FilePatchForm.cs b/UnionPatcher.Gui/Forms/FilePatchForm.cs index a52e04d..db1bb4f 100644 --- a/UnionPatcher.Gui/Forms/FilePatchForm.cs +++ b/UnionPatcher.Gui/Forms/FilePatchForm.cs @@ -132,7 +132,15 @@ public class FilePatchForm : Form { Gui.CreateOkDialog("Error occurred while patching", "An error occured while patching:\n" + e); return; } + + // Purely for the dialog box to show the correct URL. Actual patcher has this too. + // If server URL contains a trailing slash, loop until it's gone. + string formattedUrl = this.serverUrl.Text; + while (formattedUrl.EndsWith('/')) + { + formattedUrl = formattedUrl.Remove(formattedUrl.Length - 1); + } - Gui.CreateOkDialog("Success!", "The Server URL has been patched to " + this.serverUrl.Text); + Gui.CreateOkDialog("Success!", "The Server URL has been patched to " + formattedUrl); } } diff --git a/UnionPatcher.Gui/Forms/RemotePatchForm.cs b/UnionPatcher.Gui/Forms/RemotePatchForm.cs index 7354ea9..16301d6 100644 --- a/UnionPatcher.Gui/Forms/RemotePatchForm.cs +++ b/UnionPatcher.Gui/Forms/RemotePatchForm.cs @@ -73,7 +73,15 @@ public class RemotePatchForm : Form return; } - Gui.CreateOkDialog("Success!", $"The Server URL for {this.lbpGameID.Text} on the PS3 at {this.ps3LocalIP.Text} has been patched to {this.serverUrl.Text}"); + // Purely for the dialog box to show the correct URL. Actual patcher has this too. + // If server URL contains a trailing slash, loop until it's gone. + string formattedUrl = this.serverUrl.Text; + while (formattedUrl.EndsWith('/')) + { + formattedUrl = formattedUrl.Remove(formattedUrl.Length - 1); + } + + Gui.CreateOkDialog("Success!", $"The Server URL for {this.lbpGameID.Text} on the PS3 at {this.ps3LocalIP.Text} has been patched to {formattedUrl}"); }; return control; diff --git a/UnionPatcher/Patcher.cs b/UnionPatcher/Patcher.cs index 7593974..662b7ec 100644 --- a/UnionPatcher/Patcher.cs +++ b/UnionPatcher/Patcher.cs @@ -21,8 +21,10 @@ public static class Patcher { public static byte[] PatchData(byte[] data, string serverUrl) { #region Validation - if(serverUrl.EndsWith('/')) { - throw new ArgumentException("URL must not contain a trailing slash!"); + // If server URL contains a trailing slash, loop until it's gone. + while (serverUrl.EndsWith('/')) + { + serverUrl = serverUrl.Remove(serverUrl.Length - 1); } // Attempt to create URI to see if it's valid From 45f556a2fa74d74ccd09ef0cc14a2bacc2334b56 Mon Sep 17 00:00:00 2001 From: McMistrzYT <56406996+McMistrzYT@users.noreply.github.com> Date: Thu, 9 Feb 2023 18:58:37 +0100 Subject: [PATCH 2/6] Update UnionPatcher.Gui/Forms/RemotePatchForm.cs Co-authored-by: Josh --- UnionPatcher.Gui/Forms/RemotePatchForm.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/UnionPatcher.Gui/Forms/RemotePatchForm.cs b/UnionPatcher.Gui/Forms/RemotePatchForm.cs index 16301d6..7354ea9 100644 --- a/UnionPatcher.Gui/Forms/RemotePatchForm.cs +++ b/UnionPatcher.Gui/Forms/RemotePatchForm.cs @@ -73,15 +73,7 @@ public class RemotePatchForm : Form return; } - // Purely for the dialog box to show the correct URL. Actual patcher has this too. - // If server URL contains a trailing slash, loop until it's gone. - string formattedUrl = this.serverUrl.Text; - while (formattedUrl.EndsWith('/')) - { - formattedUrl = formattedUrl.Remove(formattedUrl.Length - 1); - } - - Gui.CreateOkDialog("Success!", $"The Server URL for {this.lbpGameID.Text} on the PS3 at {this.ps3LocalIP.Text} has been patched to {formattedUrl}"); + Gui.CreateOkDialog("Success!", $"The Server URL for {this.lbpGameID.Text} on the PS3 at {this.ps3LocalIP.Text} has been patched to {this.serverUrl.Text}"); }; return control; From 9acde41b820af163ed3044e3d8d191af82ce6d48 Mon Sep 17 00:00:00 2001 From: McMistrzYT <56406996+McMistrzYT@users.noreply.github.com> Date: Thu, 9 Feb 2023 18:58:58 +0100 Subject: [PATCH 3/6] Update UnionPatcher.Gui/Forms/FilePatchForm.cs Co-authored-by: Josh --- UnionPatcher.Gui/Forms/FilePatchForm.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/UnionPatcher.Gui/Forms/FilePatchForm.cs b/UnionPatcher.Gui/Forms/FilePatchForm.cs index db1bb4f..a7499d8 100644 --- a/UnionPatcher.Gui/Forms/FilePatchForm.cs +++ b/UnionPatcher.Gui/Forms/FilePatchForm.cs @@ -132,14 +132,7 @@ public class FilePatchForm : Form { Gui.CreateOkDialog("Error occurred while patching", "An error occured while patching:\n" + e); return; } - - // Purely for the dialog box to show the correct URL. Actual patcher has this too. - // If server URL contains a trailing slash, loop until it's gone. - string formattedUrl = this.serverUrl.Text; - while (formattedUrl.EndsWith('/')) - { - formattedUrl = formattedUrl.Remove(formattedUrl.Length - 1); - } + this.serverUrl.Text = this.serverUrl.Text.TrimEnd('/'); Gui.CreateOkDialog("Success!", "The Server URL has been patched to " + formattedUrl); } From 9a1900576536ca3c255177ca394b4a4cf911621e Mon Sep 17 00:00:00 2001 From: McMistrzYT <56406996+McMistrzYT@users.noreply.github.com> Date: Thu, 9 Feb 2023 18:59:09 +0100 Subject: [PATCH 4/6] Update UnionPatcher.Gui/Forms/FilePatchForm.cs Co-authored-by: Josh --- UnionPatcher.Gui/Forms/FilePatchForm.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnionPatcher.Gui/Forms/FilePatchForm.cs b/UnionPatcher.Gui/Forms/FilePatchForm.cs index a7499d8..74b5382 100644 --- a/UnionPatcher.Gui/Forms/FilePatchForm.cs +++ b/UnionPatcher.Gui/Forms/FilePatchForm.cs @@ -134,6 +134,6 @@ public class FilePatchForm : Form { } this.serverUrl.Text = this.serverUrl.Text.TrimEnd('/'); - Gui.CreateOkDialog("Success!", "The Server URL has been patched to " + formattedUrl); + Gui.CreateOkDialog("Success!", "The Server URL has been patched to " + this.serverUrl.Text); } } From 4db23adae4f3160d8f03932a32f078d8a00e2d1b Mon Sep 17 00:00:00 2001 From: McMistrzYT <56406996+McMistrzYT@users.noreply.github.com> Date: Thu, 9 Feb 2023 18:59:22 +0100 Subject: [PATCH 5/6] Update UnionPatcher/Patcher.cs Co-authored-by: Josh --- UnionPatcher/Patcher.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/UnionPatcher/Patcher.cs b/UnionPatcher/Patcher.cs index 662b7ec..7593974 100644 --- a/UnionPatcher/Patcher.cs +++ b/UnionPatcher/Patcher.cs @@ -21,10 +21,8 @@ public static class Patcher { public static byte[] PatchData(byte[] data, string serverUrl) { #region Validation - // If server URL contains a trailing slash, loop until it's gone. - while (serverUrl.EndsWith('/')) - { - serverUrl = serverUrl.Remove(serverUrl.Length - 1); + if(serverUrl.EndsWith('/')) { + throw new ArgumentException("URL must not contain a trailing slash!"); } // Attempt to create URI to see if it's valid From be1993c866accbecba762ff52f1053b45dadeb41 Mon Sep 17 00:00:00 2001 From: McMistrzYT <56406996+McMistrzYT@users.noreply.github.com> Date: Thu, 9 Feb 2023 19:00:46 +0100 Subject: [PATCH 6/6] Revert "Update UnionPatcher/Patcher.cs" This reverts commit 4db23adae4f3160d8f03932a32f078d8a00e2d1b. --- UnionPatcher/Patcher.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/UnionPatcher/Patcher.cs b/UnionPatcher/Patcher.cs index 7593974..662b7ec 100644 --- a/UnionPatcher/Patcher.cs +++ b/UnionPatcher/Patcher.cs @@ -21,8 +21,10 @@ public static class Patcher { public static byte[] PatchData(byte[] data, string serverUrl) { #region Validation - if(serverUrl.EndsWith('/')) { - throw new ArgumentException("URL must not contain a trailing slash!"); + // If server URL contains a trailing slash, loop until it's gone. + while (serverUrl.EndsWith('/')) + { + serverUrl = serverUrl.Remove(serverUrl.Length - 1); } // Attempt to create URI to see if it's valid