diff options
author | est31 <MTest31@outlook.com> | 2016-12-22 23:16:00 +0100 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2016-12-22 23:16:00 +0100 |
commit | 81d56b94919dceb7b2e51d70b21a7ca22f852bd5 (patch) | |
tree | 1e9ef1be1b3295a8673d6e4f0bdeb4c2d3a6015f /src/mapsector.cpp | |
parent | 8077612dcb48221281e726a60eb97bf73fde462b (diff) | |
parent | 231ac33d34dfaaddf292c5f31b1eae43eeefba2d (diff) | |
download | minetest-81d56b94919dceb7b2e51d70b21a7ca22f852bd5.tar.gz minetest-81d56b94919dceb7b2e51d70b21a7ca22f852bd5.tar.bz2 minetest-81d56b94919dceb7b2e51d70b21a7ca22f852bd5.zip |
Merge 0.4.15 changes into stable-0.4
0.4.15 release!
Diffstat (limited to 'src/mapsector.cpp')
-rw-r--r-- | src/mapsector.cpp | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/src/mapsector.cpp b/src/mapsector.cpp index 1588a5962..410689f5e 100644 --- a/src/mapsector.cpp +++ b/src/mapsector.cpp @@ -42,9 +42,8 @@ void MapSector::deleteBlocks() m_block_cache = NULL; // Delete all - for(std::map<s16, MapBlock*>::iterator i = m_blocks.begin(); - i != m_blocks.end(); ++i) - { + for (UNORDERED_MAP<s16, MapBlock*>::iterator i = m_blocks.begin(); + i != m_blocks.end(); ++i) { delete i->second; } @@ -56,20 +55,13 @@ MapBlock * MapSector::getBlockBuffered(s16 y) { MapBlock *block; - if(m_block_cache != NULL && y == m_block_cache_y){ + if (m_block_cache != NULL && y == m_block_cache_y) { return m_block_cache; } // If block doesn't exist, return NULL - std::map<s16, MapBlock*>::iterator n = m_blocks.find(y); - if(n == m_blocks.end()) - { - block = NULL; - } - // If block exists, return it - else{ - block = n->second; - } + UNORDERED_MAP<s16, MapBlock*>::iterator n = m_blocks.find(y); + block = (n != m_blocks.end() ? n->second : NULL); // Cache the last result m_block_cache_y = y; @@ -135,18 +127,12 @@ void MapSector::deleteBlock(MapBlock *block) void MapSector::getBlocks(MapBlockVect &dest) { - for(std::map<s16, MapBlock*>::iterator bi = m_blocks.begin(); - bi != m_blocks.end(); ++bi) - { + for (UNORDERED_MAP<s16, MapBlock*>::iterator bi = m_blocks.begin(); + bi != m_blocks.end(); ++bi) { dest.push_back(bi->second); } } -bool MapSector::empty() -{ - return m_blocks.empty(); -} - /* ServerMapSector */ |