Skip to content

Commit 45ab62d

Browse files
SapierEkdohibs
Sapier
authored andcommittedMay 6, 2017
Use stepheight from CAO instead of hardcoded value
1 parent 5ebf8f9 commit 45ab62d

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed
 

‎src/constants.h

+6
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
9090
// Maximum hit points of a player
9191
#define PLAYER_MAX_HP 20
9292

93+
// Player weight
94+
#define PLAYER_DEFAULT_WEIGHT 75
95+
96+
// Player step height
97+
#define PLAYER_DEFAULT_STEPHEIGHT 0.6f
98+
9399
// Maximal breath of a player
94100
#define PLAYER_MAX_BREATH 11
95101

‎src/content_cao.h

+6
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ class GenericCAO : public ClientActiveObject
154154

155155
scene::IBillboardSceneNode *getSpriteSceneNode();
156156

157+
158+
inline f32 getStepheight() const
159+
{
160+
return m_prop.stepheight;
161+
}
162+
157163
inline bool isPlayer() const
158164
{
159165
return m_is_player;

‎src/content_sao.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id
797797

798798
m_prop.hp_max = PLAYER_MAX_HP;
799799
m_prop.physical = false;
800-
m_prop.weight = 75;
800+
m_prop.weight = PLAYER_DEFAULT_WEIGHT;
801801
m_prop.collisionbox = aabb3f(-1/3.,-1.0,-1/3., 1/3.,1.0,1/3.);
802802
// start of default appearance, this should be overwritten by LUA
803803
m_prop.visual = "upright_sprite";
@@ -811,6 +811,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id
811811
// end of default appearance
812812
m_prop.is_visible = true;
813813
m_prop.makes_footstep_sound = true;
814+
m_prop.stepheight = PLAYER_DEFAULT_STEPHEIGHT;
814815
m_hp = PLAYER_MAX_HP;
815816
}
816817

‎src/localplayer.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2626
#include "environment.h"
2727
#include "map.h"
2828
#include "client.h"
29+
#include "content_cao.h"
2930

3031
/*
3132
LocalPlayer
@@ -343,8 +344,10 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
343344
}
344345
}
345346

346-
// TODO: this shouldn't be hardcoded but transmitted from server
347-
float player_stepheight = touching_ground ? (BS*0.6) : (BS*0.2);
347+
float player_stepheight = (m_cao == 0) ? 0.0 :
348+
(touching_ground ?
349+
(m_cao->getStepheight() * BS) :
350+
(m_cao->getStepheight() -0.4 * BS));
348351

349352
#ifdef __ANDROID__
350353
player_stepheight += (0.6 * BS);

0 commit comments

Comments
 (0)