Skip to content

Commit 3eea715

Browse files
authored
bugfix(object): Do not apply veterancy bonuses and animations for dead units (TheSuperHackers#1968)
1 parent 20adf33 commit 3eea715

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

Generals/Code/GameEngine/Include/GameLogic/Object.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ class Object : public Thing, public Snapshot
213213

214214
void scoreTheKill( const Object *victim ); ///< I just killed this object.
215215
void onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel newLevel, Bool provideFeedback = TRUE ); ///< I just achieved this level right this moment
216+
void createVeterancyLevelFX(VeterancyLevel oldLevel, VeterancyLevel newLevel);
216217
ExperienceTracker* getExperienceTracker() {return m_experienceTracker;}
217218
const ExperienceTracker* getExperienceTracker() const {return m_experienceTracker;}
218219
VeterancyLevel getVeterancyLevel() const;

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2802,6 +2802,12 @@ Bool Object::hasSpecialPower( SpecialPowerType type ) const
28022802
//-------------------------------------------------------------------------------------------------
28032803
void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel newLevel, Bool provideFeedback )
28042804
{
2805+
#if !RETAIL_COMPATIBLE_CRC
2806+
// TheSuperHackers @bugfix Stubbjax 10/12/2025 Do not apply veterancy bonuses and animations for dead units.
2807+
if (isEffectivelyDead())
2808+
return;
2809+
#endif
2810+
28052811
updateUpgradeModules();
28062812

28072813
const UpgradeTemplate* up = TheUpgradeCenter->findVeterancyUpgrade(newLevel);
@@ -2853,7 +2859,18 @@ void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel ne
28532859
&& !isKindOf(KINDOF_IGNORED_IN_GUI)
28542860
&& isLogicallyVisible();
28552861

2856-
if( doAnimation && TheGameLogic->getDrawIconUI() )
2862+
if (doAnimation)
2863+
createVeterancyLevelFX(oldLevel, newLevel);
2864+
}
2865+
2866+
void Object::createVeterancyLevelFX(VeterancyLevel oldLevel, VeterancyLevel newLevel)
2867+
{
2868+
#if RETAIL_COMPATIBLE_CRC
2869+
if (isEffectivelyDead())
2870+
return;
2871+
#endif
2872+
2873+
if (TheGameLogic->getDrawIconUI())
28572874
{
28582875
if( TheAnim2DCollection && TheGlobalData->m_levelGainAnimationName.isEmpty() == FALSE )
28592876
{
@@ -2873,7 +2890,6 @@ void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel ne
28732890
soundToPlay.setObjectID( getID() );
28742891
TheAudio->addAudioEvent( &soundToPlay );
28752892
}
2876-
28772893
}
28782894

28792895
//-------------------------------------------------------------------------------------------------

GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ class Object : public Thing, public Snapshot
229229

230230
void scoreTheKill( const Object *victim ); ///< I just killed this object.
231231
void onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel newLevel, Bool provideFeedback = TRUE ); ///< I just achieved this level right this moment
232+
void createVeterancyLevelFX(VeterancyLevel oldLevel, VeterancyLevel newLevel);
232233
ExperienceTracker* getExperienceTracker() {return m_experienceTracker;}
233234
const ExperienceTracker* getExperienceTracker() const {return m_experienceTracker;}
234235
VeterancyLevel getVeterancyLevel() const;

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3118,6 +3118,12 @@ Bool Object::hasAnySpecialPower() const
31183118
//-------------------------------------------------------------------------------------------------
31193119
void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel newLevel, Bool provideFeedback )
31203120
{
3121+
#if !RETAIL_COMPATIBLE_CRC
3122+
// TheSuperHackers @bugfix Stubbjax 10/12/2025 Do not apply veterancy bonuses and animations for dead units.
3123+
if (isEffectivelyDead())
3124+
return;
3125+
#endif
3126+
31213127
updateUpgradeModules();
31223128

31233129
const UpgradeTemplate* up = TheUpgradeCenter->findVeterancyUpgrade(newLevel);
@@ -3169,7 +3175,18 @@ void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel ne
31693175
&& !isKindOf(KINDOF_IGNORED_IN_GUI)
31703176
&& isLogicallyVisible();
31713177

3172-
if( doAnimation && TheGameLogic->getDrawIconUI() )
3178+
if (doAnimation)
3179+
createVeterancyLevelFX(oldLevel, newLevel);
3180+
}
3181+
3182+
void Object::createVeterancyLevelFX(VeterancyLevel oldLevel, VeterancyLevel newLevel)
3183+
{
3184+
#if RETAIL_COMPATIBLE_CRC
3185+
if (isEffectivelyDead())
3186+
return;
3187+
#endif
3188+
3189+
if (TheGameLogic->getDrawIconUI())
31733190
{
31743191
if( TheAnim2DCollection && TheGlobalData->m_levelGainAnimationName.isEmpty() == FALSE )
31753192
{
@@ -3189,7 +3206,6 @@ void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel ne
31893206
soundToPlay.setObjectID( getID() );
31903207
TheAudio->addAudioEvent( &soundToPlay );
31913208
}
3192-
31933209
}
31943210

31953211
//-------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)