diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-10-17 01:04:22 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-10-17 01:04:22 +0300 |
commit | b0481b9db1769fa505b68a91f17f1aa6aee66438 (patch) | |
tree | 6444dd269e87184af72045c5416e4ef5d7961d65 /src | |
parent | 5f39885975dcd73a9589ce9be0aeb908eebc3450 (diff) | |
download | minetest-b0481b9db1769fa505b68a91f17f1aa6aee66438.tar.gz minetest-b0481b9db1769fa505b68a91f17f1aa6aee66438.tar.bz2 minetest-b0481b9db1769fa505b68a91f17f1aa6aee66438.zip |
Fix chest not working after walked away and came back
Diffstat (limited to 'src')
-rw-r--r-- | src/map.cpp | 18 | ||||
-rw-r--r-- | src/map.h | 4 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/map.cpp b/src/map.cpp index 2d661a522..63c6ad57c 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -35,6 +35,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "settings.h" #include "log.h" +#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" + /* SQLite format specification: - Initially only replaces sectors/ and sectors2/ @@ -1819,9 +1821,14 @@ NodeMetadata* Map::getNodeMetadata(v3s16 p) v3s16 blockpos = getNodeBlockPos(p); v3s16 p_rel = p - blockpos*MAP_BLOCKSIZE; MapBlock *block = getBlockNoCreateNoEx(blockpos); - if(block == NULL) + if(!block){ + infostream<<"Map::getNodeMetadata(): Need to emerge " + <<PP(blockpos)<<std::endl; + block = emergeBlock(blockpos, false); + } + if(!block) { - infostream<<"WARNING: Map::setNodeMetadata(): Block not found" + infostream<<"WARNING: Map::getNodeMetadata(): Block not found" <<std::endl; return NULL; } @@ -1834,7 +1841,12 @@ void Map::setNodeMetadata(v3s16 p, NodeMetadata *meta) v3s16 blockpos = getNodeBlockPos(p); v3s16 p_rel = p - blockpos*MAP_BLOCKSIZE; MapBlock *block = getBlockNoCreateNoEx(blockpos); - if(block == NULL) + if(!block){ + infostream<<"Map::setNodeMetadata(): Need to emerge " + <<PP(blockpos)<<std::endl; + block = emergeBlock(blockpos, false); + } + if(!block) { infostream<<"WARNING: Map::setNodeMetadata(): Block not found" <<std::endl; @@ -157,6 +157,10 @@ public: // Returns NULL if not found MapBlock * getBlockNoCreateNoEx(v3s16 p); + /* Server overrides */ + virtual MapBlock * emergeBlock(v3s16 p, bool allow_generate=true) + { return getBlockNoCreateNoEx(p); } + // Returns InvalidPositionException if not found bool isNodeUnderground(v3s16 p); |