Skip to content

Commit a679e67

Browse files
committed
refactor: add isUnderpoweredForAttack helper method
1 parent 968c009 commit a679e67

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

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

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

590591
UnsignedInt getDisabledUntil( DisabledType type = DISABLED_ANY ) const;
591592

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

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,6 +1724,16 @@ Bool Object::isLogicallyVisible() const
17241724
//=============================================================================
17251725
// Object::isLocallyControlled
17261726
//=============================================================================
1727+
Bool Object::isUnderpoweredForAttack() const
1728+
{
1729+
#if !RETAIL_COMPATIBLE_CRC
1730+
return isKindOf( KINDOF_POWERED ) && isDisabledByType( DISABLED_UNDERPOWERED );
1731+
#else
1732+
return false;
1733+
#endif
1734+
}
1735+
1736+
//-------------------------------------------------------------------------------------------------
17271737
Bool Object::isLocallyControlled() const
17281738
{
17291739
return getControllingPlayer() == ThePlayerList->getLocalPlayer();
@@ -2247,10 +2257,16 @@ void Object::setDisabledUntil( DisabledType type, UnsignedInt frame )
22472257

22482258
}
22492259

2250-
// TheSuperHackers @bugfix bobtista 21/12/2025 Force FiringTracker to cool down immediately when power is lost to prevent delayed barrel animations.
2251-
if (m_firingTracker && (type == DISABLED_UNDERPOWERED || type == DISABLED_EMP || type == DISABLED_SUBDUED || type == DISABLED_HACKED))
2260+
// TheSuperHackers @bugfix bobtista 21/12/2025 Fix Gatling Cannon barrels rotating despite insufficient energy.
2261+
// When power is lost (UNDERPOWERED, EMP, SUBDUED, HACKED), immediately force FiringTracker cooldown to stop barrel animations.
2262+
// getDisabledTypesToProcess() prevents update() from restarting animations, and isUnderpoweredForAttack() prevents cursor/attack logic.
2263+
if (m_firingTracker)
22522264
{
2253-
m_firingTracker->forceCoolDown();
2265+
Bool isPowerDisableType = (type == DISABLED_UNDERPOWERED || type == DISABLED_EMP || type == DISABLED_SUBDUED || type == DISABLED_HACKED);
2266+
if (isPowerDisableType)
2267+
{
2268+
m_firingTracker->forceCoolDown();
2269+
}
22542270
}
22552271

22562272
// This will only be called if we were NOT disabled before coming into this function.
@@ -3242,9 +3258,8 @@ Bool Object::isAbleToAttack() const
32423258
if ( isDisabledByType( DISABLED_SUBDUED ) )
32433259
return FALSE; // A Microwave Tank is cooking me
32443260

3245-
// TheSuperHackers @bugfix bobtista 31/10/2025 Fixes Gatling Cannon barrels rotating despite insufficient energy.
32463261
#if !RETAIL_COMPATIBLE_CRC
3247-
if ( isKindOf( KINDOF_POWERED ) && isDisabledByType( DISABLED_UNDERPOWERED ) )
3262+
if (isUnderpoweredForAttack())
32483263
return false;
32493264
#endif
32503265

@@ -4763,9 +4778,8 @@ void Object::adjustModelConditionForWeaponStatus()
47634778
// we really don't care, so we just force the issue here. (This might still need tweaking for the pursue state.)
47644779
conditionToSet = WSF_NONE;
47654780
}
4766-
// TheSuperHackers @bugfix bobtista 11/11/2025 Prevent barrel animation when powered structures are underpowered.
47674781
#if !RETAIL_COMPATIBLE_CRC
4768-
else if ( isKindOf( KINDOF_POWERED ) && isDisabledByType( DISABLED_UNDERPOWERED ) )
4782+
else if (isUnderpoweredForAttack())
47694783
{
47704784
conditionToSet = WSF_NONE;
47714785
}
@@ -4793,9 +4807,8 @@ void Object::adjustModelConditionForWeaponStatus()
47934807
if (newStatus == READY_TO_FIRE && conditionToSet == WSF_NONE && testStatus( OBJECT_STATUS_IS_ATTACKING ) &&
47944808
(testStatus( OBJECT_STATUS_IS_AIMING_WEAPON ) || testStatus( OBJECT_STATUS_IS_FIRING_WEAPON )))
47954809
{
4796-
// TheSuperHackers @bugfix bobtista 11/11/2025 Don't resume firing animation if underpowered.
47974810
#if !RETAIL_COMPATIBLE_CRC
4798-
if ( !( isKindOf( KINDOF_POWERED ) && isDisabledByType( DISABLED_UNDERPOWERED ) ) )
4811+
if (!isUnderpoweredForAttack())
47994812
{
48004813
conditionToSet = WSF_BETWEEN;
48014814
}

0 commit comments

Comments
 (0)