diff options
author | Christof Kaufmann <christofkaufmann1986@gmail.com> | 2015-08-18 12:05:24 +0200 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2015-09-26 21:40:45 +0200 |
commit | 8787d2e7e9671f3b5930ca9c41c6e0867b8a5a54 (patch) | |
tree | 149bf77f912f5c346075876134289511fa0dc07c /src | |
parent | 776760aba730f1db565d124b4c04efae1c152d9e (diff) | |
download | minetest-8787d2e7e9671f3b5930ca9c41c6e0867b8a5a54.tar.gz minetest-8787d2e7e9671f3b5930ca9c41c6e0867b8a5a54.tar.bz2 minetest-8787d2e7e9671f3b5930ca9c41c6e0867b8a5a54.zip |
Fix falling through nodes on world load (fixes #2784)
On world load the collision code can not see node boxes, since the
nodes have not been loaded. Thus it collided only at the next full
node. However, standing on a slab on world load leaded to sinking into
it until the world finished loading. Then one maybe fell further, if
the node below was not walkable.
Now, with this commit, when no node around the player has been loaded
it simply does not move the player.
Diffstat (limited to 'src')
-rw-r--r-- | src/collision.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/collision.cpp b/src/collision.cpp index adb6970f5..5d52202d9 100644 --- a/src/collision.cpp +++ b/src/collision.cpp @@ -245,6 +245,8 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef, s16 max_y = MYMAX(oldpos_i.Y, newpos_i.Y) + (box_0.MaxEdge.Y / BS) + 1; s16 max_z = MYMAX(oldpos_i.Z, newpos_i.Z) + (box_0.MaxEdge.Z / BS) + 1; + bool any_position_valid = false; + for(s16 x = min_x; x <= max_x; x++) for(s16 y = min_y; y <= max_y; y++) for(s16 z = min_z; z <= max_z; z++) @@ -257,6 +259,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef, if (is_position_valid) { // Object collides into walkable nodes + any_position_valid = true; const ContentFeatures &f = gamedef->getNodeDefManager()->get(n); if(f.walkable == false) continue; @@ -289,6 +292,12 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef, is_object.push_back(false); } } + + // Do not move if world has not loaded yet, since custom node boxes + // are not available for collision detection. + if (!any_position_valid) + return result; + } // tt2 if(collideWithObjects) @@ -298,7 +307,6 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef, /* add object boxes to cboxes */ - std::vector<ActiveObject*> objects; #ifndef SERVER ClientEnvironment *c_env = dynamic_cast<ClientEnvironment*>(env); |