First Person Fix: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
This fix is taken from the HL Coders mail list.
The following fix is for angles on first person spectating not updating, especially when you have followed the [http://articles.thewavelength.net/702/ spectator-tutorial at Wavelength].


The original text was writen by "Ben Everett" {{e|obike@thecodevault.net}}
This fix was taken from the HL Coders mail list.


----
The original text was writen by Ben "[[User:Obike|Obike]]" Everett {{e|obike@obike.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 9:
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
CNetworkQAngle(v_angle);


Step 2: In player.cpp around line 6484 add in after sending the dead flag:
P.S. The cause of this is in baseplayer_shared when calling EyeAngles.
SendPropQAngles (SENDINFO(v_angle), 13),
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 3: In c_baseplayer.cpp around line 85 add in after receiving the dead flag:
'''Step 4'''
RecvPropQAngles (RECVINFO(v_angle)),
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 4: You must make all calls to v_angle safe. In baseplayer_shared.cpp around line 211 add in:
Around line 216 change AngleMatrix to use
if (!pMoveParent)
pl.v_angle.Get()
{
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  
Around line 227 change the return value of LocalEyeAngles to pl.v_angle.Get().
pl.v_angle.Get()


Step 5: In prediction.cpp around line 1700 in GetLocalViewAngles change the else portion to:
'''Step 5'''
else
In prediction.cpp around line 1700 in GetLocalViewAngles change the else portion to:
{
else
ang = player->pl.v_angle.Get();
{
}
    ang = player->pl.v_angle.Get();
}


Step 6: In c_baseplayer.cpp around line 437 in the function SetLocalViewAngles change that to:
'''Step 6'''
pl.v_angle.GetForModify() = viewAngles;
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;
'''Step 7'''
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 );
In player.cpp around line 598 in SnapEyeAngles change  
Around line 3052 in PlayerRunCommand change VectorCopy ( ucmd->viewangles, pl.v_angle ); to VectorCopy ( ucmd->viewangles, (QAngle)pl.v_angle.Get() );
pl.v_angle = viewAngles;  
Around line 3056 in the same function change VectorCopy ( pl.v_angle, ucmd->viewangles ); to VectorCopy ( pl.v_angle.GetForModify(), ucmd->viewangles );
to  
Around line 4427 in the function Restore change QAngle newViewAngles = pl.v_angle; to QAngle newViewAngles = pl.v_angle.Get();
pl.v_angle.GetForModify() = viewAngles;


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 2914 in the function PhysicsSimulate 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 ( pl.v_angle, ctx->cmds[ i ].viewangles );  
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 ( 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;


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]]

Latest revision as of 19:36, 14 August 2013

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;