diff options
author | Perttu Ahola <celeron55@gmail.com> | 2010-12-23 10:29:09 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2010-12-23 10:29:09 +0200 |
commit | 03d67af9e85b9641556c8ea2276aa07f6fca175e (patch) | |
tree | fac186b13b62382beac7c91c4ef108badcd0b7e4 /src/mapblock.h | |
parent | 71948dbf963023c773d3e035e79449695ff64442 (diff) | |
download | minetest-03d67af9e85b9641556c8ea2276aa07f6fca175e.tar.gz minetest-03d67af9e85b9641556c8ea2276aa07f6fca175e.tar.bz2 minetest-03d67af9e85b9641556c8ea2276aa07f6fca175e.zip |
a mutex added to TempMods which hopefully fixes rare segfaults on client
Diffstat (limited to 'src/mapblock.h')
-rw-r--r-- | src/mapblock.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mapblock.h b/src/mapblock.h index dc077c23f..586c10228 100644 --- a/src/mapblock.h +++ b/src/mapblock.h @@ -399,15 +399,30 @@ public: <<", mod.type="<<mod.type <<", mod.param="<<mod.param <<std::endl;*/ + JMutexAutoLock lock(m_temp_mods_mutex); m_temp_mods[p] = mod; } + // Returns true if there was one + bool getTempMod(v3s16 p, struct NodeMod *mod) + { + JMutexAutoLock lock(m_temp_mods_mutex); + core::map<v3s16, NodeMod>::Node *n; + n = m_temp_mods.find(p); + if(n == NULL) + return false; + if(mod) + *mod = n->getValue(); + return true; + } void clearTempMod(v3s16 p) { + JMutexAutoLock lock(m_temp_mods_mutex); if(m_temp_mods.find(p)) m_temp_mods.remove(p); } void clearTempMods() { + JMutexAutoLock lock(m_temp_mods_mutex); m_temp_mods.clear(); } #endif @@ -517,6 +532,7 @@ private: // Temporary modifications to nodes // These are only used when drawing core::map<v3s16, NodeMod> m_temp_mods; + JMutex m_temp_mods_mutex; #endif }; |