X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fmap.h;h=248312ebe5436d3f6539fe949ed9931b808583b9;hb=21df26984da91143c15587f5a03c98d68c3adc4e;hp=9dc7a101c57d39c01c4f49c1f6c1ad9c9b5d6348;hpb=0b5b2b2633609f646a534d353a2c587af4be46fa;p=dragonfireclient.git diff --git a/src/map.h b/src/map.h index 9dc7a101c..248312ebe 100644 --- 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 &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 &block_bounds, v3s16 &check); bool isOccluded(const v3s16 &pos_camera, const v3s16 &pos_target, @@ -327,7 +332,7 @@ class ServerMap : public Map - Create blank filled with CONTENT_IGNORE */ - MapBlock *emergeBlock(v3s16 p, bool create_blank=true); + MapBlock *emergeBlock(v3s16 p, bool create_blank=true) override; /* Try to get a block. @@ -349,27 +354,26 @@ class ServerMap : public Map static MapDatabase *createDatabase(const std::string &name, const std::string &savedir, Settings &conf); // Call these before and after saving of blocks - void beginSave(); - void endSave(); + void beginSave() override; + void endSave() override; - void save(ModifiedState save_level); + void save(ModifiedState save_level) override; void listAllLoadableBlocks(std::vector &dst); - void listAllLoadedBlocks(std::vector &dst); MapgenParams *getMapgenParams(); - bool saveBlock(MapBlock *block); + bool saveBlock(MapBlock *block) override; static bool saveBlock(MapBlock *block, MapDatabase *db, int compression_level = -1); MapBlock* loadBlock(v3s16 p); // Database version void loadBlock(std::string *blob, v3s16 p3d, MapSector *sector, bool save_after_load=false); - bool deleteBlock(v3s16 blockpos); + bool deleteBlock(v3s16 blockpos) override; void updateVManip(v3s16 pos); // For debug printing - virtual void PrintInfo(std::ostream &out); + void PrintInfo(std::ostream &out) override; bool isSavingEnabled(){ return m_map_saving_enabled; } @@ -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 * 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