First Person Fix

From Valve Developer Community
Jump to: navigation, search

The following fix is for angles on first person spectating not updating, especially when you have followed the spectator-tutorial at Wavelength.

This fix was taken from the HL Coders mail list.

The original text was writen by Ben "Obike" Everett obike@obike.net

Hah, thanks for giving me a reason to hunt this one down.
The Forsaken testers have been after me a while to fix it...
anyways... here you go. A fix.

Enjoy!

P.S. The cause of this is in baseplayer_shared when calling EyeAngles.
It returns pl.v_angle which is initialized to a zero-vector.
By enabling it to be sent over the network this resolves the issue.

Step 1 In PlayerState.h around line 34 change:

QAngle v_angle;

to

CNetworkQAngle(v_angle);

Step 2 In player.cpp around line 6484 add in after sending the dead flag:

SendPropQAngles (SENDINFO(v_angle), 13),

Step 3 In c_baseplayer.cpp around line 85 add in after receiving the dead flag:

RecvPropQAngles (RECVINFO(v_angle)),

Step 4 You must make all calls to v_angle safe. In baseplayer_shared.cpp around line 211 add in:

if (!pMoveParent)
{
    return pl.v_angle.Get();
}

Around line 216 change AngleMatrix to use

pl.v_angle.Get()

Around line 227 change the return value of LocalEyeAngles to

pl.v_angle.Get()

Step 5 In prediction.cpp around line 1700 in GetLocalViewAngles change the else portion to:

else
{
    ang = player->pl.v_angle.Get();
}

Step 6 In c_baseplayer.cpp around line 437 in the function SetLocalViewAngles change that to:

pl.v_angle.GetForModify() = viewAngles;

Step 7 In player.cpp around line 598 in SnapEyeAngles change

pl.v_angle = viewAngles; 

to

pl.v_angle.GetForModify() = viewAngles;

Around line 2914 in the function PhysicsSimulate change

VectorCopy ( pl.v_angle, ctx->cmds[ i ].viewangles ); 

to

VectorCopy ( pl.v_angle.GetForModify(), ctx->cmds[ i ].viewangles );

Around line 3052 in PlayerRunCommand change

VectorCopy ( ucmd->viewangles, pl.v_angle ); 

to

VectorCopy ( ucmd->viewangles, (QAngle)pl.v_angle.Get() );

Around line 3056 in the same function change

VectorCopy ( pl.v_angle, ucmd->viewangles ); 

to

VectorCopy ( pl.v_angle.GetForModify(), ucmd->viewangles );

Around line 4427 in the function Restore change

QAngle newViewAngles = pl.v_angle; 

to

QAngle newViewAngles = pl.v_angle.Get();

Step 8 In player_command.cpp around line 177 in SetupMove change

move->m_vecAngles = player->pl.v_angle; 

to

move->m_vecAngles = player->pl.v_angle.Get();

Around line 362 in RunCommand change

g_pMoveData->m_vecOldAngles = player->pl.v_angle; 

to

g_pMoveData->m_vecOldAngles = player->pl.v_angle.Get();

Around line 367 in RunCommand change

player->pl.v_angle = ucmd->viewangles; 

to

player->pl.v_angle.GetForModify() = ucmd->viewangles;

Around line 371 in RunCommand change

player->pl.v_angle = ucmd->viewangles + player->pl.anglechange; 

to

player->pl.v_angle.GetForModify() = ucmd->viewangles + player->pl.anglechange;