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

summaryrefslogtreecommitdiff
path: root/source/base
diff options
context:
space:
mode:
Diffstat (limited to 'source/base')
-rw-r--r--source/base/StarAssets.cpp6
-rw-r--r--source/base/StarAssets.hpp2
2 files changed, 5 insertions, 3 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);
diff --git a/source/base/StarAssets.hpp b/source/base/StarAssets.hpp
index a8e4480..6cc8c16 100644
--- a/source/base/StarAssets.hpp
+++ b/source/base/StarAssets.hpp
@@ -331,7 +331,7 @@ private:
// Lua
RefPtr<RefCounter> m_luaEngine; // dumb but to avoid including Lua.hpp in here...
- mutable StringMap<LuaContextPtr> m_patchContexts;
+ mutable HashMap<pair<AssetSource*, String>, LuaContextPtr> m_patchContexts;
mutable RecursiveMutex m_luaMutex;
// Paths of all used asset sources, in load order.