From 23b8707fc25d0da3030f0565ec08c73b0391eb7a Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Wed, 11 Aug 2021 12:04:53 +0200
Subject: [PATCH] - added means to define resource IDs in all container formats
 allowing long file names.

To define these, construct a file name like "basename.{resourceid}.extension", e.g. blaster.{65}.qav will define 'blaster.qav' with a resource ID of 65.
---
 source/common/filesystem/filesystem.cpp | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/source/common/filesystem/filesystem.cpp b/source/common/filesystem/filesystem.cpp
index 4c5a5b910..8b14b1312 100644
--- a/source/common/filesystem/filesystem.cpp
+++ b/source/common/filesystem/filesystem.cpp
@@ -113,7 +113,20 @@ struct FileSystem::LumpRecord
 			if (Namespace == ns_hidden) shortName.qword = 0;
 			else
 			{
-				long slash = longName.LastIndexOf('/');
+				ptrdiff_t encodedResID = longName.LastIndexOf(".{");
+				if (resourceId == -1 && encodedResID >= 0)
+				{
+					const char* p = longName.GetChars() + encodedResID;
+					char* q;
+					int id = (int)strtoull(p+2, &q, 10);	// only decimal numbers allowed here.
+					if (q[0] == '}' && (q[1] == '.' || q[1] == 0))
+					{
+						FString toDelete(p, q - p + 1);
+						longName.Substitute(toDelete, "");
+						resourceId = id;
+					}
+				}
+				ptrdiff_t slash = longName.LastIndexOf('/');
 				FString base = (slash >= 0) ? longName.Mid(slash + 1) : longName;
 				auto dot = base.LastIndexOf('.');
 				if (dot >= 0) base.Truncate(dot);