Use stepheight from CAO instead of hardcoded value 5710/head
authorSapier <sapier AT gmx dot net>
Sat, 19 Dec 2015 15:37:13 +0000 (16:37 +0100)
committerEkdohibs <nathanael.courant@laposte.net>
Sat, 6 May 2017 19:18:17 +0000 (21:18 +0200)
src/constants.h
src/content_cao.h
src/content_sao.cpp
src/localplayer.cpp

index fb9e97cb3c09f3161fde756480a7e3b1e309432f..4079d0d8fb07964021dca527f0a336fa71280280 100644 (file)
@@ -90,6 +90,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 // Maximum hit points of a player
 #define PLAYER_MAX_HP 20
 
+// Player weight
+#define PLAYER_DEFAULT_WEIGHT 75
+
+// Player step height
+#define PLAYER_DEFAULT_STEPHEIGHT 0.6f
+
 // Maximal breath of a player
 #define PLAYER_MAX_BREATH 11
 
index 3be75352992eb8754a00770cb21ff912423f2882..dde1dfe6fd6868792b62a6b5e41cf80e1c4e5195 100644 (file)
@@ -154,6 +154,12 @@ public:
 
        scene::IBillboardSceneNode *getSpriteSceneNode();
 
+
+       inline f32 getStepheight() const
+       {
+               return m_prop.stepheight;
+       }
+
        inline bool isPlayer() const
        {
                return m_is_player;
index 81c6902f58b4c2b438ac38b157fa3122d0ea8e49..d59f9727618574c3e6705086de29e413dff29bad 100644 (file)
@@ -797,7 +797,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id
 
        m_prop.hp_max = PLAYER_MAX_HP;
        m_prop.physical = false;
-       m_prop.weight = 75;
+       m_prop.weight = PLAYER_DEFAULT_WEIGHT;
        m_prop.collisionbox = aabb3f(-1/3.,-1.0,-1/3., 1/3.,1.0,1/3.);
        // start of default appearance, this should be overwritten by LUA
        m_prop.visual = "upright_sprite";
@@ -811,6 +811,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id
        // end of default appearance
        m_prop.is_visible = true;
        m_prop.makes_footstep_sound = true;
+       m_prop.stepheight = PLAYER_DEFAULT_STEPHEIGHT;
        m_hp = PLAYER_MAX_HP;
 }
 
index a909ff40fd854bbe6b310a08751dbde3697f72fa..37aef7afe88beaafab0da029c94368bccfd12a49 100644 (file)
@@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "environment.h"
 #include "map.h"
 #include "client.h"
+#include "content_cao.h"
 
 /*
        LocalPlayer
@@ -343,8 +344,10 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
                }
        }
 
-       // TODO: this shouldn't be hardcoded but transmitted from server
-       float player_stepheight = touching_ground ? (BS*0.6) : (BS*0.2);
+       float player_stepheight = (m_cao == 0) ? 0.0 :
+                               (touching_ground ?
+                               (m_cao->getStepheight() * BS) :
+                               (m_cao->getStepheight() -0.4 * BS));
 
 #ifdef __ANDROID__
        player_stepheight += (0.6 * BS);