Objectpos over limit: Avoid crash caused by sector over limit
Reduce the object limit by mapblock size, to avoid objects being added just inside the map generation limit but in a block and sector that extend beyond the map generation limit. Change notification of 'objectpos over limit' from red in-chat ERROR to in-terminal only WARNING, since this will happen often using mob mods near the world's edge.master
parent
2dcbc01904
commit
3955f51253
|
@ -669,14 +669,18 @@ typedef std::vector<MapBlock*> MapBlockVect;
|
||||||
|
|
||||||
inline bool objectpos_over_limit(v3f p)
|
inline bool objectpos_over_limit(v3f p)
|
||||||
{
|
{
|
||||||
const float map_gen_limit_bs = MYMIN(MAX_MAP_GENERATION_LIMIT,
|
// MAP_BLOCKSIZE must be subtracted to avoid an object being spawned just
|
||||||
g_settings->getU16("map_generation_limit")) * BS;
|
// within the map generation limit but in a block and sector that extend
|
||||||
return (p.X < -map_gen_limit_bs
|
// beyond the map generation limit.
|
||||||
|| p.X > map_gen_limit_bs
|
// This avoids crashes caused by sector over limit in createSector().
|
||||||
|| p.Y < -map_gen_limit_bs
|
const float object_limit = (MYMIN(MAX_MAP_GENERATION_LIMIT,
|
||||||
|| p.Y > map_gen_limit_bs
|
g_settings->getU16("map_generation_limit")) - MAP_BLOCKSIZE) * BS;
|
||||||
|| p.Z < -map_gen_limit_bs
|
return (p.X < -object_limit
|
||||||
|| p.Z > map_gen_limit_bs);
|
|| p.X > object_limit
|
||||||
|
|| p.Y < -object_limit
|
||||||
|
|| p.Y > object_limit
|
||||||
|
|| p.Z < -object_limit
|
||||||
|
|| p.Z > object_limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1667,7 +1667,7 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object,
|
||||||
|
|
||||||
if (objectpos_over_limit(object->getBasePosition())) {
|
if (objectpos_over_limit(object->getBasePosition())) {
|
||||||
v3f p = object->getBasePosition();
|
v3f p = object->getBasePosition();
|
||||||
errorstream << "ServerEnvironment::addActiveObjectRaw(): "
|
warningstream << "ServerEnvironment::addActiveObjectRaw(): "
|
||||||
<< "object position (" << p.X << "," << p.Y << "," << p.Z
|
<< "object position (" << p.X << "," << p.Y << "," << p.Z
|
||||||
<< ") outside maximum range" << std::endl;
|
<< ") outside maximum range" << std::endl;
|
||||||
if (object->environmentDeletes())
|
if (object->environmentDeletes())
|
||||||
|
|
Loading…
Reference in New Issue