Skip to content

Commit

Permalink
Optimize if checks in CWeapon::OnStateSwitch()
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Aug 18, 2017
1 parent 02e4b0f commit 4010599
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions src/xrGame/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1826,26 +1826,16 @@ void CWeapon::OnStateSwitch(u32 S, u32 oldState)
inherited::OnStateSwitch(S, oldState);
m_BriefInfo_CalcFrame = 0;

if (GetState() == eReload)
if (S == eReload)
{
if (iAmmoElapsed == 0)
{
if (H_Parent() == Level().CurrentEntity() && !fsimilar(m_zoom_params.m_ReloadEmptyDof.w, -1.0f))
{
CActor* current_actor = smart_cast<CActor*>(H_Parent());
if (current_actor)
CActor* current_actor = smart_cast<CActor*>(H_Parent());
if (current_actor && H_Parent() == Level().CurrentEntity())
if (iAmmoElapsed == 0)
if (!fsimilar(m_zoom_params.m_ReloadEmptyDof.w, -1.0f))
current_actor->Cameras().AddCamEffector(new CEffectorDOF(m_zoom_params.m_ReloadEmptyDof));
}
}
else
{
if (H_Parent() == Level().CurrentEntity() && !fsimilar(m_zoom_params.m_ReloadDof.w, -1.0f))
{
CActor* current_actor = smart_cast<CActor*>(H_Parent());
if (current_actor)
else
if (!fsimilar(m_zoom_params.m_ReloadDof.w, -1.0f))
current_actor->Cameras().AddCamEffector(new CEffectorDOF(m_zoom_params.m_ReloadDof));
}
}
}
}

Expand Down

0 comments on commit 4010599

Please sign in to comment.