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.cpp | |
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.cpp')
-rw-r--r-- | src/mapblock.cpp | 82 |
1 files changed, 44 insertions, 38 deletions
diff --git a/src/mapblock.cpp b/src/mapblock.cpp index b2b5bc4f4..186256589 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -47,6 +47,7 @@ MapBlock::MapBlock(NodeContainer *parent, v3s16 pos, bool dummy): m_mesh_expired = false; mesh_mutex.Init(); mesh = NULL; + m_temp_mods_mutex.Init(); #endif } @@ -584,47 +585,52 @@ void MapBlock::updateMesh(u32 daynight_ratio) NOTE: This is the slowest part of this method. */ + + { + // Lock this, as m_temp_mods will be used directly + JMutexAutoLock lock(m_temp_mods_mutex); - /* - Go through every y,z and get top faces in rows of x+ - */ - for(s16 y=0; y<MAP_BLOCKSIZE; y++){ - for(s16 z=0; z<MAP_BLOCKSIZE; z++){ - updateFastFaceRow(daynight_ratio, posRelative_f, - v3s16(0,y,z), MAP_BLOCKSIZE, - v3s16(1,0,0), //dir - v3f (1,0,0), - v3s16(0,1,0), //face dir - v3f (0,1,0), - fastfaces_new); - } - } - /* - Go through every x,y and get right faces in rows of z+ - */ - for(s16 x=0; x<MAP_BLOCKSIZE; x++){ + /* + Go through every y,z and get top faces in rows of x+ + */ for(s16 y=0; y<MAP_BLOCKSIZE; y++){ - updateFastFaceRow(daynight_ratio, posRelative_f, - v3s16(x,y,0), MAP_BLOCKSIZE, - v3s16(0,0,1), - v3f (0,0,1), - v3s16(1,0,0), - v3f (1,0,0), - fastfaces_new); + for(s16 z=0; z<MAP_BLOCKSIZE; z++){ + updateFastFaceRow(daynight_ratio, posRelative_f, + v3s16(0,y,z), MAP_BLOCKSIZE, + v3s16(1,0,0), //dir + v3f (1,0,0), + v3s16(0,1,0), //face dir + v3f (0,1,0), + fastfaces_new); + } } - } - /* - Go through every y,z and get back faces in rows of x+ - */ - for(s16 z=0; z<MAP_BLOCKSIZE; z++){ - for(s16 y=0; y<MAP_BLOCKSIZE; y++){ - updateFastFaceRow(daynight_ratio, posRelative_f, - v3s16(0,y,z), MAP_BLOCKSIZE, - v3s16(1,0,0), - v3f (1,0,0), - v3s16(0,0,1), - v3f (0,0,1), - fastfaces_new); + /* + Go through every x,y and get right faces in rows of z+ + */ + for(s16 x=0; x<MAP_BLOCKSIZE; x++){ + for(s16 y=0; y<MAP_BLOCKSIZE; y++){ + updateFastFaceRow(daynight_ratio, posRelative_f, + v3s16(x,y,0), MAP_BLOCKSIZE, + v3s16(0,0,1), + v3f (0,0,1), + v3s16(1,0,0), + v3f (1,0,0), + fastfaces_new); + } + } + /* + Go through every y,z and get back faces in rows of x+ + */ + for(s16 z=0; z<MAP_BLOCKSIZE; z++){ + for(s16 y=0; y<MAP_BLOCKSIZE; y++){ + updateFastFaceRow(daynight_ratio, posRelative_f, + v3s16(0,y,z), MAP_BLOCKSIZE, + v3s16(1,0,0), + v3f (1,0,0), + v3s16(0,0,1), + v3f (0,0,1), + fastfaces_new); + } } } |