Skip to content

Commit

Permalink
Fix bug with mod preset checking... again
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaboxer committed Jul 15, 2023
1 parent 78869e5 commit 232cd4f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Bloxstrap/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,9 +1000,11 @@ private async Task ApplyModifications()
Directory.CreateDirectory(modFolder);

// cursors
await CheckModPreset(App.Settings.Prop.CursorType != CursorType.Default, @"content\textures\Cursors\KeyboardMouse\ArrowCursor.png", $"Cursor.{App.Settings.Prop.CursorType}.ArrowCursor.png");
await CheckModPreset(App.Settings.Prop.CursorType != CursorType.Default, @"content\textures\Cursors\KeyboardMouse\ArrowFarCursor.png", $"Cursor.{App.Settings.Prop.CursorType}.ArrowFarCursor.png");

await CheckModPreset(App.Settings.Prop.CursorType == CursorType.From2006, @"content\textures\Cursors\KeyboardMouse\ArrowCursor.png", "Cursor.From2006.ArrowCursor.png");
await CheckModPreset(App.Settings.Prop.CursorType == CursorType.From2006, @"content\textures\Cursors\KeyboardMouse\ArrowFarCursor.png", "Cursor.From2006.ArrowFarCursor.png");
await CheckModPreset(App.Settings.Prop.CursorType == CursorType.From2013, @"content\textures\Cursors\KeyboardMouse\ArrowCursor.png", "Cursor.From2013.ArrowCursor.png");
await CheckModPreset(App.Settings.Prop.CursorType == CursorType.From2013, @"content\textures\Cursors\KeyboardMouse\ArrowFarCursor.png", "Cursor.From2013.ArrowFarCursor.png");

// character sounds
await CheckModPreset(App.Settings.Prop.UseOldCharacterSounds, @"content\sounds\action_footsteps_plastic.mp3", "OldWalk.mp3");
await CheckModPreset(App.Settings.Prop.UseOldCharacterSounds, @"content\sounds\action_jump.mp3", "OldJump.mp3");
Expand Down Expand Up @@ -1151,17 +1153,17 @@ private static async Task CheckModPreset(bool condition, string location, string
string fullLocation = Path.Combine(Directories.Modifications, location);
string fileHash = File.Exists(fullLocation) ? Utility.MD5Hash.FromFile(fullLocation) : "";

byte[] embeddedData = string.IsNullOrEmpty(name) ? Array.Empty<byte>() : await Resource.Get(name);
string embeddedHash = Utility.MD5Hash.FromBytes(embeddedData);

if (!condition)
{
if (fileHash != "")
if (fileHash != "" && fileHash == embeddedHash)
File.Delete(fullLocation);

return;
}

byte[] embeddedData = string.IsNullOrEmpty(name) ? Array.Empty<byte>() : await Resource.Get(name);
string embeddedHash = Utility.MD5Hash.FromBytes(embeddedData);

if (fileHash != embeddedHash)
{
Directory.CreateDirectory(Path.GetDirectoryName(fullLocation)!);
Expand Down

0 comments on commit 232cd4f

Please sign in to comment.