Skip to content

Commit d243af2

Browse files
gunslingermodXottab-DUTY
authored andcommitted
[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.
1 parent 8fb4797 commit d243af2

File tree

8 files changed

+35
-15
lines changed

8 files changed

+35
-15
lines changed

src/xrGame/Artefact.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,17 @@ bool CArtefact::Action(u16 cmd, u32 flags)
412412

413413
void CArtefact::OnStateSwitch(u32 S)
414414
{
415+
u32 oldState = GetState();
415416
inherited::OnStateSwitch(S);
416417
switch (S)
417418
{
418419
case eShowing: { PlayHUDMotion("anm_show", FALSE, this, S);
419420
}
420421
break;
421-
case eHiding: { PlayHUDMotion("anm_hide", FALSE, this, S);
422+
case eHiding:
423+
{
424+
if (oldState != eHiding)
425+
PlayHUDMotion("anm_hide", FALSE, this, S);
422426
}
423427
break;
424428
case eActivating: { PlayHUDMotion("anm_activate", FALSE, this, S);

src/xrGame/CustomDetector.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ void CCustomDetector::ToggleDetector(bool bFastMode)
119119

120120
void CCustomDetector::OnStateSwitch(u32 S)
121121
{
122+
u32 oldState = GetState();
122123
inherited::OnStateSwitch(S);
123124

124125
switch (S)
@@ -133,9 +134,12 @@ void CCustomDetector::OnStateSwitch(u32 S)
133134
break;
134135
case eHiding:
135136
{
136-
m_sounds.PlaySound("sndHide", Fvector().set(0, 0, 0), this, true, false);
137-
PlayHUDMotion(m_bFastAnimMode ? "anm_hide_fast" : "anm_hide", FALSE /*TRUE*/, this, GetState());
138-
SetPending(TRUE);
137+
if (oldState != eHiding)
138+
{
139+
m_sounds.PlaySound("sndHide", Fvector().set(0, 0, 0), this, true, false);
140+
PlayHUDMotion(m_bFastAnimMode ? "anm_hide_fast" : "anm_hide", FALSE/*TRUE*/, this, GetState());
141+
SetPending(TRUE);
142+
}
139143
}
140144
break;
141145
case eIdle:

src/xrGame/Grenade.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void CGrenade::OnH_A_Chield()
8989
inherited::OnH_A_Chield();
9090
}
9191

92-
void CGrenade::State(u32 state)
92+
void CGrenade::State(u32 state, u32 old_state)
9393
{
9494
switch (state)
9595
{
@@ -120,7 +120,7 @@ void CGrenade::State(u32 state)
120120
}
121121
break;
122122
};
123-
inherited::State(state);
123+
inherited::State(state, old_state);
124124
}
125125

126126
bool CGrenade::DropGrenade()

src/xrGame/Grenade.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class CGrenade : public CMissile, public CExplosive
3333

3434
virtual bool Action(u16 cmd, u32 flags);
3535
virtual bool Useful() const;
36-
virtual void State(u32 state);
36+
virtual void State(u32 state, u32 old_state);
3737

3838
virtual void OnH_B_Chield() { inherited::OnH_B_Chield(); }
3939
virtual void Hit(SHit* pHDS);

src/xrGame/Missile.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ void CMissile::shedule_Update(u32 dt)
239239
}
240240
}
241241

242-
void CMissile::State(u32 state)
242+
void CMissile::State(u32 state, u32 old_state)
243243
{
244-
switch (GetState())
244+
switch (state)
245245
{
246246
case eShowing:
247247
{
@@ -259,8 +259,11 @@ void CMissile::State(u32 state)
259259
{
260260
if (H_Parent())
261261
{
262-
SetPending(TRUE);
263-
PlayHUDMotion("anm_hide", TRUE, this, GetState());
262+
if (old_state != eHiding)
263+
{
264+
SetPending(TRUE);
265+
PlayHUDMotion("anm_hide", TRUE, this, GetState());
266+
}
264267
}
265268
}
266269
break;
@@ -311,8 +314,9 @@ void CMissile::State(u32 state)
311314
void CMissile::OnStateSwitch(u32 S)
312315
{
313316
m_dwStateTime = 0;
317+
u32 oldState = GetState();
314318
inherited::OnStateSwitch(S);
315-
State(S);
319+
State(S, oldState);
316320
}
317321

318322
void CMissile::OnAnimationEnd(u32 state)

src/xrGame/Missile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class CMissile : public CHudItemObject
4545

4646
virtual bool Action(u16 cmd, u32 flags);
4747

48-
virtual void State(u32 state);
48+
virtual void State(u32 state, u32 old_state);
4949
virtual void OnStateSwitch(u32 S);
5050
virtual bool GetBriefInfo(II_BriefInfo& info);
5151

src/xrGame/WeaponKnife.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,18 @@ void CWeaponKnife::Load(LPCSTR section)
7070

7171
void CWeaponKnife::OnStateSwitch(u32 S)
7272
{
73+
u32 old_state = GetState();
7374
inherited::OnStateSwitch(S);
7475
switch (S)
7576
{
7677
case eIdle: switch2_Idle(); break;
7778
case eShowing: switch2_Showing(); break;
78-
case eHiding: switch2_Hiding(); break;
79+
case eHiding:
80+
{
81+
if (old_state != eHiding)
82+
switch2_Hiding();
83+
break;
84+
}
7985
case eHidden: switch2_Hidden(); break;
8086
case eFire:
8187
{

src/xrGame/WeaponMagazined.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ void CWeaponMagazined::ReloadMagazine()
382382

383383
void CWeaponMagazined::OnStateSwitch(u32 S)
384384
{
385+
u32 old_state = GetState();
385386
inherited::OnStateSwitch(S);
386387
CInventoryOwner* owner = smart_cast<CInventoryOwner*>(this->H_Parent());
387388
switch (S)
@@ -406,7 +407,8 @@ void CWeaponMagazined::OnStateSwitch(u32 S)
406407
case eHiding:
407408
if (owner)
408409
m_sounds_enabled = owner->CanPlayShHdRldSounds();
409-
switch2_Hiding();
410+
if (old_state != eHiding)
411+
switch2_Hiding();
410412
break;
411413
case eHidden: switch2_Hidden(); break;
412414
}

0 commit comments

Comments
 (0)