First Person Fix: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
(Reformatted code section)
Line 2: Line 2:


The original text was writen by "Ben Everett" {{e|obike@thecodevault.net}}
The original text was writen by "Ben Everett" {{e|obike@thecodevault.net}}
----


<pre>Hah, thanks for giving me a reason to hunt this one down.
<pre>Hah, thanks for giving me a reason to hunt this one down.
Line 9: Line 7:
anyways... here you go. A fix.
anyways... here you go. A fix.


Step 1: In PlayerState.h around line 34 change:
Enjoy!
QAngle v_angle;
 
To
P.S. The cause of this is in baseplayer_shared when calling EyeAngles.
CNetworkQAngle(v_angle);
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.</pre>
----
'''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 2: In player.cpp around line 6484 add in after sending the dead flag:
'''Step 4'''
SendPropQAngles (SENDINFO(v_angle), 13),
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();
}


Step 3: In c_baseplayer.cpp around line 85 add in after receiving the dead flag:
Around line 216 change AngleMatrix to use
RecvPropQAngles (RECVINFO(v_angle)),
pl.v_angle.Get().


Step 4: You must make all calls to v_angle safe. In baseplayer_shared.cpp around line 211 add in:
Around line 227 change the return value of LocalEyeAngles to  
if (!pMoveParent)
pl.v_angle.Get().
{
return pl.v_angle.Get();
}


Around line 216 change AngleMatrix to use pl.v_angle.Get().
'''Step 5'''
Around line 227 change the return value of LocalEyeAngles to pl.v_angle.Get().
In prediction.cpp around line 1700 in GetLocalViewAngles change the else portion to:
else
{
    ang = player->pl.v_angle.Get();
}


Step 5: In prediction.cpp around line 1700 in GetLocalViewAngles change the else portion to:
'''Step 6'''
else
In c_baseplayer.cpp around line 437 in the function SetLocalViewAngles change that to:
{
pl.v_angle.GetForModify() = viewAngles;
ang = player->pl.v_angle.Get();
}


Step 6: In c_baseplayer.cpp around line 437 in the function SetLocalViewAngles change that to:
'''Step 7'''
pl.v_angle.GetForModify() = viewAngles;
In player.cpp around line 598 in SnapEyeAngles change  
pl.v_angle = viewAngles;
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  
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 );
VectorCopy ( pl.v_angle, 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() );
to  
Around line 3056 in the same function change VectorCopy ( pl.v_angle, ucmd->viewangles ); to VectorCopy ( pl.v_angle.GetForModify(), ucmd->viewangles );
VectorCopy ( pl.v_angle.GetForModify(), ctx->cmds[ i ].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 3052 in PlayerRunCommand change  
Around line 362 in RunCommand change g_pMoveData->m_vecOldAngles = player->pl.v_angle; to g_pMoveData->m_vecOldAngles = player->pl.v_angle.Get();
VectorCopy ( ucmd->viewangles, pl.v_angle );  
Around line 367 in RunCommand change player->pl.v_angle = ucmd->viewangles; to player->pl.v_angle.GetForModify() = ucmd->viewangles;
to  
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;
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;


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.</pre>
[[Category:Programming]]
[[Category:Programming]]

Revision as of 13:34, 14 February 2006

This fix is taken from the HL Coders mail list.

The original text was writen by "Ben Everett" obike@thecodevault.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;