Skip to content

Commit

Permalink
Fix path checking on eqemupatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
xackery committed Feb 29, 2024
1 parent 3e65a59 commit b8049c6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
11 changes: 6 additions & 5 deletions EQEmu Patcher/EQEmu Patcher/IniLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
using System.Windows.Forms;

namespace EQEmu_Patcher
{
Expand All @@ -17,29 +18,29 @@ class IniLibrary
public VersionTypes ClientVersion { get; set; }
public string LastPatchedVersion { get; set; }


public static void Save()
{
var serializerBuilder = new SerializerBuilder().WithNamingConvention(new CamelCaseNamingConvention());
var serializer = serializerBuilder.Build();
string body = serializer.Serialize(instance);

Console.WriteLine(body);
File.WriteAllText(@"eqemupatcher.yml", body);
File.WriteAllText($"{System.IO.Path.GetDirectoryName(Application.ExecutablePath)}\\eqemupatcher.yml", body);
}

public static void Load()
{
try {
using (var input = File.OpenText("eqemupatcher.yml"))
using (var input = File.OpenText($"{System.IO.Path.GetDirectoryName(Application.ExecutablePath)}\\eqemupatcher.yml"))
{
var deserializerBuilder = new DeserializerBuilder().WithNamingConvention(new CamelCaseNamingConvention());

var deserializer = deserializerBuilder.Build();

instance = deserializer.Deserialize<IniLibrary>(input);
}

if (instance == null) {
ResetDefaults();
Save();
Expand Down
35 changes: 17 additions & 18 deletions EQEmu Patcher/EQEmu Patcher/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace EQEmu_Patcher
{

public partial class MainForm : Form
{

Expand Down Expand Up @@ -43,7 +43,7 @@ public partial class MainForm : Form
VersionTypes.Rain_Of_Fear, //rof
VersionTypes.Rain_Of_Fear_2 //rof
//VersionTypes.Broken_Mirror, //bro
};
};

private Dictionary<VersionTypes, ClientVersion> clientVersions = new Dictionary<VersionTypes, ClientVersion>();

Expand All @@ -57,7 +57,6 @@ public MainForm()

private async void MainForm_Load(object sender, EventArgs e)
{

isLoading = true;
version = Assembly.GetEntryAssembly().GetName().Version.ToString();
Console.WriteLine($"Initializing {version}");
Expand Down Expand Up @@ -157,7 +156,7 @@ private async void MainForm_Load(object sender, EventArgs e)
bool isSupported = false;
foreach (var ver in supportedClients)
{
if (ver != currentVersion) continue;
if (ver != currentVersion) continue;
isSupported = true;
break;
}
Expand All @@ -177,7 +176,7 @@ private async void MainForm_Load(object sender, EventArgs e)
if (Environment.OSVersion.Version.Major < 6) {
return;
}
var taskbar = TaskbarManager.Instance;
var taskbar = TaskbarManager.Instance;
taskbar.SetProgressValue(value, 10000);
taskbar.SetProgressState((value == 10000) ? TaskbarProgressBarState.NoProgress : TaskbarProgressBarState.Normal);
});
Expand Down Expand Up @@ -209,7 +208,7 @@ private async void MainForm_Load(object sender, EventArgs e)
}));

string webUrl = $"{filelistUrl}{suffix}/filelist_{suffix}.yml";

string response = await DownloadFile(cts, webUrl, "filelist.yml");
if (response != "")
{
Expand Down Expand Up @@ -249,15 +248,15 @@ private async void MainForm_Load(object sender, EventArgs e)

FileList filelist;

using (var input = File.OpenText("filelist.yml"))
using (var input = File.OpenText($"{System.IO.Path.GetDirectoryName(Application.ExecutablePath)}\\filelist.yml"))
{
var deserializerBuilder = new DeserializerBuilder().WithNamingConvention(new CamelCaseNamingConvention());

var deserializer = deserializerBuilder.Build();

filelist = deserializer.Deserialize<FileList>(input);
}

if (filelist.version != IniLibrary.instance.LastPatchedVersion)
{
if (!isPendingPatch)
Expand Down Expand Up @@ -338,9 +337,9 @@ private void detectClientVersion()
{
//StatusLibrary.Log($"You seem to have put me in a {clientVersions[currentVersion].FullName} client directory");
}

//MessageBox.Show(""+currentVersion);
//StatusLibrary.Log($"If you wish to help out, press the scan button on the bottom left and wait for it to complete, then copy paste this data as an Issue on github!");
//StatusLibrary.Log($"If you wish to help out, press the scan button on the bottom left and wait for it to complete, then copy paste this data as an Issue on github!");
}
catch (UnauthorizedAccessException err)
{
Expand Down Expand Up @@ -407,7 +406,7 @@ public static async Task<string> DownloadFile(CancellationTokenSource cts, strin
{
path = path.Replace("/", "\\");
if (path.Contains("\\")) { //Make directory if needed.
string dir = Application.ExecutablePath + "\\" + path.Substring(0, path.LastIndexOf("\\"));
string dir = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\" + path.Substring(0, path.LastIndexOf("\\"));
Directory.CreateDirectory(dir);
}
return await UtilityLibrary.DownloadFile(cts, url, path);
Expand Down Expand Up @@ -453,8 +452,8 @@ private async Task AsyncPatch()
StatusLibrary.Log($"Patching with patcher version {version}...");
StatusLibrary.SetProgress(0);
FileList filelist;
using (var input = File.OpenText("filelist.yml"))

using (var input = File.OpenText($"{System.IO.Path.GetDirectoryName(Application.ExecutablePath)}\\filelist.yml"))
{
var deserializerBuilder = new DeserializerBuilder().WithNamingConvention(new CamelCaseNamingConvention());

Expand Down Expand Up @@ -489,7 +488,7 @@ private async Task AsyncPatch()
await w.WriteAsync(data, 0, data.Length, cts.Token);
}
StatusLibrary.Log($"Self update of {generateSize(data.Length)} will be used next run");

} catch (Exception e)
{
StatusLibrary.Log($"Self update failed {url}: {e.Message}");
Expand Down Expand Up @@ -530,7 +529,7 @@ private async Task AsyncPatch()


string url = filelist.downloadprefix + entry.name.Replace("\\", "/");

string resp = await DownloadFile(cts, url, entry.name);
if (resp != "")
{
Expand Down Expand Up @@ -579,11 +578,11 @@ private async Task AsyncPatch()
{
version = version.Substring(0, 8);
}

StatusLibrary.Log($"Up to date with patch {version}.");
return;
}

string elapsed = start.Elapsed.ToString("ss\\.ff");
StatusLibrary.Log($"Complete! Patched {generateSize(patchedBytes)} in {elapsed} seconds. Press Play to begin.");
IniLibrary.instance.LastPatchedVersion = filelist.version;
Expand Down Expand Up @@ -663,7 +662,7 @@ private void pendingPatchTimer_Tick(object sender, EventArgs e)
public class FileList
{
public string version { get; set; }

public List<FileEntry> deletes { get; set; }
public string downloadprefix { get; set; }
public List<FileEntry> downloads { get; set; }
Expand Down

0 comments on commit b8049c6

Please sign in to comment.