Skip to content

Commit 4482d08

Browse files
committed
perf(fps): move hero counter updates to match stealth counter pattern"
1 parent 84760ff commit 4482d08

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,10 @@ void OpenContain::addToContainList( Object *rider )
356356
{
357357
m_stealthUnitsContained++;
358358
}
359+
if( rider->isKindOf( KINDOF_HERO ) )
360+
{
361+
m_heroUnitsContained++;
362+
}
359363
}
360364

361365
//-------------------------------------------------------------------------------------------------
@@ -546,6 +550,10 @@ void OpenContain::removeFromContainViaIterator( ContainedItemsList::iterator it,
546550
}
547551
}
548552
}
553+
if( rider->isKindOf( KINDOF_HERO ) && m_heroUnitsContained > 0 )
554+
{
555+
m_heroUnitsContained--;
556+
}
549557

550558

551559
if (isEnclosingContainerFor( rider ))
@@ -633,11 +641,6 @@ void OpenContain::onContaining( Object *rider )
633641
enterSound.setObjectID(getObject()->getID());
634642
TheAudio->addAudioEvent(&enterSound);
635643
}
636-
637-
if( rider && rider->isKindOf( KINDOF_HERO ) )
638-
{
639-
m_heroUnitsContained++;
640-
}
641644
}
642645

643646
//-------------------------------------------------------------------------------------------------
@@ -653,11 +656,6 @@ void OpenContain::onRemoving( Object *rider)
653656
AudioEventRTS fallingSound = *rider->getTemplate()->getSoundFalling();
654657
fallingSound.setObjectID(rider->getID());
655658
TheAudio->addAudioEvent(&fallingSound);
656-
657-
if( rider->isKindOf( KINDOF_HERO ) && m_heroUnitsContained > 0 )
658-
{
659-
m_heroUnitsContained--;
660-
}
661659
}
662660
}
663661

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ void OpenContain::addToContainList( Object *rider )
378378
{
379379
m_stealthUnitsContained++;
380380
}
381+
if( rider->isKindOf( KINDOF_HERO ) )
382+
{
383+
m_heroUnitsContained++;
384+
}
381385
}
382386

383387
//-------------------------------------------------------------------------------------------------
@@ -664,6 +668,10 @@ void OpenContain::removeFromContainViaIterator( ContainedItemsList::iterator it,
664668
}
665669
}
666670
}
671+
if( rider->isKindOf( KINDOF_HERO ) && m_heroUnitsContained > 0 )
672+
{
673+
m_heroUnitsContained--;
674+
}
667675

668676

669677
if (isEnclosingContainerFor( rider ))
@@ -753,11 +761,6 @@ void OpenContain::onContaining( Object *rider, Bool wasSelected )
753761
enterSound.setObjectID(getObject()->getID());
754762
TheAudio->addAudioEvent(&enterSound);
755763
}
756-
757-
if( rider && rider->isKindOf( KINDOF_HERO ) )
758-
{
759-
m_heroUnitsContained++;
760-
}
761764
}
762765

763766
//-------------------------------------------------------------------------------------------------
@@ -773,11 +776,6 @@ void OpenContain::onRemoving( Object *rider)
773776
AudioEventRTS fallingSound = *rider->getTemplate()->getSoundFalling();
774777
fallingSound.setObjectID(rider->getID());
775778
TheAudio->addAudioEvent(&fallingSound);
776-
777-
if( rider->isKindOf( KINDOF_HERO ) && m_heroUnitsContained > 0 )
778-
{
779-
m_heroUnitsContained--;
780-
}
781779
}
782780
}
783781

0 commit comments

Comments
 (0)