diff options
author | sfan5 <sfan5@live.de> | 2022-05-02 20:55:04 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2022-05-02 20:56:06 +0200 |
commit | e7659883cc6fca343785da2a1af3890ae273abbf (patch) | |
tree | b8d2e3bdbe10ed0e99074207113e24ccca3fb5df /src/map.cpp | |
parent | 663c9364289dae45aeb86a87cba826f577d84a9c (diff) | |
download | minetest-e7659883cc6fca343785da2a1af3890ae273abbf.tar.gz minetest-e7659883cc6fca343785da2a1af3890ae273abbf.tar.bz2 minetest-e7659883cc6fca343785da2a1af3890ae273abbf.zip |
Async environment for mods to do concurrent tasks (#11131)
Diffstat (limited to 'src/map.cpp')
-rw-r--r-- | src/map.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/map.cpp b/src/map.cpp index 9c9324f5f..5153dcaa9 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1896,6 +1896,7 @@ MMVManip::MMVManip(Map *map): VoxelManipulator(), m_map(map) { + assert(map); } void MMVManip::initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max, @@ -1903,6 +1904,8 @@ void MMVManip::initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max, { TimeTaker timer1("initialEmerge", &emerge_time); + assert(m_map); + // Units of these are MapBlocks v3s16 p_min = blockpos_min; v3s16 p_max = blockpos_max; @@ -1986,6 +1989,7 @@ void MMVManip::blitBackAll(std::map<v3s16, MapBlock*> *modified_blocks, { if(m_area.getExtent() == v3s16(0,0,0)) return; + assert(m_map); /* Copy data of all blocks @@ -2006,4 +2010,33 @@ void MMVManip::blitBackAll(std::map<v3s16, MapBlock*> *modified_blocks, } } +MMVManip *MMVManip::clone() const +{ + MMVManip *ret = new MMVManip(); + + const s32 size = m_area.getVolume(); + ret->m_area = m_area; + if (m_data) { + ret->m_data = new MapNode[size]; + memcpy(ret->m_data, m_data, size * sizeof(MapNode)); + } + if (m_flags) { + ret->m_flags = new u8[size]; + memcpy(ret->m_flags, m_flags, size * sizeof(u8)); + } + + ret->m_is_dirty = m_is_dirty; + // Even if the copy is disconnected from a map object keep the information + // needed to write it back to one + ret->m_loaded_blocks = m_loaded_blocks; + + return ret; +} + +void MMVManip::reparent(Map *map) +{ + assert(map && !m_map); + m_map = map; +} + //END |