Skip to content

Commit 24024fc

Browse files
committed
bugfix: Destroying disabled power plants lowers energy production twice
1 parent e2385c5 commit 24024fc

File tree

2 files changed

+12
-0
lines changed
  • GeneralsMD/Code/GameEngine/Source/Common/RTS
  • Generals/Code/GameEngine/Source/Common/RTS

2 files changed

+12
-0
lines changed

Generals/Code/GameEngine/Source/Common/RTS/Energy.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,18 @@ void Energy::removePowerBonus( Object *obj )
188188
if( obj == NULL )
189189
return;
190190

191+
// TheSuperHackers @bugfix Caball009 14/11/2025 Don't remove power bonus for disabled power plants.
192+
#if RETAIL_COMPATIBLE_CRC
191193
addProduction( -obj->getTemplate()->getEnergyBonus() );
194+
#else
195+
if ( !obj->isDisabled() )
196+
addProduction( -obj->getTemplate()->getEnergyBonus() );
192197

193198
// sanity
194199
DEBUG_ASSERTCRASH( m_energyProduction >= 0 && m_energyConsumption >= 0,
195200
("Energy - Negative Energy numbers, Produce=%d Consume=%d\n",
196201
m_energyProduction, m_energyConsumption) );
202+
#endif
197203

198204
}
199205

GeneralsMD/Code/GameEngine/Source/Common/RTS/Energy.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,18 @@ void Energy::removePowerBonus( Object *obj )
207207
if( obj == NULL )
208208
return;
209209

210+
// TheSuperHackers @bugfix Caball009 14/11/2025 Don't remove power bonus for disabled power plants.
211+
#if RETAIL_COMPATIBLE_CRC
210212
addProduction( -obj->getTemplate()->getEnergyBonus() );
213+
#else
214+
if ( !obj->isDisabled() )
215+
addProduction( -obj->getTemplate()->getEnergyBonus() );
211216

212217
// sanity
213218
DEBUG_ASSERTCRASH( m_energyProduction >= 0 && m_energyConsumption >= 0,
214219
("Energy - Negative Energy numbers, Produce=%d Consume=%d\n",
215220
m_energyProduction, m_energyConsumption) );
221+
#endif
216222

217223
}
218224

0 commit comments

Comments
 (0)