summaryrefslogtreecommitdiff
path: root/src/mapblock.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mapblock.h')
-rw-r--r--src/mapblock.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/mapblock.h b/src/mapblock.h
index 5a0ec937a..bec3b6f56 100644
--- a/src/mapblock.h
+++ b/src/mapblock.h
@@ -669,14 +669,18 @@ typedef std::vector<MapBlock*> MapBlockVect;
inline bool objectpos_over_limit(v3f p)
{
- const float map_gen_limit_bs = MYMIN(MAX_MAP_GENERATION_LIMIT,
- g_settings->getU16("map_generation_limit")) * BS;
- return (p.X < -map_gen_limit_bs
- || p.X > map_gen_limit_bs
- || p.Y < -map_gen_limit_bs
- || p.Y > map_gen_limit_bs
- || p.Z < -map_gen_limit_bs
- || p.Z > map_gen_limit_bs);
+ // MAP_BLOCKSIZE must be subtracted to avoid an object being spawned just
+ // within the map generation limit but in a block and sector that extend
+ // beyond the map generation limit.
+ // This avoids crashes caused by sector over limit in createSector().
+ const float object_limit = (MYMIN(MAX_MAP_GENERATION_LIMIT,
+ g_settings->getU16("map_generation_limit")) - MAP_BLOCKSIZE) * BS;
+ return (p.X < -object_limit
+ || p.X > object_limit
+ || p.Y < -object_limit
+ || p.Y > object_limit
+ || p.Z < -object_limit
+ || p.Z > object_limit);
}
/*