Skip to content

Commit

Permalink
Restore support for Q2PRO 'extended' gunoffset, gunangles encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
res2k committed Oct 23, 2024
1 parent fdbc841 commit 5b2ff50
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
3 changes: 2 additions & 1 deletion inc/common/msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ typedef enum {
MSG_PS_EXTENSIONS_2 = BIT(7), // enable more protocol extensions
MSG_PS_RERELEASE = BIT(8), // rerelease extensions: floating point coordinates,
// increased stats numbers,
// wider pm_time and pm_flags
// wider pm_time and pm_flags,
// different viewoffset, kick_angles, gunoffset, gunangles encodings
MSG_PS_FORCE = BIT(9), // send even if unchanged (MVD stream only)
MSG_PS_REMOVE = BIT(10), // player is removed (MVD stream only)
} msgPsFlags_t;
Expand Down
24 changes: 20 additions & 4 deletions src/common/msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2600,10 +2600,14 @@ void MSG_ParseDeltaPlayerstate_Enhanced(const player_state_t *from,
}

if (extraflags & EPS_GUNOFFSET) {
if (psflags & MSG_PS_EXTENSIONS) {
if (psflags & MSG_PS_RERELEASE) {
to->gunoffset[0] = MSG_ReadShort() / 512.f;
to->gunoffset[1] = MSG_ReadShort() / 512.f;
to->gunoffset[2] = MSG_ReadShort() / 512.f;
} else if (psflags & MSG_PS_EXTENSIONS) {
to->gunoffset[0] = SHORT2COORD(MSG_ReadShort());
to->gunoffset[1] = SHORT2COORD(MSG_ReadShort());
to->gunoffset[2] = SHORT2COORD(MSG_ReadShort());
} else {
to->gunoffset[0] = MSG_ReadChar() * 0.25f;
to->gunoffset[1] = MSG_ReadChar() * 0.25f;
Expand All @@ -2612,10 +2616,14 @@ void MSG_ParseDeltaPlayerstate_Enhanced(const player_state_t *from,
}

if (extraflags & EPS_GUNANGLES) {
if (psflags & MSG_PS_EXTENSIONS) {
if (psflags & MSG_PS_RERELEASE) {
to->gunangles[0] = MSG_ReadShort() / 4096.f;
to->gunangles[1] = MSG_ReadShort() / 4096.f;
to->gunangles[2] = MSG_ReadShort() / 4096.f;
} else if (psflags & MSG_PS_EXTENSIONS) {
to->gunangles[0] = MSG_ReadAngle16();
to->gunangles[1] = MSG_ReadAngle16();
to->gunangles[2] = MSG_ReadAngle16();
} else {
to->gunangles[0] = MSG_ReadChar() * 0.25f;
to->gunangles[1] = MSG_ReadChar() * 0.25f;
Expand Down Expand Up @@ -2732,10 +2740,14 @@ void MSG_ParseDeltaPlayerstate_Packet(player_state_t *to,
}

if (flags & PPS_GUNOFFSET) {
if (psflags & MSG_PS_EXTENSIONS) {
if (psflags & MSG_PS_RERELEASE) {
to->gunoffset[0] = MSG_ReadShort() / 512.f;
to->gunoffset[1] = MSG_ReadShort() / 512.f;
to->gunoffset[2] = MSG_ReadShort() / 512.f;
} else if (psflags & MSG_PS_EXTENSIONS) {
to->gunoffset[0] = SHORT2COORD(MSG_ReadShort());
to->gunoffset[1] = SHORT2COORD(MSG_ReadShort());
to->gunoffset[2] = SHORT2COORD(MSG_ReadShort());
} else {
to->gunoffset[0] = MSG_ReadChar() * 0.25f;
to->gunoffset[1] = MSG_ReadChar() * 0.25f;
Expand All @@ -2744,10 +2756,14 @@ void MSG_ParseDeltaPlayerstate_Packet(player_state_t *to,
}

if (flags & PPS_GUNANGLES) {
if (psflags & MSG_PS_EXTENSIONS) {
if (psflags & MSG_PS_RERELEASE) {
to->gunangles[0] = MSG_ReadShort() / 4096.f;
to->gunangles[1] = MSG_ReadShort() / 4096.f;
to->gunangles[2] = MSG_ReadShort() / 4096.f;
} else if (psflags & MSG_PS_EXTENSIONS) {
to->gunangles[0] = MSG_ReadAngle16();
to->gunangles[1] = MSG_ReadAngle16();
to->gunangles[2] = MSG_ReadAngle16();
} else {
to->gunangles[0] = MSG_ReadChar() * 0.25f;
to->gunangles[1] = MSG_ReadChar() * 0.25f;
Expand Down

0 comments on commit 5b2ff50

Please sign in to comment.