Skip to content

Commit 477be26

Browse files
authored
[GEN][ZH] Fix game crash in MissileLauncherBuildingUpdate::initiateIntentToDoSpecialPower() (#1218)
1 parent b4a4c74 commit 477be26

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ SpecialPowerModule::SpecialPowerModule( Thing *thing, const ModuleData *moduleDa
9999
: BehaviorModule( thing, moduleData )
100100
{
101101

102+
#if RETAIL_COMPATIBLE_CRC
102103
m_availableOnFrame = 0;
104+
#else
105+
m_availableOnFrame = 0xFFFFFFFF;
106+
#endif
103107
m_pausedCount = 0;
104108
m_pausedOnFrame = 0;
105109
m_pausedPercent = 0.0f;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ void OCLSpecialPower::doSpecialPowerAtLocation( const Coord3D *loc, Real angle,
180180
// call the base class action cause we are *EXTENDING* functionality
181181
SpecialPowerModule::doSpecialPowerAtLocation( &targetCoord, angle, commandOptions );
182182

183+
#if RETAIL_COMPATIBLE_CRC
184+
// TheSuperHackers @info we need to leave early if we are in the MissileLauncherBuildingUpdate crash fix codepath
185+
if (m_availableOnFrame == 0xFFFFFFFF)
186+
return;
187+
#endif
188+
183189
const ObjectCreationList* ocl = findOCL();
184190

185191
// at what point will the "deliverer" come in

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ SpecialPowerModule::SpecialPowerModule( Thing *thing, const ModuleData *moduleDa
101101
: BehaviorModule( thing, moduleData )
102102
{
103103

104+
#if RETAIL_COMPATIBLE_CRC
104105
m_availableOnFrame = 0;
106+
#else
107+
m_availableOnFrame = 0xFFFFFFFF;
108+
#endif
105109
m_pausedCount = 0;
106110
m_pausedOnFrame = 0;
107111
m_pausedPercent = 0.0f;
@@ -455,6 +459,15 @@ Bool SpecialPowerModule::initiateIntentToDoSpecialPower( const Object *targetObj
455459
}
456460
}
457461

462+
#if RETAIL_COMPATIBLE_CRC
463+
// TheSuperHackers @info we need to leave early if we are in the MissileLauncherBuildingUpdate crash fix codepath
464+
if (m_availableOnFrame == 0xFFFFFFFF)
465+
{
466+
DEBUG_ASSERTCRASH(!valid, ("Using MissileLauncherBuildingUpdate escape path when valid is set to true"));
467+
return false;
468+
}
469+
#endif
470+
458471
getObject()->getControllingPlayer()->getAcademyStats()->recordSpecialPowerUsed( getSpecialPowerModuleData()->m_specialPowerTemplate );
459472

460473
//If we depend on our update module to trigger the special power, make sure we have the
@@ -715,6 +728,12 @@ void SpecialPowerModule::doSpecialPowerAtLocation( const Coord3D *loc, Real angl
715728
//will then start processing each frame.
716729
initiateIntentToDoSpecialPower( NULL, loc, NULL, commandOptions );
717730

731+
#if RETAIL_COMPATIBLE_CRC
732+
// TheSuperHackers @info we need to leave early if we are in the MissileLauncherBuildingUpdate crash fix codepath
733+
if (m_availableOnFrame == 0xFFFFFFFF)
734+
return;
735+
#endif
736+
718737
//Only trigger the special power immediately if the updatemodule doesn't start the attack.
719738
//An example of a case that wouldn't trigger immediately is for a unit that needs to
720739
//close to range before firing the special attack. A case that would trigger immediately

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,15 @@ void MissileLauncherBuildingUpdate::switchToState(DoorStateType dst)
206206
//-------------------------------------------------------------------------------------------------
207207
Bool MissileLauncherBuildingUpdate::initiateIntentToDoSpecialPower( const SpecialPowerTemplate *specialPowerTemplate, const Object *targetObj, const Coord3D *targetPos, const Waypoint *way, UnsignedInt commandOptions )
208208
{
209+
#if RETAIL_COMPATIBLE_CRC
210+
// TheSuperHackers @bugfix Mauller 29/06/2025 prevent a game crash when told to launch before ready to do so
211+
if (!m_specialPowerModule) {
212+
Object* us = getObject();
213+
us->getSpecialPowerModule(specialPowerTemplate)->setReadyFrame(0xFFFFFFFF);
214+
return FALSE;
215+
}
216+
#endif
217+
209218
if( m_specialPowerModule->getSpecialPowerTemplate() != specialPowerTemplate )
210219
{
211220
return FALSE;

0 commit comments

Comments
 (0)