Skip to content

Commit f4153a0

Browse files
committed
refactor: Condense animation conditions
1 parent 51bdeb1 commit f4153a0

File tree

2 files changed

+15
-35
lines changed
  • GeneralsMD/Code/GameEngine/Source/GameLogic/Object
  • Generals/Code/GameEngine/Source/GameLogic/Object

2 files changed

+15
-35
lines changed

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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2775,22 +2775,12 @@ void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel ne
27752775
if (body)
27762776
body->onVeterancyLevelChanged(oldLevel, newLevel, provideFeedback);
27772777

2778-
Bool hideAnimationForStealth = FALSE;
2779-
Bool doAnimation = FALSE;
2780-
2781-
if (provideFeedback)
2782-
{
2783-
if( !isLocallyControlled() &&
2784-
testStatus( OBJECT_STATUS_STEALTHED ) &&
2785-
!testStatus( OBJECT_STATUS_DETECTED ) )
2786-
{
2787-
hideAnimationForStealth = TRUE;
2788-
}
2789-
2790-
doAnimation = ( ! hideAnimationForStealth
2791-
&& (newLevel > oldLevel)
2792-
&& ( ! isKindOf(KINDOF_IGNORED_IN_GUI))); //First, we plan to do the animation if the level went up
2793-
}
2778+
Bool doAnimation = provideFeedback
2779+
&& newLevel > oldLevel
2780+
&& !isKindOf(KINDOF_IGNORED_IN_GUI)
2781+
&& (isLocallyControlled()
2782+
|| !testStatus(OBJECT_STATUS_STEALTHED)
2783+
|| testStatus(OBJECT_STATUS_DETECTED));
27942784

27952785
switch (newLevel)
27962786
{
@@ -2829,7 +2819,7 @@ void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel ne
28292819
break;
28302820
}
28312821

2832-
if( doAnimation && TheGameLogic->getDrawIconUI() && provideFeedback )
2822+
if( doAnimation && TheGameLogic->getDrawIconUI() )
28332823
{
28342824
if( TheAnim2DCollection && TheGlobalData->m_levelGainAnimationName.isEmpty() == FALSE )
28352825
{

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

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3090,23 +3090,13 @@ void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel ne
30903090
if (body)
30913091
body->onVeterancyLevelChanged( oldLevel, newLevel, provideFeedback );
30923092

3093-
Bool hideAnimationForStealth = FALSE;
3094-
Bool doAnimation = FALSE;
3095-
3096-
if (provideFeedback)
3097-
{
3098-
if( !isLocallyControlled() &&
3099-
testStatus( OBJECT_STATUS_STEALTHED ) &&
3100-
!testStatus( OBJECT_STATUS_DETECTED ) &&
3101-
!testStatus( OBJECT_STATUS_DISGUISED ) )
3102-
{
3103-
hideAnimationForStealth = TRUE;
3104-
}
3105-
3106-
doAnimation = ( ! hideAnimationForStealth
3107-
&& (newLevel > oldLevel)
3108-
&& ( ! isKindOf(KINDOF_IGNORED_IN_GUI))); //First, we plan to do the animation if the level went up
3109-
}
3093+
Bool doAnimation = provideFeedback
3094+
&& newLevel > oldLevel
3095+
&& !isKindOf(KINDOF_IGNORED_IN_GUI)
3096+
&& (isLocallyControlled()
3097+
|| !testStatus(OBJECT_STATUS_STEALTHED)
3098+
|| testStatus(OBJECT_STATUS_DETECTED)
3099+
|| testStatus(OBJECT_STATUS_DISGUISED));
31103100

31113101
switch (newLevel)
31123102
{
@@ -3145,7 +3135,7 @@ void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel ne
31453135
break;
31463136
}
31473137

3148-
if( doAnimation && TheGameLogic->getDrawIconUI() && provideFeedback )
3138+
if( doAnimation && TheGameLogic->getDrawIconUI() )
31493139
{
31503140
if( TheAnim2DCollection && TheGlobalData->m_levelGainAnimationName.isEmpty() == FALSE )
31513141
{

0 commit comments

Comments
 (0)