diff --git a/src/serverenvironment.cpp b/src/serverenvironment.cpp index 8d86a4e0..e89eb349 100644 --- a/src/serverenvironment.cpp +++ b/src/serverenvironment.cpp @@ -1850,6 +1850,25 @@ void ServerEnvironment::activateObjects(MapBlock *block, u32 dtime_s) if(block == NULL) return; + v3s16 basepos = block->getPos() * MAP_BLOCKSIZE; + const s16 s = MAP_BLOCKSIZE / 4; // tolerate being off by this much + for (std::vector::iterator + it = block->m_static_objects.m_stored.begin(); + it != block->m_static_objects.m_stored.end();) { + v3s16 objpos = floatToInt(it->pos, BS); + + if (objpos.X < basepos.X-s || objpos.X > basepos.X + MAP_BLOCKSIZE+s || + objpos.Y < basepos.Y-s || objpos.Y > basepos.Y + MAP_BLOCKSIZE+s || + objpos.Z < basepos.Z-s || objpos.Z > basepos.Z + MAP_BLOCKSIZE+s) { + errorstream << "ServerEnvironment::activateObjects(): " + << "Object at " << PP(objpos) << " should not be in block " + << PP(block->getPos()) << "; deleting it." << std::endl; + it = block->m_static_objects.m_stored.erase(it); + } else { + it++; + } + } + // Ignore if no stored objects (to not set changed flag) if(block->m_static_objects.m_stored.empty()) return;