Skip to content

Commit 7f85de8

Browse files
committed
Bugfixes
1 parent e65971b commit 7f85de8

File tree

10 files changed

+103
-57
lines changed

10 files changed

+103
-57
lines changed

LuteBot/Config/ConfigManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ private static string BuildPath(Config config)
169169

170170
public static string GetVersion()
171171
{
172-
return "3.6.0";
172+
return "3.6.1";
173173
}
174174
}
175175
}

LuteBot/Core/UpdateManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static int[] ConvertVersion(string version)
3333
public static async Task<LuteBotVersion> GetLatestVersion()
3434
{
3535
var result = new LuteBotVersion();
36-
var versionPage = await GetVersionPage(10000); // Arbitrary 10s timeout seems fine
36+
var versionPage = await GetVersionPage(10000).ConfigureAwait(false); // Arbitrary 10s timeout seems fine
3737
if (versionPage != null)
3838
{
3939
var versionMatch = versionRegex.Match(versionPage);

LuteBot/LuteBot.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@
310310
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
311311
</None>
312312
<None Include="LuteBot_TemporaryKey.pfx" />
313-
<None Include="LuteMod\FLuteMod_2.6.pak">
313+
<None Include="LuteMod\FLuteMod_2.61.pak">
314314
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
315315
</None>
316316
<None Include="LuteMod\PartitionIndex[0].sav">

LuteBot/PartitionsForm.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,30 @@ public PartitionsForm(TrackSelectionManager tsm, MidiPlayer player)
4949
exportSelectedButton.Enabled = false;
5050
renameSelectedButton.Enabled = false;
5151

52-
if (!LuteBotForm.luteBotForm.IsLuteModInstalled())
52+
try
5353
{
54-
using (var popup = new PopupForm("Install LuteMod", "Would you like to update/install LuteMod?", "You need this to play music.\n\nIf you already have a working LuteMod installed, this means there's an important update\n\nThanks to Monty for LuteMod, and cswic for the autoloader\n\nFor more information, see:",
55-
new Dictionary<string, string>() {
54+
if (!LuteBotForm.luteBotForm.IsLuteModInstalled())
55+
{
56+
using (var popup = new PopupForm("Install LuteMod", "Would you like to update/install LuteMod?", "You need this to play music.\n\nIf you already have a working LuteMod installed, this means there's an important update\n\nThanks to Monty for LuteMod, and cswic for the autoloader\n\nFor more information, see:",
57+
new Dictionary<string, string>() {
5658
{ "What is LuteMod", "https://mordhau-bards-guild.fandom.com/wiki/LuteMod" } ,
5759
{ "LuteMod mod.io page", "https://mordhau.mod.io/lutemod" },
5860
{ "Autoloader mod.io page", "https://mordhau.mod.io/clientside-mod-autoloader" },
5961
{ "Flute and Duets", "https://mordhau-bards-guild.fandom.com/wiki/LuteMod#Flute_and_Duets" },
6062
{ "The Bard's Guild Discord", "https://discord.gg/4xnJVuz" },
61-
}, MessageBoxButtons.YesNo))
62-
{
63-
popup.ShowDialog(this);
64-
if (popup.DialogResult == DialogResult.Yes)
65-
LuteBotForm.luteBotForm.InstallLuteMod();
66-
else
67-
Hide();
63+
}, MessageBoxButtons.YesNo))
64+
{
65+
popup.ShowDialog(this);
66+
if (popup.DialogResult == DialogResult.Yes)
67+
LuteBotForm.luteBotForm.InstallLuteMod();
68+
else
69+
Hide();
70+
}
6871
}
72+
}
73+
catch (Exception ex)
74+
{
75+
6976
}
7077
RefreshPartitionList();
7178
}

LuteBot/Program.cs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,40 @@ static void Main()
1919
{
2020
Application.EnableVisualStyles();
2121
Application.SetCompatibleTextRenderingDefault(false);
22-
//try
23-
//{
24-
Application.Run(new LuteBotForm());
25-
//}
26-
//catch (Exception e)
27-
//{
28-
// var saveFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "LuteBot");
29-
// var savePath = Path.Combine(saveFolder, "CrashDump_" + DateTime.Now.ToString("MM-dd-yyyy_mm-hh") + ".txt");
30-
// try
31-
// {
32-
// var currentException = e;
33-
// string content = $"{DateTime.Now.ToString("G")} - Crash: ";
34-
// do {
35-
// content += $"{currentException.Message}\n{currentException.StackTrace}\nIn method {currentException.TargetSite.Name}\nIn class {currentException.TargetSite.ReflectedType.Name}\n\n";
36-
// currentException = currentException.InnerException;
37-
// } while (currentException != null);
38-
// content += "\n\n";
39-
// Directory.CreateDirectory(saveFolder);
40-
// File.AppendAllText(savePath, content);
41-
// }
42-
// catch (Exception ex)
43-
// {
44-
// MessageBox.Show(null, $"Lutebot has crashed: {e.Message}, and could not write a crash report: {ex.Message}\nYou may need to run Lutebot as administrator", "Lutebot has crashed", MessageBoxButtons.OK);
45-
// }
46-
// var result = MessageBox.Show(null, $"Lutebot has crashed: {e.Message}\n\nThe crash report has been saved to {savePath}\n\nWould you like to open the folder?", "Lutebot has crashed", MessageBoxButtons.YesNo);
47-
//
48-
// if(result == DialogResult.Yes)
49-
// {
50-
// Process.Start(saveFolder);
51-
// }
52-
//
53-
// Environment.Exit(1);
54-
//
55-
//}
22+
try
23+
{
24+
Application.Run(new LuteBotForm());
25+
}
26+
catch (Exception e)
27+
{
28+
var saveFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "LuteBot");
29+
var savePath = Path.Combine(saveFolder, "CrashDump_" + DateTime.Now.ToString("MM-dd-yyyy_mm-hh") + ".txt");
30+
try
31+
{
32+
var currentException = e;
33+
string content = $"{DateTime.Now.ToString("G")} - Crash: ";
34+
do {
35+
content += $"{currentException.Message}\n{currentException.StackTrace}\nIn method {currentException.TargetSite.Name}\nIn class {currentException.TargetSite.ReflectedType.Name}\n\n";
36+
currentException = currentException.InnerException;
37+
} while (currentException != null);
38+
content += "\n\n";
39+
Directory.CreateDirectory(saveFolder);
40+
File.AppendAllText(savePath, content);
41+
}
42+
catch (Exception ex)
43+
{
44+
MessageBox.Show(null, $"Lutebot has crashed: {e.Message}, and could not write a crash report: {ex.Message}\nYou may need to run Lutebot as administrator", "Lutebot has crashed", MessageBoxButtons.OK);
45+
}
46+
var result = MessageBox.Show(null, $"Lutebot has crashed: {e.Message}\n\nThe crash report has been saved to {savePath}\n\nWould you like to open the folder?", "Lutebot has crashed", MessageBoxButtons.YesNo);
47+
48+
if(result == DialogResult.Yes)
49+
{
50+
Process.Start(saveFolder);
51+
}
52+
53+
Environment.Exit(1);
54+
55+
}
5656
}
5757
}
5858
}

