summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/cl_parse.c2
-rw-r--r--source/q_msg.c41
2 files changed, 34 insertions, 9 deletions
diff --git a/source/cl_parse.c b/source/cl_parse.c
index 4f3d16c..abf1257 100644
--- a/source/cl_parse.c
+++ b/source/cl_parse.c
@@ -854,6 +854,7 @@ static void CL_ParseServerData( void ) {
if( !R1Q2_SUPPORTED( i ) ) {
Com_Error( ERR_DROP, "Unsupported R1Q2 protocol version %d.\n", i );
}
+ cls.protocolVersion = i;
i = MSG_ReadByte();
if( i ) { // seems to be no longer used
Com_DPrintf( "R1Q2 advancedDeltas enabled\n" );
@@ -868,6 +869,7 @@ static void CL_ParseServerData( void ) {
if( !Q2PRO_SUPPORTED( i ) ) {
Com_Error( ERR_DROP, "Unsupported Q2PRO protocol version %d.\n", i );
}
+ cls.protocolVersion = i;
cl.gametype = MSG_ReadByte();
cl.pmp.strafeHack = MSG_ReadByte();
cl.pmp.qwmod = MSG_ReadByte(); //atu QWMod
diff --git a/source/q_msg.c b/source/q_msg.c
index cddd8ce..d23079a 100644
--- a/source/q_msg.c
+++ b/source/q_msg.c
@@ -219,7 +219,7 @@ MSG_WriteDeltaUsercmd
=============
*/
int MSG_WriteDeltaUsercmd( const usercmd_t *from, const usercmd_t *cmd, int version ) {
- int bits;
+ int bits, buttons = cmd->buttons & BUTTON_MASK;
if( !from ) {
from = &nullUserCmd;
@@ -250,8 +250,16 @@ int MSG_WriteDeltaUsercmd( const usercmd_t *from, const usercmd_t *cmd, int vers
if( version >= PROTOCOL_VERSION_R1Q2_UCMD ) {
if( bits & CM_BUTTONS ) {
- // TODO: actually optimize
- MSG_WriteByte( cmd->buttons );
+ if( ( bits & CM_FORWARD ) && !( cmd->forwardmove % 5 ) ) {
+ buttons |= BUTTON_FORWARD;
+ }
+ if( ( bits & CM_SIDE ) && !( cmd->sidemove % 5 ) ) {
+ buttons |= BUTTON_SIDE;
+ }
+ if( ( bits & CM_UP ) && !( cmd->upmove % 5 ) ) {
+ buttons |= BUTTON_UP;
+ }
+ MSG_WriteByte( buttons );
}
}
@@ -262,12 +270,27 @@ int MSG_WriteDeltaUsercmd( const usercmd_t *from, const usercmd_t *cmd, int vers
if( bits & CM_ANGLE3 )
MSG_WriteShort( cmd->angles[2] );
- if( bits & CM_FORWARD )
- MSG_WriteShort( cmd->forwardmove );
- if( bits & CM_SIDE )
- MSG_WriteShort( cmd->sidemove );
- if( bits & CM_UP )
- MSG_WriteShort( cmd->upmove );
+ if( bits & CM_FORWARD ) {
+ if( buttons & BUTTON_FORWARD ) {
+ MSG_WriteChar( cmd->forwardmove / 5 );
+ } else {
+ MSG_WriteShort( cmd->forwardmove );
+ }
+ }
+ if( bits & CM_SIDE ) {
+ if( buttons & BUTTON_SIDE ) {
+ MSG_WriteChar( cmd->sidemove / 5 );
+ } else {
+ MSG_WriteShort( cmd->sidemove );
+ }
+ }
+ if( bits & CM_UP ) {
+ if( buttons & BUTTON_UP ) {
+ MSG_WriteChar( cmd->upmove / 5 );
+ } else {
+ MSG_WriteShort( cmd->upmove );
+ }
+ }
if( version < PROTOCOL_VERSION_R1Q2_UCMD ) {
if( bits & CM_BUTTONS )