diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-07-01 21:04:40 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-07-01 21:04:40 +0300 |
commit | 71f5d4b3443c6ea770463838a2c84b85d9fa3b21 (patch) | |
tree | 8457916fda22b9a19194e6c8163e742443fefdb1 /src/map.cpp | |
parent | 282912caa0f8a19d5b5fb94a3cb6a41432a3a2df (diff) | |
download | minetest-71f5d4b3443c6ea770463838a2c84b85d9fa3b21.tar.gz minetest-71f5d4b3443c6ea770463838a2c84b85d9fa3b21.tar.bz2 minetest-71f5d4b3443c6ea770463838a2c84b85d9fa3b21.zip |
Fixed objects being sometimes not able to be stored statically in a block when block has been unloaded
Diffstat (limited to 'src/map.cpp')
-rw-r--r-- | src/map.cpp | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/src/map.cpp b/src/map.cpp index 79f2a40af..dc66b4d55 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2442,23 +2442,51 @@ MapBlock * ServerMap::createBlock(v3s16 p) return block; } -#if 0 -MapBlock * ServerMap::emergeBlock( - v3s16 p, - bool only_from_disk, - core::map<v3s16, MapBlock*> &changed_blocks, - core::map<v3s16, MapBlock*> &lighting_invalidated_blocks -) +MapBlock * ServerMap::emergeBlock(v3s16 p, bool allow_generate) { - DSTACKF("%s: p=(%d,%d,%d), only_from_disk=%d", + DSTACKF("%s: p=(%d,%d,%d), allow_generate=%d", __FUNCTION_NAME, - p.X, p.Y, p.Z, only_from_disk); + p.X, p.Y, p.Z, allow_generate); - // This has to be redone or removed - assert(0); + { + MapBlock *block = getBlockNoCreateNoEx(p); + if(block) + return block; + } + + { + MapBlock *block = loadBlock(p); + if(block) + return block; + } + + if(allow_generate) + { + core::map<v3s16, MapBlock*> modified_blocks; + MapBlock *block = generateBlock(p, modified_blocks); + if(block) + { + MapEditEvent event; + event.type = MEET_OTHER; + event.p = p; + + // Copy modified_blocks to event + for(core::map<v3s16, MapBlock*>::Iterator + i = modified_blocks.getIterator(); + i.atEnd()==false; i++) + { + event.modified_blocks.insert(i.getNode()->getKey(), false); + } + + // Queue event + dispatchEvent(&event); + + return block; + } + } + return NULL; } -#endif #if 0 /* |