aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHybridDog <ovvv@web.de>2016-01-04 17:21:33 +0100
committerparamat <mat.gregory@virginmedia.com>2016-03-14 08:44:28 +0000
commitc0b6986e3875e6f42682c78fd5db0080a7bae651 (patch)
treebc03d65ada090bb6538e55912be1398a2918b3d8 /src
parent5a40a7dad8cbf46320c3b5dd1122808eb4919b62 (diff)
downloadminetest-c0b6986e3875e6f42682c78fd5db0080a7bae651.tar.gz
minetest-c0b6986e3875e6f42682c78fd5db0080a7bae651.tar.bz2
minetest-c0b6986e3875e6f42682c78fd5db0080a7bae651.zip
Fix player teleportation bug whilst sneaking
Only set back position when sneaking if player wasn't teleported by adding and using a bool "got_teleported" to player it fixes #2876
Diffstat (limited to 'src')
-rw-r--r--src/localplayer.cpp5
-rw-r--r--src/network/clientpackethandler.cpp1
-rw-r--r--src/player.cpp1
-rw-r--r--src/player.h1
4 files changed, 7 insertions, 1 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 0c94582aa..dbd8c4a61 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -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);
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp
index a49bbe167..28d147d38 100644
--- a/src/network/clientpackethandler.cpp
+++ b/src/network/clientpackethandler.cpp
@@ -552,6 +552,7 @@ void Client::handleCommand_MovePlayer(NetworkPacket* pkt)
*pkt >> pos >> pitch >> yaw;
+ player->got_teleported = true;
player->setPosition(pos);
infostream << "Client got TOCLIENT_MOVE_PLAYER"
diff --git a/src/player.cpp b/src/player.cpp
index 623dde230..5949712a5 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Player::Player(IGameDef *gamedef, const char *name):
+ got_teleported(false),
touching_ground(false),
in_liquid(false),
in_liquid_stable(false),
diff --git a/src/player.h b/src/player.h
index 50267c72c..b317cda4f 100644
--- a/src/player.h
+++ b/src/player.h
@@ -318,6 +318,7 @@ public:
// Use a function, if isDead can be defined by other conditions
bool isDead() { return hp == 0; }
+ bool got_teleported;
bool touching_ground;
// This oscillates so that the player jumps a bit above the surface
bool in_liquid;