Skip to content

Commit

Permalink
[Bugfix] quick changing of target slot restarts animation of hiding
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gunslingermod authored and Xottab-DUTY committed Aug 14, 2017
1 parent 8fb4797 commit d243af2
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 15 deletions.
6 changes: 5 additions & 1 deletion src/xrGame/Artefact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 7 additions & 3 deletions src/xrGame/CustomDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ void CCustomDetector::ToggleDetector(bool bFastMode)

void CCustomDetector::OnStateSwitch(u32 S)
{
u32 oldState = GetState();
inherited::OnStateSwitch(S);

switch (S)
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/Grenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -120,7 +120,7 @@ void CGrenade::State(u32 state)
}
break;
};
inherited::State(state);
inherited::State(state, old_state);
}

bool CGrenade::DropGrenade()
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Grenade.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 9 additions & 5 deletions src/xrGame/Missile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
{
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Missile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 7 additions & 1 deletion src/xrGame/WeaponKnife.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
{
Expand Down
4 changes: 3 additions & 1 deletion src/xrGame/WeaponMagazined.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ void CWeaponMagazined::ReloadMagazine()

void CWeaponMagazined::OnStateSwitch(u32 S)
{
u32 old_state = GetState();
inherited::OnStateSwitch(S);
CInventoryOwner* owner = smart_cast<CInventoryOwner*>(this->H_Parent());
switch (S)
Expand All @@ -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;
}
Expand Down

0 comments on commit d243af2

Please sign in to comment.