From acca1e3287d2c50541f93b4153ecc30d8a9d4579 Mon Sep 17 00:00:00 2001 From: MattNL Date: Tue, 10 Jan 2023 10:49:08 -0500 Subject: [PATCH] Fix for AudioEditor allowing empty categories --- PCK-Studio/Forms/Editor/AudioEditor.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/PCK-Studio/Forms/Editor/AudioEditor.cs b/PCK-Studio/Forms/Editor/AudioEditor.cs index 3340a54d..5c5aae08 100644 --- a/PCK-Studio/Forms/Editor/AudioEditor.cs +++ b/PCK-Studio/Forms/Editor/AudioEditor.cs @@ -262,8 +262,15 @@ namespace PckStudio.Forms.Editor } PCKAudioFile.AudioCategory overworldCategory = audioFile.GetCategory(PCKAudioFile.AudioCategory.EAudioType.Overworld); + foreach (var category in audioFile.Categories) { + if (category.SongNames.Count < 1) + { + MessageBox.Show("The game will crash upon loading your pack if any of the categories are empty. Please remove or occupy the category.", "Empty Category"); + return; + } + category.Name = ""; if (playOverworldInCreative.Checked && category.audioType == PCKAudioFile.AudioCategory.EAudioType.Creative) { @@ -279,14 +286,6 @@ namespace PckStudio.Forms.Editor } } - bool emptyCat = false; - - if (emptyCat) - { - MessageBox.Show("The game will crash upon loading your pack if a category is empty", "Empty Category"); - return; - } - using (var stream = new MemoryStream()) { PCKAudioFileWriter.Write(stream, audioFile, _isLittleEndian);