From 955eb71e79d1d14222fa95e7580886fca84a058f Mon Sep 17 00:00:00 2001 From: Reza Date: Thu, 23 Jul 2026 21:42:03 +0200 Subject: [PATCH] fix(contain): remove destroyed detached occupants --- .../Source/GameLogic/Object/Contain/OpenContain.cpp | 4 +++- .../Source/GameLogic/Object/Contain/OpenContain.cpp | 4 +++- docs/WORKLOG/2026-07-DIARY.md | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp index 5c2d950dc82..7352aa17ecb 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp @@ -1443,7 +1443,9 @@ void OpenContain::processDamageToContained(Real percentDamage) if( !object->isEffectivelyDead() && killContained ) object->kill(); // in case we are carrying flame proof troops we have been asked to kill - if ( object->isEffectivelyDead() ) + // TheSuperHackers @bugfix mreza0100 23/07/2026 A destroyed occupant cannot remove itself + // while the contain list is temporarily detached. Do not restore a pending dangling pointer. + if ( object->isEffectivelyDead() || object->isDestroyed() ) { onRemoving( object ); object->onRemovedFrom( getObject() ); diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp index 4cc9a3bae7c..fa2278f6023 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp @@ -1587,7 +1587,9 @@ void OpenContain::processDamageToContained(Real percentDamage) if( !object->isEffectivelyDead() && killContained ) object->kill(); // in case we are carrying flame proof troops we have been asked to kill - if ( object->isEffectivelyDead() ) + // TheSuperHackers @bugfix mreza0100 23/07/2026 A destroyed occupant cannot remove itself + // while the contain list is temporarily detached. Do not restore a pending dangling pointer. + if ( object->isEffectivelyDead() || object->isDestroyed() ) { onRemoving( object ); object->onRemovedFrom( getObject() ); diff --git a/docs/WORKLOG/2026-07-DIARY.md b/docs/WORKLOG/2026-07-DIARY.md index 2f579568029..ef159b412c1 100644 --- a/docs/WORKLOG/2026-07-DIARY.md +++ b/docs/WORKLOG/2026-07-DIARY.md @@ -1,5 +1,10 @@ # July 2026 +## 23/07/2026 +### Prevent Stale Occupants After Contained Damage +- Removed destroyed occupants before restoring the temporarily detached contain list, preventing deferred deletion from leaving dangling rider pointers in transports and garrisons. +- Applied the same fix to Generals and Zero Hour while preserving the retail-compatible CRC path. + ## 17/07/2026 ### Fix Non-Deterministic Math in WWMath Matrix Classes - Traced the cross-platform desync at frame 100 to the `TrainCabUngarrisonable` object's translation matrix diverging between macOS (ARM64) and Linux (x86_64).