Skip to content

Commit 6c89a5a

Browse files
fix: Guard BodyModule access in StealthUpdate::allowedToStealth
1 parent c929fa0 commit 6c89a5a

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,15 +310,17 @@ Bool StealthUpdate::allowedToStealth( Object *stealthOwner ) const
310310
return FALSE;
311311
}
312312

313-
if( flags & STEALTH_NOT_WHILE_TAKING_DAMAGE && self->getBodyModule()->getLastDamageTimestamp() >= now - 1 )
313+
BodyModuleInterface *body = self->getBodyModule();
314+
if( flags & STEALTH_NOT_WHILE_TAKING_DAMAGE && body && body->getLastDamageTimestamp() >= now - 1 )
314315
{
315316
#if RETAIL_COMPATIBLE_CRC || PRESERVE_STRUCTURE_STEALTH_DURING_REPAIR
316317
//Only if it's not healing damage.
317-
if( self->getBodyModule()->getLastDamageInfo()->in.m_damageType != DAMAGE_HEALING )
318+
const DamageInfo *lastDamageInfo = body->getLastDamageInfo();
319+
if( lastDamageInfo && lastDamageInfo->in.m_damageType != DAMAGE_HEALING )
318320
#endif
319321
{
320322
//Can't stealth if we just took damage in the last frame or two.
321-
if( self->getBodyModule()->getLastDamageTimestamp() != 0xffffffff )
323+
if( body->getLastDamageTimestamp() != 0xffffffff )
322324
{
323325
//But it's initialized to 0xffffffff so we don't think we took damage on the first frame.
324326
return FALSE;

0 commit comments

Comments
 (0)