diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/constants.h | 3 | ||||
-rw-r--r-- | src/content_cao.h | 5 | ||||
-rw-r--r-- | src/content_sao.cpp | 1 | ||||
-rw-r--r-- | src/localplayer.cpp | 12 | ||||
-rw-r--r-- | src/network/networkprotocol.h | 2 |
5 files changed, 20 insertions, 3 deletions
diff --git a/src/constants.h b/src/constants.h index fb9e97cb3..e615d00cd 100644 --- a/src/constants.h +++ b/src/constants.h @@ -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 */ diff --git a/src/content_cao.h b/src/content_cao.h index d6d5deac8..dc254ad5b 100644 --- a/src/content_cao.h +++ b/src/content_cao.h @@ -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; diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 5ba4f1ad1..674ab580c 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -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; } diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 0ab252a9d..f04be07d6 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -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 diff --git a/src/network/networkprotocol.h b/src/network/networkprotocol.h index c85887802..c90e9456a 100644 --- a/src/network/networkprotocol.h +++ b/src/network/networkprotocol.h @@ -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 |