diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/content_cao.cpp | 6 | ||||
-rw-r--r-- | src/content_sao.cpp | 10 | ||||
-rw-r--r-- | src/content_sao.h | 2 | ||||
-rw-r--r-- | src/genericobject.cpp | 6 | ||||
-rw-r--r-- | src/genericobject.h | 3 | ||||
-rw-r--r-- | src/localplayer.cpp | 12 | ||||
-rw-r--r-- | src/player.cpp | 8 | ||||
-rw-r--r-- | src/player.h | 2 | ||||
-rw-r--r-- | src/script/lua_api/l_object.cpp | 11 | ||||
-rw-r--r-- | src/script/lua_api/l_object.h | 3 |
10 files changed, 51 insertions, 12 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp index e97e3a1be..ec8cde35b 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -1693,12 +1693,18 @@ public: float override_speed = readF1000(is); float override_jump = readF1000(is); float override_gravity = readF1000(is); + // these are sent inverted so we get true when the server sends nothing + bool sneak = !readU8(is); + bool sneak_glitch = !readU8(is); + if(m_is_local_player) { LocalPlayer *player = m_env->getLocalPlayer(); player->physics_override_speed = override_speed; player->physics_override_jump = override_jump; player->physics_override_gravity = override_gravity; + player->physics_override_sneak = sneak; + player->physics_override_sneak_glitch = sneak_glitch; } } else if(cmd == GENERIC_CMD_SET_ANIMATION) diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 85ab8d307..52b741365 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -969,6 +969,8 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_, m_physics_override_speed(1), m_physics_override_jump(1), m_physics_override_gravity(1), + m_physics_override_sneak(true), + m_physics_override_sneak_glitch(true), m_physics_override_sent(false) { assert(m_player); @@ -1060,7 +1062,9 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version) os<<serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size } os<<serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id, m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4 - os<<serializeLongString(gob_cmd_update_physics_override(m_physics_override_speed, m_physics_override_jump, m_physics_override_gravity)); // 5 + os<<serializeLongString(gob_cmd_update_physics_override(m_physics_override_speed, + m_physics_override_jump, m_physics_override_gravity, m_physics_override_sneak, + m_physics_override_sneak_glitch)); // 5 } else { @@ -1187,7 +1191,9 @@ void PlayerSAO::step(float dtime, bool send_recommended) if(m_physics_override_sent == false){ m_physics_override_sent = true; - std::string str = gob_cmd_update_physics_override(m_physics_override_speed, m_physics_override_jump, m_physics_override_gravity); + std::string str = gob_cmd_update_physics_override(m_physics_override_speed, + m_physics_override_jump, m_physics_override_gravity, + m_physics_override_sneak, m_physics_override_sneak_glitch); // create message and add to list ActiveObjectMessage aom(getId(), true, str); m_messages_out.push_back(aom); diff --git a/src/content_sao.h b/src/content_sao.h index 6b97cb148..1be620f29 100644 --- a/src/content_sao.h +++ b/src/content_sao.h @@ -330,6 +330,8 @@ public: float m_physics_override_speed; float m_physics_override_jump; float m_physics_override_gravity; + bool m_physics_override_sneak; + bool m_physics_override_sneak_glitch; bool m_physics_override_sent; }; diff --git a/src/genericobject.cpp b/src/genericobject.cpp index e2fbde838..9a1b9d8d0 100644 --- a/src/genericobject.cpp +++ b/src/genericobject.cpp @@ -117,7 +117,8 @@ std::string gob_cmd_update_armor_groups(const ItemGroupList &armor_groups) return os.str(); } -std::string gob_cmd_update_physics_override(float physics_override_speed, float physics_override_jump, float physics_override_gravity) +std::string gob_cmd_update_physics_override(float physics_override_speed, float physics_override_jump, + float physics_override_gravity, bool sneak, bool sneak_glitch) { std::ostringstream os(std::ios::binary); // command @@ -126,6 +127,9 @@ std::string gob_cmd_update_physics_override(float physics_override_speed, float writeF1000(os, physics_override_speed); writeF1000(os, physics_override_jump); writeF1000(os, physics_override_gravity); + // these are sent inverted so we get true when the server sends nothing + writeU8(os, !sneak); + writeU8(os, !sneak_glitch); return os.str(); } diff --git a/src/genericobject.h b/src/genericobject.h index 276865ab9..29e5e29cb 100644 --- a/src/genericobject.h +++ b/src/genericobject.h @@ -63,7 +63,8 @@ std::string gob_cmd_punched(s16 damage, s16 result_hp); #include "itemgroup.h" std::string gob_cmd_update_armor_groups(const ItemGroupList &armor_groups); -std::string gob_cmd_update_physics_override(float physics_override_speed, float physics_override_jump, float physics_override_gravity); +std::string gob_cmd_update_physics_override(float physics_override_speed, + float physics_override_jump, float physics_override_gravity, bool sneak, bool sneak_glitch); std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_blend); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 48e6592c1..a6f04849a 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -165,7 +165,9 @@ void LocalPlayer::move(f32 dtime, ClientEnvironment *env, f32 pos_max_d, If sneaking, keep in range from the last walked node and don't fall off from it */ - if(control.sneak && m_sneak_node_exists && !(fly_allowed && g_settings->getBool("free_move")) && !in_liquid) + if(control.sneak && m_sneak_node_exists && + !(fly_allowed && g_settings->getBool("free_move")) && !in_liquid && + physics_override_sneak) { f32 maxd = 0.5*BS + sneak_max; v3f lwn_f = intToFloat(m_sneak_node, BS); @@ -225,7 +227,7 @@ void LocalPlayer::move(f32 dtime, ClientEnvironment *env, f32 pos_max_d, // node. m_need_to_get_new_sneak_node = true; } - if(m_need_to_get_new_sneak_node) + if(m_need_to_get_new_sneak_node && physics_override_sneak) { v3s16 pos_i_bottom = floatToInt(position - v3f(0,BS/2,0), BS); v2f player_p2df(position.X, position.Z); @@ -264,6 +266,10 @@ void LocalPlayer::move(f32 dtime, ClientEnvironment *env, f32 pos_max_d, // And the node above it has to be nonwalkable if(nodemgr->get(map->getNode(p+v3s16(0,1,0))).walkable == true) continue; + if (!physics_override_sneak_glitch) { + if (nodemgr->get(map->getNode(p+v3s16(0,2,0))).walkable) + continue; + } } catch(InvalidPositionException &e) { @@ -576,6 +582,6 @@ v3s16 LocalPlayer::getStandingNodePos() { if(m_sneak_node_exists) return m_sneak_node; - return floatToInt(getPosition(), BS); + return floatToInt(getPosition() - v3f(0, BS, 0), BS); } diff --git a/src/player.cpp b/src/player.cpp index 584c00dd0..3481260c0 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -85,9 +85,11 @@ Player::Player(IGameDef *gamedef): movement_gravity = 9.81 * BS; // Movement overrides are multipliers and must be 1 by default - physics_override_speed = 1; - physics_override_jump = 1; - physics_override_gravity = 1; + physics_override_speed = 1; + physics_override_jump = 1; + physics_override_gravity = 1; + physics_override_sneak = true; + physics_override_sneak_glitch = true; hud_flags = HUD_FLAG_HOTBAR_VISIBLE | HUD_FLAG_HEALTHBAR_VISIBLE | HUD_FLAG_CROSSHAIR_VISIBLE | HUD_FLAG_WIELDITEM_VISIBLE | diff --git a/src/player.h b/src/player.h index 12ea0dba1..a1050d4c7 100644 --- a/src/player.h +++ b/src/player.h @@ -266,6 +266,8 @@ public: float physics_override_speed; float physics_override_jump; float physics_override_gravity; + bool physics_override_sneak; + bool physics_override_sneak_glitch; u16 hp; diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index cbcaa40eb..5e1517e46 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -349,7 +349,8 @@ int ObjectRef::l_set_armor_groups(lua_State *L) return 0; } -// set_physics_override(self, physics_override_speed, physics_override_jump, physics_override_gravity) +// set_physics_override(self, physics_override_speed, physics_override_jump, +// physics_override_gravity, sneak, sneak_glitch) int ObjectRef::l_set_physics_override(lua_State *L) { ObjectRef *ref = checkobject(L, 1); @@ -368,6 +369,14 @@ int ObjectRef::l_set_physics_override(lua_State *L) co->m_physics_override_gravity = lua_tonumber(L, 4); co->m_physics_override_sent = false; } + if (lua_isboolean(L, 5)) { + co->m_physics_override_sneak = lua_toboolean(L, 5); + co->m_physics_override_sent = false; + } + if (lua_isboolean(L, 6)) { + co->m_physics_override_sneak_glitch = lua_toboolean(L, 6); + co->m_physics_override_sent = false; + } return 0; } diff --git a/src/script/lua_api/l_object.h b/src/script/lua_api/l_object.h index 4b4f5eff7..c8c67f2c5 100644 --- a/src/script/lua_api/l_object.h +++ b/src/script/lua_api/l_object.h @@ -101,7 +101,8 @@ private: // set_armor_groups(self, groups) static int l_set_armor_groups(lua_State *L); - // set_physics_override(self, physics_override_speed, physics_override_jump, physics_override_gravity) + // set_physics_override(self, physics_override_speed, physics_override_jump, + // physics_override_gravity, sneak, sneak_glitch) static int l_set_physics_override(lua_State *L); // set_animation(self, frame_range, frame_speed, frame_blend) |