LuteBot/UI/LuteBotForm.cs

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using System.Linq;
3030
using System.Reflection;
3131
using System.Runtime.InteropServices;
32+
using System.Runtime.InteropServices.ComTypes;
3233
using System.Text;
3334
using System.Text.RegularExpressions;
3435
using System.Threading.Tasks;
@@ -55,7 +56,7 @@ public partial class LuteBotForm : Form
5556
public static TrackSelectionManager trackSelectionManager;
5657

5758
private const string musicNameLabelHeader = "Loaded: ";
58-
private static string lutemodPakName = "FLuteMod_2.6.pak"; // TODO: Get this dynamically or something. Really, get the file itself from github, but this will do for now
59+
private static string lutemodPakName = "FLuteMod_2.61.pak"; // TODO: Get this dynamically or something. Really, get the file itself from github, but this will do for now
5960
private static int lutemodVersion1 = 2;
6061
private static int lutemodVersion2 = 6;
6162
private static string loaderPakName = "AutoLoaderWindowsClient.pak";
@@ -205,15 +206,15 @@ public LuteBotForm()
205206

206207
private async void LuteBotForm_Shown(object sender, EventArgs e)
207208
{
208-
await CheckUpdates(false);
209+
await CheckUpdates(false).ConfigureAwait(false);
209210
}
210211

