Fix player teleportation bug whilst sneaking
[oweals/minetest.git] / src / localplayer.cpp
index 524c6272ec51d00569abdca3c50deac351d519bc..dbd8c4a6113856c71400865ba153a0ef12eab1a2 100644 (file)
@@ -183,7 +183,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
        */
        if (control.sneak && m_sneak_node_exists &&
                        !(fly_allowed && g_settings->getBool("free_move")) && !in_liquid &&
-                       physics_override_sneak) {
+                       physics_override_sneak && !got_teleported) {
                f32 maxd = 0.5 * BS + sneak_max;
                v3f lwn_f = intToFloat(m_sneak_node, BS);
                position.X = rangelim(position.X, lwn_f.X-maxd, lwn_f.X+maxd);
@@ -204,6 +204,9 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
                }
        }
 
+       if (got_teleported)
+               got_teleported = false;
+
        // this shouldn't be hardcoded but transmitted from server
        float player_stepheight = touching_ground ? (BS*0.6) : (BS*0.2);
 
@@ -310,7 +313,8 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
                if (sneak_node_found) {
                        f32 cb_max = 0;
                        MapNode n = map->getNodeNoEx(m_sneak_node);
-                       std::vector<aabb3f> nodeboxes = n.getCollisionBoxes(nodemgr);
+                       std::vector<aabb3f> nodeboxes;
+                       n.getCollisionBoxes(nodemgr, &nodeboxes);
                        for (std::vector<aabb3f>::iterator it = nodeboxes.begin();
                                        it != nodeboxes.end(); ++it) {
                                aabb3f box = *it;