Noise: Prevent unittest crash caused by division by zero
[oweals/minetest.git] / src / content_cao.cpp
index aff143bf2ddc95529485dfe73e0b9c7c466cb379..2cc675573c26076cf94b7cbfa88f02557b4740db 100644 (file)
@@ -283,8 +283,14 @@ public:
 
        void initialize(const std::string &data);
 
-       aabb3f *getSelectionBox()
-               {return &m_selection_box;}
+
+       virtual bool getSelectionBox(aabb3f *toset) const
+       {
+               *toset = m_selection_box;
+               return true;
+       }
+
+
        v3f getPosition()
                {return m_position;}
        inline float getYaw() const
@@ -605,11 +611,14 @@ GenericCAO::~GenericCAO()
        removeFromScene(true);
 }
 
-aabb3f *GenericCAO::getSelectionBox()
+bool GenericCAO::getSelectionBox(aabb3f *toset) const
 {
-       if(!m_prop.is_visible || !m_is_visible || m_is_local_player || getParent() != NULL)
-               return NULL;
-       return &m_selection_box;
+       if (!m_prop.is_visible || !m_is_visible || m_is_local_player
+                       || getParent() != NULL){
+               return false;
+       }
+       *toset = m_selection_box;
+       return true;
 }
 
 v3f GenericCAO::getPosition()
@@ -658,7 +667,7 @@ void GenericCAO::setAttachments()
        updateAttachments();
 }
 
-ClientActiveObject* GenericCAO::getParent()
+ClientActiveObject* GenericCAO::getParent() const
 {
        ClientActiveObject *obj = NULL;
 
@@ -963,7 +972,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
                if (m_is_visible) {
                        int old_anim = player->last_animation;
                        float old_anim_speed = player->last_animation_speed;
-                       m_position = player->getPosition() + v3f(0,BS,0);
+                       m_position = player->getPosition();
                        m_velocity = v3f(0,0,0);
                        m_acceleration = v3f(0,0,0);
                        pos_translator.vect_show = m_position;
@@ -1503,6 +1512,7 @@ void GenericCAO::processMessage(const std::string &data)
                if (m_is_local_player) {
                        LocalPlayer *player = m_env->getLocalPlayer();
                        player->makes_footstep_sound = m_prop.makes_footstep_sound;
+                       player->setCollisionbox(m_selection_box);
                }
 
                if ((m_is_player && !m_is_local_player) && m_prop.nametag == "")