]> git.lizzy.rs Git - minetest.git/blobdiff - src/map.h
* better glass graphics
[minetest.git] / src / map.h
index cb48cb32b65184616cb13d69f44c1975976dfdb7..09154547cf6240bf5bd44ea2aff0a9c39df8b2db 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().
@@ -514,13 +545,9 @@ class ServerMap : public Map
                Misc. helper functions for fiddling with directory and file
                names when saving
        */
-       void createDir(std::string path);
-       void createSaveDir();
-       // returns something like "xxxxxxxx"
-       std::string getSectorSubDir(v2s16 pos);
+       void createDirs(std::string path);
        // returns something like "map/sectors/xxxxxxxx"
-       std::string getSectorDir(v2s16 pos);
-       std::string createSectorDir(v2s16 pos);
+       std::string getSectorDir(v2s16 pos, int layout = 2);
        // dirname: final directory name
        v2s16 getSectorPos(std::string dirname);
        v3s16 getBlockPos(std::string sectordir, std::string blockfile);
@@ -541,7 +568,7 @@ class ServerMap : public Map
        // (no MapBlocks)
        // DEPRECATED? Sectors have no metadata anymore.
        void saveSectorMeta(ServerMapSector *sector);
-       MapSector* loadSectorMeta(std::string dirname);
+       MapSector* loadSectorMeta(std::string dirname, bool save_after_load);
        
        // Full load of a sector including all blocks.
        // returns true on success, false on failure.
@@ -552,7 +579,7 @@ class ServerMap : public Map
        
        void saveBlock(MapBlock *block);
        // This will generate a sector with getSector if not found.
-       void loadBlock(std::string sectordir, std::string blockfile, MapSector *sector);
+       void loadBlock(std::string sectordir, std::string blockfile, MapSector *sector, bool save_after_load=false);
 
        // For debug printing
        virtual void PrintInfo(std::ostream &out);
@@ -571,6 +598,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;
 };
 
 /*
@@ -780,7 +813,8 @@ struct ChunkMakeData
 
        ChunkMakeData():
                no_op(false),
-               vmanip(NULL)
+               vmanip(NULL),
+               seed(0)
        {}
 };