]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/map.h
Merge branch 'master' of https://github.com/minetest/minetest
[dragonfireclient.git] / src / map.h
index d8ed291061f8f2167ec4541707a4b32a8baa7bff..248312ebe5436d3f6539fe949ed9931b808583b9 100644 (file)
--- a/src/map.h
+++ b/src/map.h
@@ -151,7 +151,9 @@ class Map /*: public NodeContainer*/
        MapBlock * getBlockNoCreate(v3s16 p);
        // Returns NULL if not found
        MapBlock * getBlockNoCreateNoEx(v3s16 p);
-
+       
+       void listAllLoadedBlocks(std::vector<v3s16> &dst);
+       
        /* Server overrides */
        virtual MapBlock * emergeBlock(v3s16 p, bool create_blank=true)
        { return getBlockNoCreateNoEx(p); }
@@ -275,6 +277,9 @@ class Map /*: public NodeContainer*/
        // This stores the properties of the nodes on the map.
        const NodeDefManager *m_nodedef;
 
+       // Can be implemented by child class
+       virtual void reportMetrics(u64 save_time_us, u32 saved_blocks, u32 all_blocks) {}
+
        bool determineAdditionalOcclusionCheck(const v3s16 &pos_camera,
                const core::aabbox3d<s16> &block_bounds, v3s16 &check);
        bool isOccluded(const v3s16 &pos_camera, const v3s16 &pos_target,
@@ -354,7 +359,6 @@ class ServerMap : public Map
 
        void save(ModifiedState save_level) override;
        void listAllLoadableBlocks(std::vector<v3s16> &dst);
-       void listAllLoadedBlocks(std::vector<v3s16> &dst);
 
        MapgenParams *getMapgenParams();
 
@@ -392,6 +396,10 @@ class ServerMap : public Map
 
        MapSettingsManager settings_mgr;
 
+protected:
+
+       void reportMetrics(u64 save_time_us, u32 saved_blocks, u32 all_blocks) override;
+
 private:
        friend class LuaVoxelManip;
 
@@ -420,7 +428,10 @@ class ServerMap : public Map
        MapDatabase *dbase = nullptr;
        MapDatabase *dbase_ro = nullptr;
 
+       // Map metrics
+       MetricGaugePtr m_loaded_blocks_gauge;
        MetricCounterPtr m_save_time_counter;
+       MetricCounterPtr m_save_count_counter;
 };
 
 
@@ -446,10 +457,25 @@ class MMVManip : public VoxelManipulator
        void blitBackAll(std::map<v3s16, MapBlock*> * modified_blocks,
                bool overwrite_generated = true);
 
+       /*
+               Creates a copy of this VManip including contents, the copy will not be
+               associated with a Map.
+       */
+       MMVManip *clone() const;
+
+       // Reassociates a copied VManip to a map
+       void reparent(Map *map);
+
+       // Is it impossible to call initialEmerge / blitBackAll?
+       inline bool isOrphan() const { return !m_map; }
+
        bool m_is_dirty = false;
 
 protected:
-       Map *m_map;
+       MMVManip() {};
+
+       // may be null
+       Map *m_map = nullptr;
        /*
                key = blockpos
                value = flags describing the block