From 97ba073681b75af10cd0eab827a6aa98b77ea627 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Sat, 12 Apr 2025 16:53:22 +1000 Subject: Fix multiple Lua patches of the same path not working correctly --- source/base/StarAssets.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/base/StarAssets.cpp') diff --git a/source/base/StarAssets.cpp b/source/base/StarAssets.cpp index 9742f9e..b6aeab9 100644 --- a/source/base/StarAssets.cpp +++ b/source/base/StarAssets.cpp @@ -969,8 +969,9 @@ ImageConstPtr Assets::readImage(String const& path) const { auto& patchSource = pair.second; auto patchStream = patchSource->read(patchPath); if (patchPath.endsWith(".lua")) { + std::pair contextKey = make_pair(patchSource.get(), patchPath); luaLocker.lock(); - LuaContextPtr& context = m_patchContexts[patchPath]; + LuaContextPtr& context = m_patchContexts[contextKey]; if (!context) { context = make_shared(luaEngine->createContext()); context->load(patchStream, patchPath); @@ -1042,9 +1043,10 @@ Json Assets::readJson(String const& path) const { auto& patchSource = pair.second; auto patchStream = patchSource->read(patchBasePath); if (patchBasePath.endsWith(".lua")) { + std::pair contextKey = make_pair(patchSource.get(), patchBasePath); RecursiveMutexLocker luaLocker(m_luaMutex); // Kae: i don't like that lock. perhaps have a LuaEngine and patch context cache per worker thread later on? - LuaContextPtr& context = m_patchContexts[patchBasePath]; + LuaContextPtr& context = m_patchContexts[contextKey]; if (!context) { context = make_shared(as(m_luaEngine.get())->createContext()); context->load(patchStream, patchBasePath); -- cgit v1.2.3