]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Fix legit_speed
authorElias Fleckenstein <eliasfleckenstein@web.de>
Fri, 26 Mar 2021 11:57:30 +0000 (12:57 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Fri, 26 Mar 2021 11:57:30 +0000 (12:57 +0100)
src/client/localplayer.cpp
src/client/localplayer.h

index ddec04cb50a4e5ee4bd8c7ca2f9eb0628286af4e..c75404a4ba8f27577a8579aa1ef93569df227dbe 100644 (file)
@@ -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;
        }
 
index 0e071d2b4862a0eb117bbce618c2a831b4a08118..842c1801556abf62c82e3de285ba111c6f29eb6a 100644 (file)
@@ -140,8 +140,8 @@ class LocalPlayer : public Player
        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 @@ class LocalPlayer : public Player
                        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 @@ class LocalPlayer : public Player
        {
                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);