From f1e3f6791d18f82e662a54ea407b5e5495e18a30 Mon Sep 17 00:00:00 2001 From: JamesTheMaker Date: Wed, 6 Mar 2024 12:40:38 -0500 Subject: [PATCH] Multiple patch files --- source/base/StarAssets.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/source/base/StarAssets.cpp b/source/base/StarAssets.cpp index 2c3d04b..422ea22 100644 --- a/source/base/StarAssets.cpp +++ b/source/base/StarAssets.cpp @@ -86,10 +86,21 @@ Assets::Assets(Settings settings, StringList assetSources) { m_assetSourcePaths.add(sourcePath, source); for (auto const& filename : source->assetPaths()) { - if (filename.endsWith(AssetsPatchSuffix, String::CaseInsensitive)) { - auto targetPatchFile = filename.substr(0, filename.size() - strlen(AssetsPatchSuffix)); - if (auto p = m_files.ptr(targetPatchFile)) - p->patchSources.append({filename, source}); + if (filename.contains(AssetsPatchSuffix, String::CaseInsensitive)) { + if (filename.endsWith(AssetsPatchSuffix, String::CaseInsensitive)) { + auto targetPatchFile = filename.substr(0, filename.size() - strlen(AssetsPatchSuffix)); + if (auto p = m_files.ptr(targetPatchFile)) + p->patchSources.append({filename, source}); + } else { + for (int i = 0; i < 10; i++) { + if (filename.endsWith(AssetsPatchSuffix + toString(i), String::CaseInsensitive)) { + auto targetPatchFile = filename.substr(0, filename.size() - strlen(AssetsPatchSuffix) + 1); + if (auto p = m_files.ptr(targetPatchFile)) + p->patchSources.append({filename, source}); + break; + } + } + } } auto& descriptor = m_files[filename]; descriptor.sourceName = filename;