Skip to content

Commit 6044ba1

Browse files
authored
refactor(object): Simplify veterancy effect conditions (#1464)
1 parent 0c2375e commit 6044ba1

File tree

2 files changed

+17
-29
lines changed
  • GeneralsMD/Code/GameEngine/Source/GameLogic/Object
  • Generals/Code/GameEngine/Source/GameLogic/Object

2 files changed

+17
-29
lines changed

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

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

2778-
Bool hideAnimationForStealth = FALSE;
2779-
if( !isLocallyControlled() &&
2780-
testStatus( OBJECT_STATUS_STEALTHED ) &&
2781-
!testStatus( OBJECT_STATUS_DETECTED ) )
2782-
{
2783-
hideAnimationForStealth = TRUE;
2784-
}
2785-
2786-
Bool doAnimation = ( ! hideAnimationForStealth
2787-
&& (newLevel > oldLevel)
2788-
&& ( ! isKindOf(KINDOF_IGNORED_IN_GUI))); //First, we plan to do the animation if the level went up
2789-
27902778
switch (newLevel)
27912779
{
27922780
case LEVEL_REGULAR:
@@ -2796,7 +2784,6 @@ void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel ne
27962784
clearWeaponBonusCondition(WEAPONBONUSCONDITION_VETERAN);
27972785
clearWeaponBonusCondition(WEAPONBONUSCONDITION_ELITE);
27982786
clearWeaponBonusCondition(WEAPONBONUSCONDITION_HERO);
2799-
doAnimation = FALSE;//... but not if somehow up to Regular
28002787
break;
28012788
case LEVEL_VETERAN:
28022789
setWeaponSetFlag(WEAPONSET_VETERAN);
@@ -2824,7 +2811,14 @@ void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel ne
28242811
break;
28252812
}
28262813

2827-
if( doAnimation && TheGameLogic->getDrawIconUI() && provideFeedback )
2814+
Bool doAnimation = provideFeedback
2815+
&& newLevel > oldLevel
2816+
&& !isKindOf(KINDOF_IGNORED_IN_GUI)
2817+
&& (isLocallyControlled()
2818+
|| !testStatus(OBJECT_STATUS_STEALTHED)
2819+
|| testStatus(OBJECT_STATUS_DETECTED));
2820+
2821+
if( doAnimation && TheGameLogic->getDrawIconUI() )
28282822
{
28292823
if( TheAnim2DCollection && TheGlobalData->m_levelGainAnimationName.isEmpty() == FALSE )
28302824
{

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

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

3093-
Bool hideAnimationForStealth = FALSE;
3094-
if( !isLocallyControlled() &&
3095-
testStatus( OBJECT_STATUS_STEALTHED ) &&
3096-
!testStatus( OBJECT_STATUS_DETECTED ) &&
3097-
!testStatus( OBJECT_STATUS_DISGUISED ) )
3098-
{
3099-
hideAnimationForStealth = TRUE;
3100-
}
3101-
3102-
Bool doAnimation = ( ! hideAnimationForStealth
3103-
&& (newLevel > oldLevel)
3104-
&& ( ! isKindOf(KINDOF_IGNORED_IN_GUI))); //First, we plan to do the animation if the level went up
3105-
31063093
switch (newLevel)
31073094
{
31083095
case LEVEL_REGULAR:
@@ -3112,7 +3099,6 @@ void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel ne
31123099
clearWeaponBonusCondition(WEAPONBONUSCONDITION_VETERAN);
31133100
clearWeaponBonusCondition(WEAPONBONUSCONDITION_ELITE);
31143101
clearWeaponBonusCondition(WEAPONBONUSCONDITION_HERO);
3115-
doAnimation = FALSE;//... but not if somehow up to Regular
31163102
break;
31173103
case LEVEL_VETERAN:
31183104
setWeaponSetFlag(WEAPONSET_VETERAN);
@@ -3140,7 +3126,15 @@ void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel ne
31403126
break;
31413127
}
31423128

3143-
if( doAnimation && TheGameLogic->getDrawIconUI() && provideFeedback )
3129+
Bool doAnimation = provideFeedback
3130+
&& newLevel > oldLevel
3131+
&& !isKindOf(KINDOF_IGNORED_IN_GUI)
3132+
&& (isLocallyControlled()
3133+
|| !testStatus(OBJECT_STATUS_STEALTHED)
3134+
|| testStatus(OBJECT_STATUS_DETECTED)
3135+
|| testStatus(OBJECT_STATUS_DISGUISED));
3136+
3137+
if( doAnimation && TheGameLogic->getDrawIconUI() )
31443138
{
31453139
if( TheAnim2DCollection && TheGlobalData->m_levelGainAnimationName.isEmpty() == FALSE )
31463140
{

0 commit comments

Comments
 (0)