Step height: Add as a player object property

Add settable player step height using the existing object property.
Breaks compatibility with old clients, add to protocol version 35.
This commit is contained in:
paramat 2017-08-06 03:57:34 +01:00 committed by paramat
parent 7cd1251d83
commit 3d0e8a691f
5 changed files with 19 additions and 2 deletions

@ -80,6 +80,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
// the main loop (related to TempMods and day/night)
//#define MAP_BLOCKSIZE 32
// Player step height in nodes
#define PLAYER_DEFAULT_STEPHEIGHT 0.6f
/*
Old stuff that shouldn't be hardcoded
*/

@ -147,6 +147,11 @@ public:
scene::IAnimatedMeshSceneNode *getAnimatedMeshSceneNode();
inline f32 getStepHeight() const
{
return m_prop.stepheight;
}
inline bool isLocalPlayer() const
{
return m_is_local_player;

@ -799,6 +799,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 * BS;
m_hp = PLAYER_MAX_HP;
}

@ -279,9 +279,15 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
// This should always apply, otherwise there are glitches
sanity_check(d > pos_max_d);
// TODO: this shouldn't be hardcoded but transmitted from server
float player_stepheight = (touching_ground) ? (BS * 0.6f) : (BS * 0.2f);
// Player object property step height is multiplied by BS in
// /src/script/common/c_content.cpp and /src/content_sao.cpp
float player_stepheight = (m_cao == nullptr) ? 0.0f :
(touching_ground ? m_cao->getStepHeight() : (0.2f * BS));
// TODO this is a problematic hack.
// Use a better implementation for autojump, or apply a custom stepheight
// to all players, as this currently creates unintended special movement
// abilities and advantages for Android players on a server.
#ifdef __ANDROID__
player_stepheight += (0.6f * BS);
#endif

@ -174,6 +174,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Add settable player collisionbox. Breaks compatibility with older
clients as a 1-node vertical offset has been removed from player's
position
Add settable player stepheight using existing object property.
Breaks compatibility with older clients.
*/
#define LATEST_PROTOCOL_VERSION 35