From 40105998d414e9322540b52ed323196dc8deab78 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Thu, 17 Aug 2017 03:08:55 +0500 Subject: [PATCH] Optimize if checks in CWeapon::OnStateSwitch() --- src/xrGame/Weapon.cpp | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/xrGame/Weapon.cpp b/src/xrGame/Weapon.cpp index 47f9d4f3123..df8f378a026 100644 --- a/src/xrGame/Weapon.cpp +++ b/src/xrGame/Weapon.cpp @@ -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(H_Parent()); - if (current_actor) + CActor* current_actor = smart_cast(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(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)); - } - } } }