Saner block modification flag operation for not saving everything always
authorPerttu Ahola <celeron55@gmail.com>
Wed, 12 Oct 2011 07:53:37 +0000 (10:53 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Wed, 12 Oct 2011 07:53:37 +0000 (10:53 +0300)
src/mapblock.cpp
src/mapblock.h
src/server.cpp

index 44ca75ff0b794ab66393c8329ab70ffd9b153de3..6613f388a2ecbfd0d7b4b549700af39813470fa2 100644 (file)
@@ -441,7 +441,8 @@ void MapBlock::stepObjects(float dtime, bool server, u32 daynight_ratio)
        */
        m_objects.step(dtime, server, daynight_ratio);
 
-       setChangedFlag();
+       //setChangedFlag();
+       raiseModified(MOD_STATE_WRITE_AT_UNLOAD);
 }
 
 
index 741c306eb9968c58c0a3052ce9b0e3a8122f8774..368290065458be02fa6b3602e01a5588dc2c80a8 100644 (file)
@@ -225,8 +225,10 @@ public:
 
        void setLightingExpired(bool expired)
        {
-               m_lighting_expired = expired;
-               raiseModified(MOD_STATE_WRITE_NEEDED);
+               if(expired != m_lighting_expired){
+                       m_lighting_expired = expired;
+                       raiseModified(MOD_STATE_WRITE_NEEDED);
+               }
        }
        bool getLightingExpired()
        {
@@ -239,8 +241,10 @@ public:
        }
        void setGenerated(bool b)
        {
-               raiseModified(MOD_STATE_WRITE_NEEDED);
-               m_generated = b;
+               if(b != m_generated){
+                       raiseModified(MOD_STATE_WRITE_NEEDED);
+                       m_generated = b;
+               }
        }
 
        bool isValid()
index 44889d67ef18360a98d28c5606ceb17916d2d39a..c95c724cb3545ebe9fa6980c9f7abffc24622b9c 100644 (file)
@@ -897,7 +897,7 @@ void RemoteClient::SendObjectData(
                        {
                                block->stepObjects(dtime, true, server->m_env.getDayNightRatio());
                                stepped_blocks.insert(p, true);
-                               block->setChangedFlag();
+                               //block->setChangedFlag();
                        }
 
                        // Skip block if there are no objects