diff --git a/UnionPatcher/Patcher.cs b/UnionPatcher/Patcher.cs index 6de78d9..37bd130 100644 --- a/UnionPatcher/Patcher.cs +++ b/UnionPatcher/Patcher.cs @@ -6,33 +6,6 @@ using System.Text.RegularExpressions; namespace LBPUnion.UnionPatcher; public static class Patcher { - private static readonly string[] toBePatched = { - // Normal LittleBigPlanet gameserver URLs - "https://littlebigplanetps3.online.scee.com:10061/LITTLEBIGPLANETPS3_XML", - "http://littlebigplanetps3.online.scee.com:10060/LITTLEBIGPLANETPS3_XML", - // LittleBigPlanet 3 Presence URLs - "http://live.littlebigplanetps3.online.scee.com:10060/LITTLEBIGPLANETPS3_XML", - "http://presence.littlebigplanetps3.online.scee.com:10060/LITTLEBIGPLANETPS3_XML", - #region Spinoff URLs - // LittleBigPlanet PSP URLs - "http://lbppsp.online.scee.com:10060/LITTLEBIGPLANETPSP_XML", - "https://lbppsp.online.scee.com:10061/LITTLEBIGPLANETPSP_XML", - // LittleBigPlanet Vita URLs - "http://lbpvita.online.scee.com:10060/LITTLEBIGPLANETPS3_XML", - "https://lbpvita.online.scee.com:10061/LITTLEBIGPLANETPS3_XML", - #endregion - #region Beta URLS - // LittleBigPlanet 2 Beta URLs - "http://lbp2ps3-beta.online.scee.com:10060/LITTLEBIGPLANETPS3_XML", - "https://lbp2ps3-beta.online.scee.com:10061/LITTLEBIGPLANETPS3_XML", - // LittleBigPlanet (3?) Beta URLs - "http://littlebigplanetps3-beta.online.scee.com:10060/LITTLEBIGPLANETPS3_XML", - "https://littlebigplanetps3-beta.online.scee.com:10061/LITTLEBIGPLANETPS3_XML", - // LittleBigPlanet Vita Beta URLs - "http://lbpvita-beta.online.scee.com:10060/LITTLEBIGPLANETPS3_XML", - "https://lbpvita-beta.online.scee.com:10061/LITTLEBIGPLANETPS3_XML", - #endregion - }; public static void PatchFile(string fileName, Uri serverUrl, string outputFileName) { PatchFile(fileName, serverUrl.ToString(), outputFileName); @@ -74,14 +47,14 @@ public static class Patcher { bool wroteUrl = false; - // Find a string including http or https and LITTLEBIGPLANETPS3_XML or LITTLEBIGPLANETPSP_XML - MatchCollection urls = Regex.Matches(dataAsString, "https?.*?LITTLEBIGPLANETPS(3|P)_XML"); + // Find a string including http or https and LITTLEBIGPLANETPS3_XML or LITTLEBIGPLANETPSP_XML, + // then match any additional NULL characters to dynamically gague the maximum length on a per-title basis + // without a hardcoded array of known server URLs + MatchCollection urls = Regex.Matches(dataAsString, "(https?.*?LITTLEBIGPLANETPS(3|P)_XML)(\x00*)"); foreach(Match urlMatch in urls) { string url = urlMatch.Value; - // Hard coded 79 max length - // TODO: Get length of index to next data in EBOOT to calcuate true maximum length - if(serverUrl.Length > 79) { + if(serverUrl.Length > url.Length) { throw new ArgumentOutOfRangeException(nameof(serverUrl), $"Server URL ({serverUrl.Length} characters long) is above maximum length {url.Length}"); } int offset = urlMatch.Index;