]> git.lizzy.rs Git - minetest.git/blobdiff - src/nodemetadata.cpp
Fix logic of checkbox formspec element validity checking
[minetest.git] / src / nodemetadata.cpp
index 4cdd61767df889cc39b6f82ca7291fb49226285d..b8c7d3d9c11722cefec153c769bc2cb2df32985f 100644 (file)
@@ -83,7 +83,7 @@ void NodeMetadataList::serialize(std::ostream &os) const
                Version 0 is a placeholder for "nothing to see here; go away."
        */
 
-       if(m_data.size() == 0){
+       if(m_data.empty()){
                writeU8(os, 0); // version
                return;
        }
@@ -130,12 +130,12 @@ void NodeMetadataList::deSerialize(std::istream &is, IGameDef *gamedef)
        {
                u16 p16 = readU16(is);
 
-               v3s16 p(0,0,0);
-               p.Z += p16 / MAP_BLOCKSIZE / MAP_BLOCKSIZE;
-               p16 -= p.Z * MAP_BLOCKSIZE * MAP_BLOCKSIZE;
-               p.Y += p16 / MAP_BLOCKSIZE;
-               p16 -= p.Y * MAP_BLOCKSIZE;
-               p.X += p16;
+               v3s16 p;
+               p.Z = p16 / MAP_BLOCKSIZE / MAP_BLOCKSIZE;
+               p16 &= MAP_BLOCKSIZE * MAP_BLOCKSIZE - 1;
+               p.Y = p16 / MAP_BLOCKSIZE;
+               p16 &= MAP_BLOCKSIZE - 1;
+               p.X = p16;
 
                if(m_data.find(p) != m_data.end())
                {