Skip to content
Permalink
Browse files

Sneak: Add option for old move code

Temporary option for the old move code for specific old sneak behaviour.
Enabled by setting the added 'new move' physics override to false.
By default 'new move' is true.
  • Loading branch information
paramat committed Apr 5, 2017
1 parent 907be0a commit f6da7b3fda5bbb793c7795a228ea6f2602b93fbe
@@ -3021,7 +3021,11 @@ This is basically a reference to a C++ `ServerActiveObject`
* `jump`: multiplier to default jump value (default: `1`)
* `gravity`: multiplier to default gravity value (default: `1`)
* `sneak`: whether player can sneak (default: `true`)
* `sneak_glitch`: whether player can use the sneak glitch (default: `true`)
* `sneak_glitch`: whether player can use the new move code replications
of the old sneak side-effects: sneak ladders and 2 node sneak jump
when next to a ledge 2 nodes up (default: `true`)
* `new_move`: use new move/sneak code. When `false` the exact old code
is used for the specific old sneak behaviour (default: `true`)
* `get_physics_override()`: returns the table given to set_physics_override
* `hud_add(hud definition)`: add a HUD element described by HUD def, returns ID
number on success
@@ -1652,6 +1652,7 @@ void GenericCAO::processMessage(const std::string &data)
// these are sent inverted so we get true when the server sends nothing
bool sneak = !readU8(is);
bool sneak_glitch = !readU8(is);
bool new_move = !readU8(is);


if(m_is_local_player)
@@ -1662,6 +1663,7 @@ void GenericCAO::processMessage(const std::string &data)
player->physics_override_gravity = override_gravity;
player->physics_override_sneak = sneak;
player->physics_override_sneak_glitch = sneak_glitch;
player->physics_override_new_move = new_move;
}
} else if (cmd == GENERIC_CMD_SET_ANIMATION) {
// TODO: change frames send as v2s32 value
@@ -789,6 +789,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, u16 peer_id_, bool is_singleplayer
m_physics_override_gravity(1),
m_physics_override_sneak(true),
m_physics_override_sneak_glitch(true),
m_physics_override_new_move(true),
m_physics_override_sent(false)
{
assert(m_peer_id != 0); // pre-condition
@@ -886,7 +887,7 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4
msg_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
m_physics_override_sneak_glitch, m_physics_override_new_move)); // 5
// (GENERIC_CMD_UPDATE_NAMETAG_ATTRIBUTES) : Deprecated, for backwards compatibility only.
msg_os << serializeLongString(gob_cmd_update_nametag_attributes(m_prop.nametag_color)); // 6
int message_count = 6 + m_bone_position.size();
@@ -1049,7 +1050,8 @@ void PlayerSAO::step(float dtime, bool send_recommended)
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,
m_physics_override_sneak, m_physics_override_sneak_glitch);
m_physics_override_sneak, m_physics_override_sneak_glitch,
m_physics_override_new_move);
// create message and add to list
ActiveObjectMessage aom(getId(), true, str);
m_messages_out.push(aom);
@@ -397,6 +397,7 @@ class PlayerSAO : public UnitSAO
float m_physics_override_gravity;
bool m_physics_override_sneak;
bool m_physics_override_sneak_glitch;
bool m_physics_override_new_move;
bool m_physics_override_sent;
};

@@ -118,7 +118,7 @@ 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, bool sneak, bool sneak_glitch)
float physics_override_gravity, bool sneak, bool sneak_glitch, bool new_move)
{
std::ostringstream os(std::ios::binary);
// command
@@ -130,6 +130,7 @@ std::string gob_cmd_update_physics_override(float physics_override_speed, float
// these are sent inverted so we get true when the server sends nothing
writeU8(os, !sneak);
writeU8(os, !sneak_glitch);
writeU8(os, !new_move);
return os.str();
}

@@ -68,7 +68,8 @@ std::string gob_cmd_punched(s16 damage, s16 result_hp);
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, bool sneak, bool sneak_glitch);
float physics_override_jump, float physics_override_gravity,
bool sneak, bool sneak_glitch, bool new_move);

std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_blend, bool frame_loop);

0 comments on commit f6da7b3

Please sign in to comment.
You can’t perform that action at this time.