summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorleviathan <leviathan@lindenlab.com>2026-07-31 11:33:34 -0700
committerleviathan <leviathan@lindenlab.com>2026-10-16 13:14:37 -0700
commitb1da22cddb385ef3bf02eb5c94f6dcee9fb5d1d8 (patch)
tree19dcc5a2b4a72e9d152fd9c9b9e1fa60423d10c5
parentce424904be01e5168c5a2633c480e454c4493aaa (diff)
more terse packing for GameControlData message
-rw-r--r--indra/newview/llagent.cpp1
-rw-r--r--indra/newview/llappviewer.cpp40
-rw-r--r--scripts/messages/message_template.msg33
-rw-r--r--scripts/messages/message_template.msg.sha12
4 files changed, 48 insertions, 28 deletions
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index a84f8adab9..e948c8bb64 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -5305,7 +5305,6 @@ void LLAgent::applyExternalActions(const LLGameControl::AgentActions& actions)
void LLAgent::toggleFlycam()
{
mUsingFlycam = !mUsingFlycam;
- LL_INFOS("adebug") << "using_flycam=" << mUsingFlycam << LL_ENDL; // adebug
if (mUsingFlycam)
{
// copy main camera transform to flycam
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index b3331d4b06..88925e6aa8 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1378,27 +1378,45 @@ void sendGameControlData()
msg->addU8Fast(_PREHASH_ActionMode, state.mActionMode);
// Non-modal canonical axes/buttons: pack every available value every message,
- // whether or not it changed since the last one (no per-field diffing).
+ // whether or not it changed since the last one (no per-field diffing). Trailing
+ // zero axes are truncated and the Buttons block is skipped entirely when zero --
+ // the server assumes anything not packed is zero -- to save bytes.
size_t num_axes = state.mAxes.size();
- for (U8 i = 0; i < num_axes; ++i)
+ while (num_axes > 0 && state.mAxes[num_axes - 1] == 0)
+ {
+ --num_axes;
+ }
+ for (size_t i = 0; i < num_axes; ++i)
{
msg->nextBlockFast(_PREHASH_Axes);
msg->addS16Fast(_PREHASH_Value, state.mAxes[i]);
}
- msg->nextBlockFast(_PREHASH_Buttons);
- msg->addU32Fast(_PREHASH_Flags, state.mButtons);
+ if (state.mButtons != 0)
+ {
+ msg->nextBlockFast(_PREHASH_Buttons);
+ msg->addU32Fast(_PREHASH_Flags, state.mButtons);
+ }
- // Modal semantic axes/buttons: same always-pack-everything policy, but the
- // number of axes packed depends on ActionMode -- see message_template.msg's
- // GameControlData doc and LLGameControl::numSemanticAxesForMode().
- U8 num_mode_axes = LLGameControl::numSemanticAxesForMode((LLGameControl::AgentControlMode)state.mActionMode);
- for (U8 i = 0; i < num_mode_axes; ++i)
+ // Modal semantic axes/buttons: same truncation policy, except the number of
+ // axes considered depends on ActionMode -- see message_template.msg's
+ // GameControlData doc and LLGameControl::numSemanticAxesForMode() -- since the
+ // server computes its own expected axis count from the mode and zeros anything
+ // not packed.
+ size_t num_mode_axes = LLGameControl::numSemanticAxesForMode((LLGameControl::AgentControlMode)state.mActionMode);
+ while (num_mode_axes > 0 && state.mSemanticAxes[num_mode_axes - 1] == 0)
+ {
+ --num_mode_axes;
+ }
+ for (size_t i = 0; i < num_mode_axes; ++i)
{
msg->nextBlockFast(_PREHASH_ModeAxes);
msg->addS16Fast(_PREHASH_Value, state.mSemanticAxes[i]);
}
- msg->nextBlockFast(_PREHASH_ModeButtons);
- msg->addU32Fast(_PREHASH_Flags, state.mSemanticButtons);
+ if (state.mSemanticButtons != 0)
+ {
+ msg->nextBlockFast(_PREHASH_ModeButtons);
+ msg->addU32Fast(_PREHASH_Flags, state.mSemanticButtons);
+ }
LLGameControl::updateResendPeriod();
gAgent.sendMessage();
diff --git a/scripts/messages/message_template.msg b/scripts/messages/message_template.msg
index 59077aa43d..e4f2c0844d 100644
--- a/scripts/messages/message_template.msg
+++ b/scripts/messages/message_template.msg
@@ -9298,20 +9298,20 @@ version 2.0
}
}
-// GameControlData
// viewer -> simulator
// GameControlData - data from game controller
+// Carries canonical gamepad state plus mode-dependent semantic interpretation.
+// Replaces the deprecated GameControlInput (High 32).
//
// The Packet field of the AgentData is an increasing sequence number (with overflow
// after 255) for each GameControlData message, used to ignore late arrivals for
-// out-of-order GameControlData messages.
+// out-of-order messages.
//
// The ActionMode field of the AgentData block represents the viewer's game-control
// mode and is used to assign meaning to the semantic data (see below).
//
-// Canonical Axes has up to 6 axes: the server will ignore any axes beyond 6 and if
-// fewer than 6 are packed then the server will assume the unpacked axes haven't changed
-// since last message.
+// Canonical Axes has up to 6 Values: the server will ignore any Values beyond 6 and if
+// fewer than 6 are packed then it will assume unpacked Values are zero.
// 0 AXIS_LEFTX
// 1 AXIS_LEFTY
// 2 AXIS_RIGHTX
@@ -9345,22 +9345,22 @@ version 2.0
// ...
// 31 BUTTON_31
//
-// Semantic data is mostly the same as canonical, but reordered (and combined in the case of the triggers)
-// according to their meaning. The meaning of the semantic axis data depends on the mode. The modes are:
+// Modal data is mostly the same as canonical, but reordered (and combined in the case of the triggers)
+// according to their semantic meanings, which depend on the mode. The possible modes are:
// 0 CONTROL_MODE_AVATAR
// 1 CONTROL_MODE_MOUSELOOK
// 2 CONTROL_MODE_FLYCAM
// 3 CONTROL_MODE_CAPTIVE (sitting)
// 4 CONTROL_MODE_MOUSE (mouse cursor)
//
-// For AVATAR, MOUSELOOK, and CAPTIVE modes the axes are:
+// For AVATAR, MOUSELOOK, and CAPTIVE modes the semantics are:
// 0 AXIS_STRAFE
// 1 AXIS_ADVANCE
// 2 AXIS_TURN
// 3 AXIS_LOOK
// 4 AXIS_RISE
//
-// For FLYCAM the axes are:
+// For FLYCAM the semantics are:
// 0 FLYCAM_AXIS_TRUCK
// 1 FLYCAM_AXIS_DOLLY
// 2 FLYCAM_AXIS_PAN
@@ -9375,10 +9375,9 @@ version 2.0
// 2 AXIS_TURN
// 3 AXIS_LOOK
//
-// Similarly for semantic buttons the meaning of the bits depend on the mode:
-// TODO: document the semantic button bits for the various modes.
-// Carries canonical gamepad state plus mode-dependent semantic interpretation.
-// Replaces the deprecated GameControlInput (High 32).
+// Similarly for semantic ModeButtons the meaning of the Flags depend on the mode:
+// TODO: document the ModeButton Flags for the various modes.
+//
{
GameControlData High 33 NotTrusted Zerocoded
{
@@ -9390,20 +9389,24 @@ version 2.0
}
// non-modal canonical data
{
+ // server will zero unpacked Values
Axes Variable
{ Value S16 }
}
{
- Buttons Single
+ // server will zero unpacked Flags
+ Buttons Variable
{ Flags U32 }
}
// modal semantic data
{
+ // server will zero unpacked Values
ModeAxes Variable
{ Value S16 }
}
{
- ModeButtons Single
+ // server will zero unpacked Flags
+ ModeButtons Variable
{ Flags U32 }
}
}
diff --git a/scripts/messages/message_template.msg.sha1 b/scripts/messages/message_template.msg.sha1
index de81fcb401..4d5fb79fbf 100644
--- a/scripts/messages/message_template.msg.sha1
+++ b/scripts/messages/message_template.msg.sha1
@@ -1 +1 @@
-147b08045d51245c55b1297000c8bd1c8e719e57 \ No newline at end of file
+b34ed9a5337e4429e4d2fd91512f48ca07a3de6e \ No newline at end of file