Skip to content

Commit 6e3da22

Browse files
committed
More fixes
1 parent 0a5642a commit 6e3da22

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ SpecialPowerModule::SpecialPowerModule( Thing *thing, const ModuleData *moduleDa
114114
initCountdown();
115115
#else
116116
// The Special Power will not be available until construction is done.
117-
m_availableOnFrame = UINT_MAX;
117+
m_availableOnFrame = ~0u;
118118
#endif
119119
}
120120

@@ -400,7 +400,7 @@ Bool SpecialPowerModule::isScriptOnly() const
400400
void SpecialPowerModule::onConstructionCompleted()
401401
{
402402
#if !RETAIL_COMPATIBLE_CRC
403-
DEBUG_ASSERTCRASH(m_availableOnFrame == UINT_MAX,
403+
DEBUG_ASSERTCRASH(m_availableOnFrame == ~0u,
404404
("Unexpected state. Function must be called only after OBJECT_STATUS_UNDER_CONSTRUCTION was completed"));
405405

406406
m_availableOnFrame = 0;
@@ -483,7 +483,7 @@ Bool SpecialPowerModule::initiateIntentToDoSpecialPower( const Object *targetObj
483483

484484
#if RETAIL_COMPATIBLE_CRC
485485
// TheSuperHackers @info we need to leave early if we are in the MissileLauncherBuildingUpdate crash fix codepath
486-
if (m_availableOnFrame == 0xFFFFFFFF)
486+
if (m_availableOnFrame == ~0u)
487487
{
488488
DEBUG_ASSERTCRASH(!valid, ("Using MissileLauncherBuildingUpdate escape path when valid is set to true"));
489489
return false;
@@ -752,7 +752,7 @@ void SpecialPowerModule::doSpecialPowerAtLocation( const Coord3D *loc, Real angl
752752

753753
#if RETAIL_COMPATIBLE_CRC
754754
// TheSuperHackers @info we need to leave early if we are in the MissileLauncherBuildingUpdate crash fix codepath
755-
if (m_availableOnFrame == 0xFFFFFFFF)
755+
if (m_availableOnFrame == ~0u)
756756
return;
757757
#endif
758758

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

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,15 @@
4646
//-------------------------------------------------------------------------------------------------
4747
MissileLauncherBuildingUpdate::MissileLauncherBuildingUpdate( Thing *thing, const ModuleData* moduleData ) : SpecialPowerUpdateModule( thing, moduleData )
4848
{
49+
const MissileLauncherBuildingUpdateModuleData* d = getMissileLauncherBuildingUpdateModuleData();
50+
4951
m_doorState = DOOR_CLOSED;
5052
m_timeoutState = DOOR_CLOSED;
5153
m_timeoutFrame = 0;
52-
m_openIdleAudio = getMissileLauncherBuildingUpdateModuleData()->m_openIdleAudio;
54+
m_openIdleAudio = d->m_openIdleAudio;
5355
m_openIdleAudio.setObjectID(getObject()->getID());
56+
m_specialPowerModule = getObject()->getSpecialPowerModule(d->m_specialPowerTemplate);
57+
DEBUG_ASSERTCRASH(m_specialPowerModule, ("Missing special power"));
5458
}
5559

5660
//-------------------------------------------------------------------------------------------------
@@ -201,14 +205,14 @@ void MissileLauncherBuildingUpdate::switchToState(DoorStateType dst)
201205
//-------------------------------------------------------------------------------------------------
202206
Bool MissileLauncherBuildingUpdate::initiateIntentToDoSpecialPower( const SpecialPowerTemplate *specialPowerTemplate, const Object *targetObj, const Coord3D *targetPos, const Waypoint *way, UnsignedInt commandOptions )
203207
{
204-
#if RETAIL_COMPATIBLE_CRC
205208
// TheSuperHackers @bugfix Mauller 29/06/2025 prevent a game crash when told to launch before ready to do so
206-
if (!m_specialPowerModule) {
207-
Object* us = getObject();
208-
us->getSpecialPowerModule(specialPowerTemplate)->setReadyFrame(0xFFFFFFFF);
209+
if( getObject()->testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION) )
210+
{
211+
#if RETAIL_COMPATIBLE_CRC
212+
getObject()->getSpecialPowerModule(specialPowerTemplate)->setReadyFrame(~0u);
213+
#endif
209214
return FALSE;
210215
}
211-
#endif
212216

213217
if( m_specialPowerModule->getSpecialPowerTemplate() != specialPowerTemplate )
214218
{
@@ -236,23 +240,16 @@ Bool MissileLauncherBuildingUpdate::isPowerCurrentlyInUse( const CommandButton *
236240
//-------------------------------------------------------------------------------------------------
237241
UpdateSleepTime MissileLauncherBuildingUpdate::update( void )
238242
{
239-
const MissileLauncherBuildingUpdateModuleData* d = getMissileLauncherBuildingUpdateModuleData();
240-
241-
UnsignedInt now = TheGameLogic->getFrame();
242-
243243
// If we are under construction, any decision we make about door status could be wrong.
244244
// Our special power module is randomly going to be initialized or not (which would result
245245
// in him reporting a 0 frame ready, which means we will start open).
246246
if( getObject()->testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION) )
247247
return UPDATE_SLEEP_NONE;
248248

249-
if (!m_specialPowerModule)
250-
{
251-
m_specialPowerModule = getObject()->getSpecialPowerModule(d->m_specialPowerTemplate);
252-
DEBUG_ASSERTCRASH(m_specialPowerModule, ("Missing special power"));
253-
}
249+
const MissileLauncherBuildingUpdateModuleData* d = getMissileLauncherBuildingUpdateModuleData();
250+
251+
UnsignedInt now = TheGameLogic->getFrame();
254252

255-
if (m_specialPowerModule)
256253
{
257254
UnsignedInt readyFrame = m_specialPowerModule->getReadyFrame();
258255
UnsignedInt whenToStartOpening = (readyFrame >= d->m_doorOpenTime) ? (readyFrame - d->m_doorOpenTime) : 0;
@@ -313,9 +310,6 @@ void MissileLauncherBuildingUpdate::xfer( Xfer *xfer )
313310
// extend base class
314311
UpdateModule::xfer( xfer );
315312

316-
// do not need to tie the m_specialPowerModule pointer cause it gets tied
317-
// SpecialPowerModuleInterface *m_specialPowerModule;
318-
319313
// door state
320314
xfer->xferUser( &m_doorState, sizeof( DoorStateType ) );
321315

0 commit comments

Comments
 (0)