Skip to content

Commit

Permalink
Don't write viewangles to engine while dead(fix of rotating corpses).…
Browse files Browse the repository at this point in the history
… Don't let any movement during intermission
  • Loading branch information
a1batross committed Jul 28, 2016
1 parent 8912a96 commit a52fda0
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 39 deletions.
83 changes: 51 additions & 32 deletions cl_dll/input_xash3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ float rel_pitch;
#define IMPULSE_DOWN 2
#define IMPULSE_UP 4

bool CL_IsDead();
Vector dead_viewangles(0, 0, 0);

void IN_ToggleButtons( float forwardmove, float sidemove )
{
Expand Down Expand Up @@ -152,9 +154,17 @@ void IN_ClientLookEvent( float relyaw, float relpitch )
void IN_Move( float frametime, usercmd_t *cmd )
{
Vector viewangles;
gEngfuncs.GetViewAngles( viewangles );
bool fLadder = false;
if( cl_laddermode->value !=2 ) fLadder = gEngfuncs.GetLocalPlayer()->curstate.movetype == MOVETYPE_FLY;

if( gHUD.m_iIntermission )
return; // we can't move during intermission

if( cl_laddermode->value != 2 )
{
cl_entity_t *pplayer = gEngfuncs.GetLocalPlayer();
if( pplayer )
fLadder = pplayer->curstate.movetype == MOVETYPE_FLY;
}
//if(ac_forwardmove || ac_sidemove)
//gEngfuncs.Con_Printf("Move: %f %f %f %f\n", ac_forwardmove, ac_sidemove, rel_pitch, rel_yaw);
#if 0
Expand All @@ -163,39 +173,49 @@ void IN_Move( float frametime, usercmd_t *cmd )
V_StopPitchDrift();
}
#endif
if( !gHUD.m_iIntermission )
if( CL_IsDead() )
{
if( gHUD.GetSensitivity() != 0 )
{
rel_yaw *= gHUD.GetSensitivity();
rel_pitch *= gHUD.GetSensitivity();
}
else
{
rel_yaw *= sensitivity->value;
rel_pitch *= sensitivity->value;
}

viewangles[YAW] += rel_yaw;
if( fLadder )
{
if( cl_laddermode->value == 1 )
viewangles[YAW] -= ac_sidemove * 5;
ac_sidemove = 0;
}
if(gHUD.m_MOTD.m_bShow)
gHUD.m_MOTD.scroll += rel_pitch;
else
viewangles = dead_viewangles; // HACKHACK: see below
}
else
{
gEngfuncs.GetViewAngles( viewangles );
}
if( gHUD.GetSensitivity() != 0 )
{
rel_yaw *= gHUD.GetSensitivity();
rel_pitch *= gHUD.GetSensitivity();
}
else
{
rel_yaw *= sensitivity->value;
rel_pitch *= sensitivity->value;
}
viewangles[YAW] += rel_yaw;
if( fLadder )
{
if( cl_laddermode->value == 1 )
viewangles[YAW] -= ac_sidemove * 5;
ac_sidemove = 0;
}
if(gHUD.m_MOTD.m_bShow)
gHUD.m_MOTD.scroll += rel_pitch;
else
viewangles[PITCH] += rel_pitch;
if (viewangles[PITCH] > cl_pitchdown->value)
viewangles[PITCH] = cl_pitchdown->value;
if (viewangles[PITCH] < -cl_pitchup->value)
viewangles[PITCH] = -cl_pitchup->value;

if (viewangles[PITCH] > cl_pitchdown->value)
viewangles[PITCH] = cl_pitchdown->value;
if (viewangles[PITCH] < -cl_pitchup->value)
viewangles[PITCH] = -cl_pitchup->value;

// HACKHACK: change viewangles directly in viewcode,
// so viewangles when player is dead will not be changed on server
if( !CL_IsDead() )
{
gEngfuncs.SetViewAngles( viewangles );
}
float rgfl[3];
viewangles.CopyToArray( rgfl );
gEngfuncs.SetViewAngles( rgfl );

dead_viewangles = viewangles; // keep them actual
if( ac_movecount )
{
IN_ToggleButtons( ac_forwardmove / ac_movecount, ac_sidemove / ac_movecount );
Expand All @@ -206,7 +226,6 @@ void IN_Move( float frametime, usercmd_t *cmd )
cmd->forwardmove *= cl_movespeedkey->value;
cmd->sidemove *= cl_movespeedkey->value;
}

}

ac_sidemove = ac_forwardmove = rel_pitch = rel_yaw = 0;
Expand Down
35 changes: 28 additions & 7 deletions cl_dll/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ extern cvar_t *cl_forwardspeed;
extern cvar_t *chase_active;
extern cvar_t *scr_ofsx, *scr_ofsy, *scr_ofsz;
extern cvar_t *cl_vsmoothing;
extern Vector dead_viewangles;

#define CAM_MODE_RELAX 1
#define CAM_MODE_FOCUS 2
Expand Down Expand Up @@ -434,7 +435,7 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams )
ent = gEngfuncs.GetLocalPlayer();
}

// view is the weapon model (only visible from inside body )
// view is the weapon model (only visible from inside body)
view = gEngfuncs.GetViewModel();

// transform the view offset by the model's matrix to get the offset from
Expand All @@ -446,7 +447,14 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams )
pparams->vieworg[2] += ( bob );
VectorAdd( pparams->vieworg, pparams->viewheight, pparams->vieworg );

VectorCopy ( pparams->cl_viewangles, pparams->viewangles );
if( pparams->health <= 0 )
{
VectorCopy( dead_viewangles, pparams->viewangles );
}
else
{
VectorCopy ( pparams->cl_viewangles, pparams->viewangles );
}

gEngfuncs.V_CalcShake();
gEngfuncs.V_ApplyShake( pparams->vieworg, pparams->viewangles, 1.0 );
Expand Down Expand Up @@ -525,7 +533,14 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams )
V_AddIdle ( pparams );

// offsets
VectorCopy( pparams->cl_viewangles, angles );
if ( pparams->health <= 0 )
{
VectorCopy( dead_viewangles, angles );
}
else
{
VectorCopy( pparams->cl_viewangles, angles );
}

AngleVectors ( angles, pparams->forward, pparams->right, pparams->up );

Expand Down Expand Up @@ -559,8 +574,14 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams )
}

// Give gun our viewangles
VectorCopy ( pparams->cl_viewangles, view->angles );

if ( pparams->health <= 0 )
{
VectorCopy( dead_viewangles, view->angles );
}
else
{
VectorCopy ( pparams->cl_viewangles, view->angles );
}
// set up gun position
V_CalcGunAngle ( pparams );

Expand Down Expand Up @@ -611,7 +632,7 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams )
VectorAdd ( pparams->viewangles, pparams->punchangle, pparams->viewangles );

// Include client side punch, too
VectorAdd ( pparams->viewangles, (float *)&ev_punchangle, pparams->viewangles);
VectorAdd ( pparams->viewangles, (float *)&ev_punchangle, pparams->viewangles );

V_DropPunchAngle ( pparams->frametime, (float *)&ev_punchangle );

Expand All @@ -623,7 +644,7 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams )

steptime = pparams->time - lasttime;
if (steptime < 0)
//FIXME I_Error ("steptime < 0");
//FIXME I_Error ("steptime < 0");
steptime = 0;

oldz += steptime * 150;
Expand Down

0 comments on commit a52fda0

Please sign in to comment.