Player::getSpeed/setSpeed use const refs
authorLoic Blot <loic.blot@unix-experience.fr>
Mon, 14 Aug 2017 08:56:06 +0000 (10:56 +0200)
committerLoic Blot <loic.blot@unix-experience.fr>
Mon, 14 Aug 2017 08:56:06 +0000 (10:56 +0200)
src/camera.cpp
src/clientiface.cpp
src/player.h

index efd8a338952b79adefd276eee92f9a9623d4b1f5..7406aba0323533402b7ddf46009a84e6912e0244 100644 (file)
@@ -526,7 +526,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime,
        // If the player is walking, swimming, or climbing,
        // view bobbing is enabled and free_move is off,
        // start (or continue) the view bobbing animation.
-       v3f speed = player->getSpeed();
+       const v3f &speed = player->getSpeed();
        const bool movement_XZ = hypot(speed.X, speed.Z) > BS;
        const bool movement_Y = fabs(speed.Y) > BS;
 
index 361315c3bcb6411456e61afd202a61d1c17a84cc..fdabcc7839fadc56813a770943fa738e883ccf3c 100644 (file)
@@ -95,7 +95,7 @@ void RemoteClient::GetNextBlocks (
        }
 
        v3f playerpos = sao->getBasePosition();
-       v3f playerspeed = player->getSpeed();
+       const v3f &playerspeed = player->getSpeed();
        v3f playerspeeddir(0,0,0);
        if(playerspeed.getLength() > 1.0*BS)
                playerspeeddir = playerspeed / playerspeed.getLength();
index 0b2cbbfb27eab0e369ce8fa6c91fab082702830e..1d9882775398beeaa5b846a7c053e1058e50e228 100644 (file)
@@ -104,12 +104,12 @@ public:
                        std::vector<CollisionInfo> *collision_info)
        {}
 
-       v3f getSpeed()
+       const v3f &getSpeed() const
        {
                return m_speed;
        }
 
-       void setSpeed(v3f speed)
+       void setSpeed(const v3f &speed)
        {
                m_speed = speed;
        }