diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-03-26 12:57:30 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-03-26 12:57:30 +0100 |
commit | 63f7c96ec20724aef1ed03bae0793db892cf23d5 (patch) | |
tree | 368817134ab564a00b012b30a2dde9142919154f | |
parent | 22f73e9f279db40a7357ca955c279ffd5dd881d8 (diff) | |
download | dragonfireclient-63f7c96ec20724aef1ed03bae0793db892cf23d5.tar.xz |
Fix legit_speed
-rw-r--r-- | src/client/localplayer.cpp | 4 | ||||
-rw-r--r-- | src/client/localplayer.h | 20 |
2 files changed, 11 insertions, 13 deletions
diff --git a/src/client/localplayer.cpp b/src/client/localplayer.cpp index ddec04cb5..c75404a4b 100644 --- a/src/client/localplayer.cpp +++ b/src/client/localplayer.cpp @@ -172,7 +172,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d, { if (m_cao && m_cao->m_waiting_for_reattach > 0) m_cao->m_waiting_for_reattach -= dtime; - + // Node at feet position, update each ClientEnvironment::step() if (!collision_info || collision_info->empty()) m_standing_node = floatToInt(m_position, BS); @@ -461,8 +461,6 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d, m_speed.Y += jumpspeed; } setSpeed(m_speed); - if (! m_freecam) - m_legit_speed = m_speed; m_can_jump = false; } diff --git a/src/client/localplayer.h b/src/client/localplayer.h index 0e071d2b4..842c18015 100644 --- a/src/client/localplayer.h +++ b/src/client/localplayer.h @@ -140,8 +140,8 @@ public: v3f getPosition() const { return m_position; } v3f getLegitPosition() const { return m_legit_position; } - - v3f getLegitSpeed() const { return m_legit_speed; } + + v3f getLegitSpeed() const { return m_freecam ? m_legit_speed : m_speed; } inline void setLegitPosition(const v3f &position) { @@ -151,18 +151,18 @@ public: setPosition(position); } - inline void freecamEnable() + inline void freecamEnable() { m_freecam = true; } - - inline void freecamDisable() + + inline void freecamDisable() { m_freecam = false; setPosition(m_legit_position); setSpeed(m_legit_speed); } - + // Non-transformed eye offset getters // For accurate positions, use the Camera functions v3f getEyePosition() const { return m_position + getEyeOffset(); } @@ -184,13 +184,13 @@ public: { added_velocity += vel; } - + void tryReattach(int id); - + bool isWaitingForReattach() const; - + bool canWalkOn(const ContentFeatures &f); - + private: void accelerate(const v3f &target_speed, const f32 max_increase_H, const f32 max_increase_V, const bool use_pitch); |