From 804efe51afdf7ec92f8d3a7aa26b4fd8b139dcaa Mon Sep 17 00:00:00 2001 From: HX3N Date: Sun, 25 May 2025 16:49:31 +0900 Subject: [PATCH] fix: global templates are not loaded (#12787) --- src/MaaCore/Config/TemplResource.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/MaaCore/Config/TemplResource.cpp b/src/MaaCore/Config/TemplResource.cpp index 315f0e8005..494a728e09 100644 --- a/src/MaaCore/Config/TemplResource.cpp +++ b/src/MaaCore/Config/TemplResource.cpp @@ -31,10 +31,6 @@ bool asst::TemplResource::load(const std::filesystem::path& path) bool some_file_not_exists = false; #endif for (const std::string& name : m_load_required) { - if (m_templ_paths.contains(name)) { - continue; - } - bool found = false; for (const auto& dir : search_paths) { @@ -44,14 +40,17 @@ bool asst::TemplResource::load(const std::filesystem::path& path) } if (std::filesystem::exists(filepath)) { - m_templs.erase(name); - m_templ_paths.insert_or_assign(name, filepath); + auto path_iter = m_templ_paths.find(name); + if (path_iter == m_templ_paths.end() || path_iter->second != filepath) { + m_templs.erase(name); + m_templ_paths.insert_or_assign(name, filepath); + } found = true; break; } } - if (!found) { + if (!found && !m_templ_paths.contains(name)) { Log.error("Templ load failed, file not exists in all directories:", name); #ifdef ASST_DEBUG some_file_not_exists = true;