Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 8208208

Browse files
committed
Made MOSprite animations only reset the anim timer if one of their supported animations occured. Also fixed indenting on the switch
Fixed ActiveSound playing at (0, 0) Fixed IsReloading, DoneReloading and NeedsReloading not being marked as overrides, which was screwing up their lua bindings. Also marked them and HD::IsActivated as const cause they are.
1 parent 8012efd commit 8208208

File tree

4 files changed

+30
-28
lines changed

4 files changed

+30
-28
lines changed

Entities/HDFirearm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ void HDFirearm::Activate()
563563

564564
// Play the pre-fire sound
565565
if (!IsReloading() && !m_ActiveSound.IsBeingPlayed())
566-
m_ActiveSound.Play();
566+
m_ActiveSound.Play(this->m_Pos);
567567
}
568568

569569

@@ -646,7 +646,7 @@ void HDFirearm::Reload()
646646
//////////////////////////////////////////////////////////////////////////////////////////
647647
// Description: Tells whether the device is curtrently in need of being reloaded.
648648

649-
bool HDFirearm::NeedsReloading()
649+
bool HDFirearm::NeedsReloading() const
650650
{
651651
if (!m_Reloading)
652652
{

Entities/HDFirearm.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ ENTITYALLOCATION(HDFirearm)
587587
// Arguments: None.
588588
// Return value: Whetehr being reloaded.
589589

590-
virtual bool IsReloading() const { return m_Reloading; }
590+
virtual bool IsReloading() const override { return m_Reloading; }
591591

592592

593593
//////////////////////////////////////////////////////////////////////////////////////////
@@ -597,7 +597,7 @@ ENTITYALLOCATION(HDFirearm)
597597
// Arguments: None.
598598
// Return value: Whether just done reloading this frame.
599599

600-
virtual bool DoneReloading() { return m_DoneReloading; }
600+
virtual bool DoneReloading() const override { return m_DoneReloading; }
601601

602602

603603
//////////////////////////////////////////////////////////////////////////////////////////
@@ -607,7 +607,7 @@ ENTITYALLOCATION(HDFirearm)
607607
// Arguments: None.
608608
// Return value: Whetehr in need of reloading (ie not full).
609609

610-
virtual bool NeedsReloading();
610+
virtual bool NeedsReloading() const override;
611611

612612

613613
//////////////////////////////////////////////////////////////////////////////////////////

Entities/HeldDevice.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ ENTITYALLOCATION(HeldDevice)
476476
// Arguments: None.
477477
// Return value: Whether being activated.
478478

479-
virtual bool IsActivated() { return m_Activated; }
479+
virtual bool IsActivated() const { return m_Activated; }
480480

481481

482482
//////////////////////////////////////////////////////////////////////////////////////////
@@ -486,7 +486,7 @@ ENTITYALLOCATION(HeldDevice)
486486
// Arguments: None.
487487
// Return value: Whetehr being reloaded.
488488

489-
virtual bool IsReloading() { return false; }
489+
virtual bool IsReloading() const { return false; }
490490

491491

492492
//////////////////////////////////////////////////////////////////////////////////////////
@@ -496,7 +496,7 @@ ENTITYALLOCATION(HeldDevice)
496496
// Arguments: None.
497497
// Return value: Whether just done reloading this frame.
498498

499-
virtual bool DoneReloading() { return false; }
499+
virtual bool DoneReloading() const { return false; }
500500

501501

502502
//////////////////////////////////////////////////////////////////////////////////////////
@@ -506,7 +506,7 @@ ENTITYALLOCATION(HeldDevice)
506506
// Arguments: None.
507507
// Return value: Whetehr in need of reloading (ie not full).
508508

509-
virtual bool NeedsReloading() { return false; }
509+
virtual bool NeedsReloading() const { return false; }
510510

511511

512512
//////////////////////////////////////////////////////////////////////////////////////////

Entities/MOSprite.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -477,26 +477,28 @@ void MOSprite::Update() {
477477

478478
if (m_SpriteAnimTimer.GetElapsedSimTimeMS() > frameTime) {
479479
switch (m_SpriteAnimMode) {
480-
case ALWAYSLOOP:
481-
m_Frame = ((m_Frame + 1) % m_FrameCount);
482-
break;
483-
case ALWAYSRANDOM:
484-
while (m_Frame == prevFrame) {
485-
m_Frame = floorf(static_cast<float>(m_FrameCount) * PosRand());
486-
}
487-
break;
488-
case ALWAYSPINGPONG:
489-
if (m_Frame == m_FrameCount - 1) {
490-
m_SpriteAnimIsReversingFrames = true;
491-
} else if (m_Frame == 0) {
492-
m_SpriteAnimIsReversingFrames = false;
493-
}
494-
m_SpriteAnimIsReversingFrames ? m_Frame-- : m_Frame++;
495-
break;
496-
default:
497-
break;
480+
case ALWAYSLOOP:
481+
m_Frame = ((m_Frame + 1) % m_FrameCount);
482+
m_SpriteAnimTimer.Reset();
483+
break;
484+
case ALWAYSRANDOM:
485+
while (m_Frame == prevFrame) {
486+
m_Frame = floorf(static_cast<float>(m_FrameCount) * PosRand());
487+
}
488+
m_SpriteAnimTimer.Reset();
489+
break;
490+
case ALWAYSPINGPONG:
491+
if (m_Frame == m_FrameCount - 1) {
492+
m_SpriteAnimIsReversingFrames = true;
493+
} else if (m_Frame == 0) {
494+
m_SpriteAnimIsReversingFrames = false;
495+
}
496+
m_SpriteAnimIsReversingFrames ? m_Frame-- : m_Frame++;
497+
m_SpriteAnimTimer.Reset();
498+
break;
499+
default:
500+
break;
498501
}
499-
m_SpriteAnimTimer.Reset();
500502
}
501503
}
502504

0 commit comments

Comments
 (0)