]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/map.h
Moved the temporary mapgen test files and added a modified map.cpp too... These are...
[dragonfireclient.git] / src / map.h
index 206dc7d7ba31ee071903b7e1e1df7c711de56236..fa52dc26b33ca1de90ed7e3031e9a60410d9b003 100644 (file)
--- a/src/map.h
+++ b/src/map.h
@@ -1,6 +1,6 @@
 /*
 Minetest-c55
-Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
+Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -287,6 +287,11 @@ class Map : public NodeContainer
        void removeNodeMetadata(v3s16 p);
        void nodeMetadataStep(float dtime,
                        core::map<v3s16, MapBlock*> &changed_blocks);
+       
+       /*
+               Misc.
+       */
+       core::map<v2s16, MapSector*> *getSectorsPtr(){return &m_sectors;}
 
        /*
                Variables
@@ -298,16 +303,13 @@ class Map : public NodeContainer
 
        core::map<MapEventReceiver*, bool> m_event_receivers;
        
-       // Mutex is important because on client map is accessed asynchronously
        core::map<v2s16, MapSector*> m_sectors;
-       JMutex m_sector_mutex;
+       //JMutex m_sector_mutex;
 
        // Be sure to set this to NULL when the cached sector is deleted 
        MapSector *m_sector_cache;
        v2s16 m_sector_cache_p;
 
-       //WrapperHeightmap m_hwrapper;
-       
        // Queued transforming water nodes
        UniqueQueue<v3s16> m_transforming_liquid;
 };
@@ -399,6 +401,35 @@ class ServerMap : public Map
                }
                return true;
        }
+       
+       /*
+               Returns true if any chunk is marked as modified
+       */
+       bool anyChunkModified()
+       {
+               for(core::map<v2s16, MapChunk*>::Iterator
+                               i = m_chunks.getIterator();
+                               i.atEnd()==false; i++)
+               {
+                       v2s16 p = i.getNode()->getKey();
+                       MapChunk *chunk = i.getNode()->getValue();
+                       if(chunk->isModified())
+                               return true;
+               }
+               return false;
+       }
+
+       void setChunksNonModified()
+       {
+               for(core::map<v2s16, MapChunk*>::Iterator
+                               i = m_chunks.getIterator();
+                               i.atEnd()==false; i++)
+               {
+                       v2s16 p = i.getNode()->getKey();
+                       MapChunk *chunk = i.getNode()->getValue();
+                       chunk->setModified(false);
+               }
+       }
 
        /*
                Chunks are generated by using these and makeChunk().
@@ -571,6 +602,12 @@ class ServerMap : public Map
        s16 m_chunksize;
        // Chunks
        core::map<v2s16, MapChunk*> m_chunks;
+
+       /*
+               Metadata is re-written on disk only if this is true.
+               This is reset to false when written on disk.
+       */
+       bool m_map_metadata_changed;
 };
 
 /*