#4370 Fix change in crouch behaviour

A motion wasn't reset and requires an extra 'push' from viewer.
master
Andrey Kleshchev 2025-07-18 19:12:46 +03:00 committed by Andrey Kleshchev
parent 590ad6747f
commit 8efc4744de
1 changed files with 16 additions and 0 deletions

View File

@ -3189,6 +3189,7 @@ void send_agent_update(bool force_send, bool send_reliable)
static F64 last_send_time = 0.0;
static U32 last_control_flags = 0;
static bool control_flags_follow_up = false;
static U8 last_render_state = 0;
static U8 last_flags = AU_FLAGS_NONE;
static LLQuaternion last_body_rot,
@ -3266,6 +3267,20 @@ void send_agent_update(bool force_send, bool send_reliable)
break;
}
// example:
// user taps crouch (control_flags 4128), viewer sends 4128 then immediately 0
// server starts crouching motion but does not stop it, only once viewer sends 0
// second time will server stop the motion. follow_up exists to make sure all
// states like 'crouch' motion are properly cleared server side.
//
// P.S. Server probably shouldn't require a reminder to stop a motion,
// but at the moment it does.
if (control_flags_follow_up)
{
send_update = true;
break;
}
// check translation
constexpr F32 TRANSLATE_THRESHOLD = 0.01f;
if ((last_camera_pos_agent - camera_pos_agent).magVec() > TRANSLATE_THRESHOLD)
@ -3399,6 +3414,7 @@ void send_agent_update(bool force_send, bool send_reliable)
// remember last update data
last_send_time = now;
control_flags_follow_up = last_control_flags != control_flags;
last_control_flags = control_flags;
last_render_state = render_state;
last_flags = flags;