mirror of
https://github.com/LBPUnion/UnionPatcher.git
synced 2025-07-29 12:18:46 +00:00
Use regex to discover existing server urls
- Supports LBP PSP and PS3 - Hardcoded length limit, will fix soonTM
This commit is contained in:
parent
8f6ba8b535
commit
704ce90b21
1 changed files with 11 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace LBPUnion.UnionPatcher;
|
||||
|
||||
|
@ -72,13 +73,18 @@ public static class Patcher {
|
|||
byte[] serverUrlAsBytes = Encoding.ASCII.GetBytes(serverUrl);
|
||||
|
||||
bool wroteUrl = false;
|
||||
foreach(string url in toBePatched) {
|
||||
if(serverUrl.Length > url.Length) {
|
||||
|
||||
// Find a string including http or https and LITTLEBIGPLANETPS3_XML or LITTLEBIGPLANETPSP_XML
|
||||
MatchCollection urls = Regex.Matches(dataAsString, "https?.*?LITTLEBIGPLANETPS(3|P)_XML");
|
||||
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) {
|
||||
throw new ArgumentOutOfRangeException(nameof(serverUrl), $"Server URL ({serverUrl.Length} characters long) is above maximum length {url.Length}");
|
||||
}
|
||||
|
||||
int offset = dataAsString.IndexOf(url, StringComparison.Ordinal);
|
||||
if(offset < 1) continue;
|
||||
int offset = urlMatch.Index;
|
||||
|
||||
writer.BaseStream.Position = offset;
|
||||
for(int i = 0; i < url.Length; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue