From 05939279dc3be7aa8ed8e41ad008043487de95fb Mon Sep 17 00:00:00 2001
From: biwa <6475593+biwa@users.noreply.github.com>
Date: Sat, 11 Sep 2021 22:47:52 +0200
Subject: [PATCH] Dehacked: fixed a crash when loading data from a directory
 that didn't contain a Dehacked patch

---
 Source/Core/Data/PK3StructuredReader.cs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Source/Core/Data/PK3StructuredReader.cs b/Source/Core/Data/PK3StructuredReader.cs
index 3d86e0d1e..aed189365 100755
--- a/Source/Core/Data/PK3StructuredReader.cs
+++ b/Source/Core/Data/PK3StructuredReader.cs
@@ -504,7 +504,8 @@ namespace CodeImp.DoomBuilder.Data
 			else
 				allfilenames = GetAllFilesWithTitle(pathname, filename, false);
 
-			result.Add(new TextResourceData(this, LoadFile(allfilenames[allfilenames.Length - 1]), allfilenames[allfilenames.Length - 1], true));
+			if(allfilenames.Length > 0)
+				result.Add(new TextResourceData(this, LoadFile(allfilenames[allfilenames.Length - 1]), allfilenames[allfilenames.Length - 1], true));
 
 			return result;
 		}
-- 
GitLab