Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/base/StarAssets.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2025-04-30 12:49:47 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2025-04-30 12:49:47 +1000
commitd3d4345e057d95d784e34be9b23e7fe07fb9a7c1 (patch)
treef59fa890e5be1d590e42a337448cecfc6b61850a /source/base/StarAssets.cpp
parent86e229012f84744a1e878124d9a6e2991c0460bb (diff)
parent885502bf11057e7de961f178bc85ce93a9f40723 (diff)
Merge branch 'main' into pr/218
Diffstat (limited to 'source/base/StarAssets.cpp')
-rw-r--r--source/base/StarAssets.cpp6
1 files changed, 4 insertions, 2 deletions
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<AssetSource*, String> contextKey = make_pair(patchSource.get(), patchPath);
luaLocker.lock();
- LuaContextPtr& context = m_patchContexts[patchPath];
+ LuaContextPtr& context = m_patchContexts[contextKey];
if (!context) {
context = make_shared<LuaContext>(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<AssetSource*, String> 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<LuaContext>(as<LuaEngine>(m_luaEngine.get())->createContext());
context->load(patchStream, patchBasePath);