Skip to content

Commit

Permalink
Fix object position border checking
Browse files Browse the repository at this point in the history
Borders have to be converted into BS format in order to be accurately comparable to
object positions.
  • Loading branch information
est31 committed Sep 16, 2015
1 parent f61f817 commit 6c81be5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/environment.cpp
Expand Up @@ -1495,8 +1495,10 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object,
}

if (objectpos_over_limit(object->getBasePosition())) {
v3f p = object->getBasePosition();
errorstream << "ServerEnvironment::addActiveObjectRaw(): "
<< "object position outside maximum range" << std::endl;
<< "object position (" << p.X << "," << p.Y << "," << p.Z
<< ") outside maximum range" << std::endl;
if (object->environmentDeletes())
delete object;
return 0;
Expand Down
16 changes: 8 additions & 8 deletions src/mapblock.h
Expand Up @@ -639,14 +639,14 @@ typedef std::vector<MapBlock*> MapBlockVect;

inline bool objectpos_over_limit(v3f p)
{
const static u16 map_gen_limit = MYMIN(MAX_MAP_GENERATION_LIMIT,
g_settings->getU16("map_generation_limit"));
return (p.X < -map_gen_limit
|| p.X > map_gen_limit
|| p.Y < -map_gen_limit
|| p.Y > map_gen_limit
|| p.Z < -map_gen_limit
|| p.Z > map_gen_limit);
const static 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);
}

inline bool blockpos_over_limit(v3s16 p)
Expand Down

0 comments on commit 6c81be5

Please sign in to comment.