From 55faf154e61007a0c2db4786e5451c4120d9545c Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sat, 6 Aug 2022 06:38:25 +0200 Subject: [PATCH] Fixed Index Out of Range Exception when retriving available categories --- .../Classes/FileTypes/PCKAudioFile.cs | 2 +- MinecraftUSkinEditor/MainForm.cs | 20 ++++++------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/MinecraftUSkinEditor/Classes/FileTypes/PCKAudioFile.cs b/MinecraftUSkinEditor/Classes/FileTypes/PCKAudioFile.cs index d81db2cf..1fab8740 100644 --- a/MinecraftUSkinEditor/Classes/FileTypes/PCKAudioFile.cs +++ b/MinecraftUSkinEditor/Classes/FileTypes/PCKAudioFile.cs @@ -17,7 +17,7 @@ namespace PckStudio.Classes.FileTypes public readonly int type = 1; public AudioCategory[] Categories => Array.FindAll(_categories, c => c is not null); - private AudioCategory[] _categories { get; } = new AudioCategory[8]; + private AudioCategory[] _categories { get; } = new AudioCategory[9]; public Dictionary Credits { get; } = new Dictionary(); diff --git a/MinecraftUSkinEditor/MainForm.cs b/MinecraftUSkinEditor/MainForm.cs index bce20f95..fb67ed74 100644 --- a/MinecraftUSkinEditor/MainForm.cs +++ b/MinecraftUSkinEditor/MainForm.cs @@ -589,20 +589,12 @@ namespace PckStudio break; case 8 when file.filepath == "audio.pck": - try - { - if (!TryGetLocFile(out LOCFile locFile)) - throw new Exception("No .loc File found."); - AudioEditor audioEditor = new AudioEditor(file, locFile, LittleEndianCheckBox.Checked); - audioEditor.ShowDialog(this); - if (audioEditor.saved) TrySetLocFile(locFile); - audioEditor.Dispose(); - } - catch (Exception ex) - { - MessageBox.Show("Error", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } + if (!TryGetLocFile(out LOCFile locFile)) + throw new Exception("No .loc File found."); + AudioEditor audioEditor = new AudioEditor(file, locFile, LittleEndianCheckBox.Checked); + audioEditor.ShowDialog(this); + if (audioEditor.saved) TrySetLocFile(locFile); + audioEditor.Dispose(); break; case 9 when file.filepath == "colours.col":