211212
public async Task CheckUpdates(bool ignoreSettings = false)
212213
{
213214
if (ConfigManager.GetBooleanProperty(PropertyItem.CheckForUpdates))
214215
{
215216
// Try to update the version. This is an async void by necessity, so errors will be dropped if we don't log them - but they get logged in there
216-
LatestVersion = await UpdateManager.GetLatestVersion();
217+
LatestVersion = await UpdateManager.GetLatestVersion().ConfigureAwait(false);
217218
try
218219
{
219220
if (LatestVersion != null && LatestVersion.VersionArray != null)
@@ -337,6 +338,7 @@ public bool IsLuteModInstalled()
337338
{
338339
return true; // They have disabled installs or otherwise didn't input the path correctly, so don't check
339340
}
341+
340342
if (!IsMordhauPakPathValid())
341343
{
342344
MordhauPakPath = GetMordhauPathFromPrompt();
@@ -370,12 +372,26 @@ public bool IsLuteModInstalled()
370372
{
371373
// Check if they have a similar version instead
372374
Directory.CreateDirectory(MordhauPakPath); // Prevent crash if it doesn't exist
375+
var curVers = Regex.Replace(lutemodPakName, "[^0-9]", "").Select(c => int.Parse(c.ToString())).ToArray();
373376
foreach (var f in Directory.GetFiles(MordhauPakPath))
374377
{
375-
Match m = Regex.Match(Path.GetFileName(f), @"LuteMod_([0-9])\.([0-9]*)");
378+
Match m = Regex.Match(Path.GetFileName(f), @"LuteMod_([0-9])\.([0-9])([0-9]*)");
376379
if (m.Success)
377380
{
381+
var existingVers = Regex.Replace(Path.GetFileName(f), "[^0-9]", "").Select(c => int.Parse(c.ToString())).ToArray();
382+
for(int i = 0; i < curVers.Length; i++)
383+
{
384+
if (existingVers.Length > i && existingVers[i] > curVers[i])
385+
return true;
386+
if (existingVers.Length <= i || existingVers[i] < curVers[i])
387+
{
388+
// This doesn't really go here but oh well; if they have an existing old version, force an update then return true
389+
InstallLuteMod();
390+
return true;
391+
}
392+
}
378393
return true;
394+
379395
}
380396
}
381397
}
@@ -675,7 +691,7 @@ private string GetPakPath()
675691
{
676692
MessageBox.Show($"General failure... \n{e.Message}\n{e.StackTrace}");
677693
}
678-
var epicDefaultPath = "C:\\Program Files\\Epic Games\\Mordhau\\Mordhau\\Content\\CustomPaks";
694+
var epicDefaultPath = @"C:\Program Files\Epic Games\Mordhau\Mordhau\Content\CustomPaks";
679695
if (IsMordhauPakPathValid(epicDefaultPath))
680696
return epicDefaultPath;
681697

@@ -687,7 +703,7 @@ private string GetMordhauPathFromPrompt()
687703
var inputForm = new MordhauPathInputForm(MordhauPakPath);
688704
inputForm.ShowDialog(this);
689705

690-
if (inputForm.result == DialogResult.OK && inputForm.path != string.Empty && File.Exists(inputForm.path))
706+
if (inputForm.result == DialogResult.OK && inputForm.path != string.Empty && IsMordhauPakPathValid(inputForm.path))
691707
{
692708
installLuteModToolStripMenuItem.Enabled = true;
693709
var result = Path.Combine(Path.GetDirectoryName(inputForm.path), "Mordhau", "Content", "CustomPaks");
@@ -710,8 +726,24 @@ public static bool IsMordhauPakPathValid(string path = null)
710726
// See if the mordhau exe is where it should be
711727
if (string.IsNullOrWhiteSpace(path))
712728
return false;
713-
var exePath = Path.Combine(path, ".." + Path.DirectorySeparatorChar, ".." + Path.DirectorySeparatorChar, ".." + Path.DirectorySeparatorChar, "Mordhau.exe");
714-
return File.Exists(exePath);
729+
var exePath = Path.Combine(path, "..", "..", "..", "Mordhau.exe");
730+
731+
System.IO.FileInfo fi = null;
732+
try
733+
{
734+
fi = new System.IO.FileInfo(exePath);
735+
}
736+
catch (ArgumentException) { }
737+
catch (System.IO.PathTooLongException) { }
738+
catch (NotSupportedException) { }
739+
if (ReferenceEquals(fi, null))
740+
{
741+
return false;
742+
}
743+
else
744+
{
745+
return fi.Exists;
746+
}
715747
}
716748

717749
private async Task PlayerLoadCompleted(bool skipUI)

LuteBot/UI/NeuralNetworkForm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ private async Task TrainNetwork(int numPerfect, float percentForSuccess, int par
533533

534534
//await Task.Delay(0); // Let the form live between iterations
535535
});
536-
Parallel.ForEach(neuralTrainingCandidates.OrderBy(n => random.NextDouble()), new ParallelOptions() { MaxDegreeOfParallelism = parallelism }, song =>
536+
Parallel.ForEach(neuralTestCandidates.OrderBy(n => random.NextDouble()), new ParallelOptions() { MaxDegreeOfParallelism = parallelism }, song =>
537537
{
538538
float maxAvgNoteLength = song.Max(c => c.Id == 9 ? 0 : c.avgNoteLength);
539539
float maxNoteLength = song.Max(c => c.Id == 9 ? 0 : c.totalNoteLength);

ReleaseNotes.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Version 3.6.1
2+
3+
- Maybe fix startup crashes for Epic users
4+
- LuteMod 2.61
5+
- Re-enabled loading of voice config settings
6+
- Fixed issue where playing sometimes pauses itself immediately
7+
18
Version 3.6.0
29

310
- Major rework of LuteBot and LuteMod note handling and configuration

Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.6.0
1+
3.6.1

0 commit comments

Comments
 (0)