Skip to content

Commit 89bd63d

Browse files
committed
refactor: add isUnderpoweredForAttack helper method
1 parent a679e67 commit 89bd63d

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ class Object : public Thing, public Snapshot
549549
void setDisabled( DisabledType type );
550550
void setDisabledUntil( DisabledType type, UnsignedInt frame );
551551
Bool isDisabledByType( DisabledType type ) const { return TEST_DISABLEDMASK( m_disabledMask, type ); }
552+
Bool isUnderpoweredForAttack() const; ///< Returns true if powered-type and underpowered
552553

553554
void pauseAllSpecialPowers( const Bool disabling ) const;
554555

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

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,16 @@ Bool Object::isLogicallyVisible() const
15691569
//=============================================================================
15701570
// Object::isLocallyControlled
15711571
//=============================================================================
1572+
Bool Object::isUnderpoweredForAttack() const
1573+
{
1574+
#if !RETAIL_COMPATIBLE_CRC
1575+
return isKindOf( KINDOF_POWERED ) && isDisabledByType( DISABLED_UNDERPOWERED );
1576+
#else
1577+
return false;
1578+
#endif
1579+
}
1580+
1581+
//-------------------------------------------------------------------------------------------------
15721582
Bool Object::isLocallyControlled() const
15731583
{
15741584
return getControllingPlayer() == ThePlayerList->getLocalPlayer();
@@ -2015,10 +2025,16 @@ void Object::setDisabledUntil( DisabledType type, UnsignedInt frame )
20152025

20162026
}
20172027

2018-
// TheSuperHackers @bugfix bobtista 21/12/2025 Force FiringTracker to cool down immediately when power is lost to prevent delayed barrel animations.
2019-
if (m_firingTracker && (type == DISABLED_UNDERPOWERED || type == DISABLED_EMP || type == DISABLED_HACKED))
2028+
// TheSuperHackers @bugfix bobtista 21/12/2025 Fix Gatling Cannon barrels rotating despite insufficient energy.
2029+
// When power is lost (UNDERPOWERED, EMP, HACKED), immediately force FiringTracker cooldown to stop barrel animations.
2030+
// getDisabledTypesToProcess() prevents update() from restarting animations, and isUnderpoweredForAttack() prevents cursor/attack logic.
2031+
if (m_firingTracker)
20202032
{
2021-
m_firingTracker->forceCoolDown();
2033+
Bool isPowerDisableType = (type == DISABLED_UNDERPOWERED || type == DISABLED_EMP || type == DISABLED_HACKED);
2034+
if (isPowerDisableType)
2035+
{
2036+
m_firingTracker->forceCoolDown();
2037+
}
20222038
}
20232039

20242040
// This will only be called if we were NOT disabled before coming into this function.
@@ -2924,9 +2940,8 @@ Bool Object::isAbleToAttack() const
29242940
if( testStatus(OBJECT_STATUS_SOLD) )
29252941
return false;
29262942

2927-
// TheSuperHackers @bugfix bobtista 31/10/2025 Fixes Gatling Cannon barrels rotating despite insufficient energy.
29282943
#if !RETAIL_COMPATIBLE_CRC
2929-
if ( isKindOf( KINDOF_POWERED ) && isDisabledByType( DISABLED_UNDERPOWERED ) )
2944+
if (isUnderpoweredForAttack())
29302945
return false;
29312946
#endif
29322947

@@ -4199,9 +4214,8 @@ void Object::adjustModelConditionForWeaponStatus()
41994214
// we really don't care, so we just force the issue here. (This might still need tweaking for the pursue state.)
42004215
conditionToSet = WSF_NONE;
42014216
}
4202-
// TheSuperHackers @bugfix bobtista 11/11/2025 Prevent barrel animation when powered structures are underpowered.
42034217
#if !RETAIL_COMPATIBLE_CRC
4204-
else if ( isKindOf( KINDOF_POWERED ) && isDisabledByType( DISABLED_UNDERPOWERED ) )
4218+
else if (isUnderpoweredForAttack())
42054219
{
42064220
conditionToSet = WSF_NONE;
42074221
}
@@ -4229,9 +4243,8 @@ void Object::adjustModelConditionForWeaponStatus()
42294243
if (newStatus == READY_TO_FIRE && conditionToSet == WSF_NONE && testStatus( OBJECT_STATUS_IS_ATTACKING ) &&
42304244
(testStatus( OBJECT_STATUS_IS_AIMING_WEAPON ) || testStatus( OBJECT_STATUS_IS_FIRING_WEAPON )))
42314245
{
4232-
// TheSuperHackers @bugfix bobtista 11/11/2025 Don't resume firing animation if underpowered.
42334246
#if !RETAIL_COMPATIBLE_CRC
4234-
if ( !( isKindOf( KINDOF_POWERED ) && isDisabledByType( DISABLED_UNDERPOWERED ) ) )
4247+
if (!isUnderpoweredForAttack())
42354248
{
42364249
conditionToSet = WSF_BETWEEN;
42374250
}

0 commit comments

Comments
 (0)