diff options
author | lhofhansl <lhofhansl@yahoo.com> | 2017-01-07 23:42:25 -0800 |
---|---|---|
committer | Zeno- <kde.psych@gmail.com> | 2017-01-08 17:42:25 +1000 |
commit | b0746834cc44af1086c83715d0d6f749f653f29a (patch) | |
tree | 77e46c037903a9c1d22553aad1982e09d83c8a62 /src/environment.cpp | |
parent | 8f9611bcb20f4eca69abb204bf5dc28f62fab4a2 (diff) | |
download | minetest-b0746834cc44af1086c83715d0d6f749f653f29a.tar.gz minetest-b0746834cc44af1086c83715d0d6f749f653f29a.tar.bz2 minetest-b0746834cc44af1086c83715d0d6f749f653f29a.zip |
Get neighbor from same map block if possible in ABMHandler (#4998)
Diffstat (limited to 'src/environment.cpp')
-rw-r--r-- | src/environment.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/environment.cpp b/src/environment.cpp index a0cf9dca5..50f5d58aa 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -902,14 +902,23 @@ public: if(!i->required_neighbors.empty()) { v3s16 p1; - for(p1.X = p.X-1; p1.X <= p.X+1; p1.X++) - for(p1.Y = p.Y-1; p1.Y <= p.Y+1; p1.Y++) - for(p1.Z = p.Z-1; p1.Z <= p.Z+1; p1.Z++) + for(p1.X = p0.X-1; p1.X <= p0.X+1; p1.X++) + for(p1.Y = p0.Y-1; p1.Y <= p0.Y+1; p1.Y++) + for(p1.Z = p0.Z-1; p1.Z <= p0.Z+1; p1.Z++) { - if(p1 == p) + if(p1 == p0) continue; - MapNode n = map->getNodeNoEx(p1); - content_t c = n.getContent(); + content_t c; + if (block->isValidPosition(p1)) { + // if the neighbor is found on the same map block + // get it straight from there + const MapNode &n = block->getNodeUnsafe(p1); + c = n.getContent(); + } else { + // otherwise consult the map + MapNode n = map->getNodeNoEx(p1 + block->getPosRelative()); + c = n.getContent(); + } std::set<content_t>::const_iterator k; k = i->required_neighbors.find(c); if(k != i->required_neighbors.end()){ |