summaryrefslogtreecommitdiff
path: root/src/client/localplayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/localplayer.cpp')
-rw-r--r--src/client/localplayer.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/client/localplayer.cpp b/src/client/localplayer.cpp
index c086d860a..c20c3619f 100644
--- a/src/client/localplayer.cpp
+++ b/src/client/localplayer.cpp
@@ -184,8 +184,8 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
v3f position = getPosition();
// Copy parent position if local player is attached
- if (isAttached) {
- setPosition(overridePosition);
+ if (getParent()) {
+ setPosition(m_cao->getPosition());
added_velocity = v3f(0.0f); // ignored
return;
}
@@ -474,7 +474,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
setYaw(control.yaw);
// Nullify speed and don't run positioning code if the player is attached
- if (isAttached) {
+ if (getParent()) {
setSpeed(v3f(0.0f));
return;
}
@@ -706,6 +706,11 @@ v3f LocalPlayer::getEyeOffset() const
return v3f(0.0f, BS * eye_height, 0.0f);
}
+ClientActiveObject *LocalPlayer::getParent() const
+{
+ return m_cao ? m_cao->getParent() : nullptr;
+}
+
bool LocalPlayer::isDead() const
{
FATAL_ERROR_IF(!getCAO(), "LocalPlayer's CAO isn't initialized");
@@ -764,8 +769,8 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
v3f position = getPosition();
// Copy parent position if local player is attached
- if (isAttached) {
- setPosition(overridePosition);
+ if (getParent()) {
+ setPosition(m_cao->getPosition());
m_sneak_node_exists = false;
added_velocity = v3f(0.0f);
return;