]> git.lizzy.rs Git - minetest.git/blobdiff - src/mapblock.cpp
Create PacketError exception and use it with ACTIVEOBJECT_REMOVE_ADD handler which...
[minetest.git] / src / mapblock.cpp
index c22096562e81681ff4928069c53b20390c1bd2d7..ca80c39d71cae6d55d9f2a49cccbdccdc2ebeb18 100644 (file)
@@ -330,47 +330,42 @@ void MapBlock::copyFrom(VoxelManipulator &dst)
 void MapBlock::actuallyUpdateDayNightDiff()
 {
        INodeDefManager *nodemgr = m_gamedef->ndef();
+
        // Running this function un-expires m_day_night_differs
        m_day_night_differs_expired = false;
 
-       if(data == NULL)
-       {
+       if (data == NULL) {
                m_day_night_differs = false;
                return;
        }
 
-       bool differs = false;
+       bool differs;
 
        /*
                Check if any lighting value differs
        */
-       for(u32 i=0; i<MAP_BLOCKSIZE*MAP_BLOCKSIZE*MAP_BLOCKSIZE; i++)
-       {
+       for (u32 i = 0; i < MAP_BLOCKSIZE*MAP_BLOCKSIZE*MAP_BLOCKSIZE; i++) {
                MapNode &n = data[i];
-               if(n.getLight(LIGHTBANK_DAY, nodemgr) != n.getLight(LIGHTBANK_NIGHT, nodemgr))
-               {
-                       differs = true;
+
+               differs = !n.isLightDayNightEq(nodemgr);
+               if (differs)
                        break;
-               }
        }
 
        /*
                If some lighting values differ, check if the whole thing is
-               just air. If it is, differ = false
+               just air. If it is just air, differs = false
        */
-       if(differs)
-       {
+       if (differs) {
                bool only_air = true;
-               for(u32 i=0; i<MAP_BLOCKSIZE*MAP_BLOCKSIZE*MAP_BLOCKSIZE; i++)
-               {
+               for (u32 i = 0; i < MAP_BLOCKSIZE*MAP_BLOCKSIZE*MAP_BLOCKSIZE; i++) {
                        MapNode &n = data[i];
-                       if(n.getContent() != CONTENT_AIR)
-                       {
+                       if (n.getContent() != CONTENT_AIR) {
                                only_air = false;
                                break;
                        }
                }
-               if(only_air)
+               if (only_air)
                        differs = false;
        }
 
@@ -526,6 +521,8 @@ void MapBlock::serialize(std::ostream &os, u8 version, bool disk)
                throw SerializationError("ERROR: Not writing dummy block.");
        }
 
+       FATAL_ERROR_IF(version < SER_FMT_CLIENT_VER_LOWEST, "Serialize version error");
+
        // First byte
        u8 flags = 0;
        if(is_underground)