mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:23:53 +00:00
Make getLayerInfo thread safe
This commit is contained in:
parent
8aba74e6ee
commit
98848c752a
2 changed files with 7 additions and 0 deletions
|
@ -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())
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue