1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 10:53:53 +00:00

Make getLayerInfo thread safe

This commit is contained in:
scrawl 2016-02-09 20:26:58 +01:00
parent 8aba74e6ee
commit 98848c752a
2 changed files with 7 additions and 0 deletions

View file

@ -3,6 +3,8 @@
#include <set>
#include <iostream>
#include <OpenThreads/ScopedLock>
#include <osg/Image>
#include <osg/Plane>
@ -498,6 +500,8 @@ namespace ESMTerrain
Terrain::LayerInfo Storage::getLayerInfo(const std::string& texture)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mLayerInfoMutex);
// Already have this cached?
std::map<std::string, Terrain::LayerInfo>::iterator found = mLayerInfoMap.find(texture);
if (found != mLayerInfoMap.end())

View file

@ -1,6 +1,8 @@
#ifndef COMPONENTS_ESM_TERRAIN_STORAGE_H
#define COMPONENTS_ESM_TERRAIN_STORAGE_H
#include <OpenThreads/Mutex>
#include <components/terrain/storage.hpp>
#include <components/esm/loadland.hpp>
@ -105,6 +107,7 @@ namespace ESMTerrain
std::string getTextureName (UniqueTextureId id);
std::map<std::string, Terrain::LayerInfo> mLayerInfoMap;
OpenThreads::Mutex mLayerInfoMutex;
Terrain::LayerInfo getLayerInfo(const std::string& texture);
};