From d243af2234dda3d6f63083be998b981cdd68632f Mon Sep 17 00:00:00 2001 From: Sin! Date: Fri, 4 Aug 2017 02:51:09 +1000 Subject: [PATCH] [Bugfix] quick changing of target slot restarts animation of hiding Take weapon from automatic slot into hands. Press key to change slot to pistol's one. Then change slot to knife's one without waiting for changing completed. Hiding animation will be restarted. You can never change slot while you repeats such actions. --- src/xrGame/Artefact.cpp | 6 +++++- src/xrGame/CustomDetector.cpp | 10 +++++++--- src/xrGame/Grenade.cpp | 4 ++-- src/xrGame/Grenade.h | 2 +- src/xrGame/Missile.cpp | 14 +++++++++----- src/xrGame/Missile.h | 2 +- src/xrGame/WeaponKnife.cpp | 8 +++++++- src/xrGame/WeaponMagazined.cpp | 4 +++- 8 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/xrGame/Artefact.cpp b/src/xrGame/Artefact.cpp index b746c87c830..b2d27663228 100644 --- a/src/xrGame/Artefact.cpp +++ b/src/xrGame/Artefact.cpp @@ -412,13 +412,17 @@ bool CArtefact::Action(u16 cmd, u32 flags) void CArtefact::OnStateSwitch(u32 S) { + u32 oldState = GetState(); inherited::OnStateSwitch(S); switch (S) { case eShowing: { PlayHUDMotion("anm_show", FALSE, this, S); } break; - case eHiding: { PlayHUDMotion("anm_hide", FALSE, this, S); + case eHiding: + { + if (oldState != eHiding) + PlayHUDMotion("anm_hide", FALSE, this, S); } break; case eActivating: { PlayHUDMotion("anm_activate", FALSE, this, S); diff --git a/src/xrGame/CustomDetector.cpp b/src/xrGame/CustomDetector.cpp index 93ad945e5c5..3b13f59b0b1 100644 --- a/src/xrGame/CustomDetector.cpp +++ b/src/xrGame/CustomDetector.cpp @@ -119,6 +119,7 @@ void CCustomDetector::ToggleDetector(bool bFastMode) void CCustomDetector::OnStateSwitch(u32 S) { + u32 oldState = GetState(); inherited::OnStateSwitch(S); switch (S) @@ -133,9 +134,12 @@ void CCustomDetector::OnStateSwitch(u32 S) break; case eHiding: { - m_sounds.PlaySound("sndHide", Fvector().set(0, 0, 0), this, true, false); - PlayHUDMotion(m_bFastAnimMode ? "anm_hide_fast" : "anm_hide", FALSE /*TRUE*/, this, GetState()); - SetPending(TRUE); + if (oldState != eHiding) + { + m_sounds.PlaySound("sndHide", Fvector().set(0, 0, 0), this, true, false); + PlayHUDMotion(m_bFastAnimMode ? "anm_hide_fast" : "anm_hide", FALSE/*TRUE*/, this, GetState()); + SetPending(TRUE); + } } break; case eIdle: diff --git a/src/xrGame/Grenade.cpp b/src/xrGame/Grenade.cpp index 69c3cec47c3..54378380355 100644 --- a/src/xrGame/Grenade.cpp +++ b/src/xrGame/Grenade.cpp @@ -89,7 +89,7 @@ void CGrenade::OnH_A_Chield() inherited::OnH_A_Chield(); } -void CGrenade::State(u32 state) +void CGrenade::State(u32 state, u32 old_state) { switch (state) { @@ -120,7 +120,7 @@ void CGrenade::State(u32 state) } break; }; - inherited::State(state); + inherited::State(state, old_state); } bool CGrenade::DropGrenade() diff --git a/src/xrGame/Grenade.h b/src/xrGame/Grenade.h index 41ef58524ad..7b2bc15609d 100644 --- a/src/xrGame/Grenade.h +++ b/src/xrGame/Grenade.h @@ -33,7 +33,7 @@ class CGrenade : public CMissile, public CExplosive virtual bool Action(u16 cmd, u32 flags); virtual bool Useful() const; - virtual void State(u32 state); + virtual void State(u32 state, u32 old_state); virtual void OnH_B_Chield() { inherited::OnH_B_Chield(); } virtual void Hit(SHit* pHDS); diff --git a/src/xrGame/Missile.cpp b/src/xrGame/Missile.cpp index db4515363be..d2b82513566 100644 --- a/src/xrGame/Missile.cpp +++ b/src/xrGame/Missile.cpp @@ -239,9 +239,9 @@ void CMissile::shedule_Update(u32 dt) } } -void CMissile::State(u32 state) +void CMissile::State(u32 state, u32 old_state) { - switch (GetState()) + switch (state) { case eShowing: { @@ -259,8 +259,11 @@ void CMissile::State(u32 state) { if (H_Parent()) { - SetPending(TRUE); - PlayHUDMotion("anm_hide", TRUE, this, GetState()); + if (old_state != eHiding) + { + SetPending(TRUE); + PlayHUDMotion("anm_hide", TRUE, this, GetState()); + } } } break; @@ -311,8 +314,9 @@ void CMissile::State(u32 state) void CMissile::OnStateSwitch(u32 S) { m_dwStateTime = 0; + u32 oldState = GetState(); inherited::OnStateSwitch(S); - State(S); + State(S, oldState); } void CMissile::OnAnimationEnd(u32 state) diff --git a/src/xrGame/Missile.h b/src/xrGame/Missile.h index e40aa99429e..29dd9ea2925 100644 --- a/src/xrGame/Missile.h +++ b/src/xrGame/Missile.h @@ -45,7 +45,7 @@ class CMissile : public CHudItemObject virtual bool Action(u16 cmd, u32 flags); - virtual void State(u32 state); + virtual void State(u32 state, u32 old_state); virtual void OnStateSwitch(u32 S); virtual bool GetBriefInfo(II_BriefInfo& info); diff --git a/src/xrGame/WeaponKnife.cpp b/src/xrGame/WeaponKnife.cpp index 760adcbce9d..d3501e2061e 100644 --- a/src/xrGame/WeaponKnife.cpp +++ b/src/xrGame/WeaponKnife.cpp @@ -70,12 +70,18 @@ void CWeaponKnife::Load(LPCSTR section) void CWeaponKnife::OnStateSwitch(u32 S) { + u32 old_state = GetState(); inherited::OnStateSwitch(S); switch (S) { case eIdle: switch2_Idle(); break; case eShowing: switch2_Showing(); break; - case eHiding: switch2_Hiding(); break; + case eHiding: + { + if (old_state != eHiding) + switch2_Hiding(); + break; + } case eHidden: switch2_Hidden(); break; case eFire: { diff --git a/src/xrGame/WeaponMagazined.cpp b/src/xrGame/WeaponMagazined.cpp index 5cb71045eab..3971fe88d14 100644 --- a/src/xrGame/WeaponMagazined.cpp +++ b/src/xrGame/WeaponMagazined.cpp @@ -382,6 +382,7 @@ void CWeaponMagazined::ReloadMagazine() void CWeaponMagazined::OnStateSwitch(u32 S) { + u32 old_state = GetState(); inherited::OnStateSwitch(S); CInventoryOwner* owner = smart_cast(this->H_Parent()); switch (S) @@ -406,7 +407,8 @@ void CWeaponMagazined::OnStateSwitch(u32 S) case eHiding: if (owner) m_sounds_enabled = owner->CanPlayShHdRldSounds(); - switch2_Hiding(); + if (old_state != eHiding) + switch2_Hiding(); break; case eHidden: switch2_Hidden(); break; }