Skip to content

Commit 2e69d53

Browse files
authored
[GEN][ZH] Fix assert about using uninitialized garrison points when entering a structure for the first time (#783)
1 parent d11ecb9 commit 2e69d53

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

Generals/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,11 +638,10 @@ void GarrisonContain::trackTargets( void )
638638
AIUpdateInterface *ai;
639639
Object *obj;
640640

641+
DEBUG_ASSERTCRASH(m_garrisonPointsInitialized, ("garrisonPoints are not inited"));
642+
641643
for( ContainedItemsList::const_iterator it = containList.begin(); it != containList.end(); ++it )
642644
{
643-
644-
DEBUG_ASSERTCRASH(m_garrisonPointsInitialized, ("garrisonPoints are not inited"));
645-
646645
// get the object
647646
obj = *it;
648647

Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,15 +319,25 @@ void OpenContain::addToContain( Object *rider )
319319
addOrRemoveObjFromWorld(rider, false);
320320
}
321321

322-
// ensure our contents are positions correctly.
322+
#if RETAIL_COMPATIBLE_CRC
323+
// ensure our occupants are positioned correctly.
324+
// TheSuperHackers @info Moving this call elsewhere will cause retail mismatch.
323325
redeployOccupants();
326+
#endif
324327

325328
// trigger an onContaining event for the object that just "ate" something
326329
if( getObject()->getContain() )
327330
{
328331
getObject()->getContain()->onContaining( rider );
329332
}
330333

334+
// ensure our occupants are positioned correctly.
335+
// TheSuperHackers @fix Skyaero 10/07/2025 Now (re)deploys the occupants after the garrison points
336+
// had a chance to initialize with prior call to onContaining(). No user facing bug was observed.
337+
#if !RETAIL_COMPATIBLE_CRC
338+
redeployOccupants();
339+
#endif
340+
331341
// trigger an onContainedBy event for the object that just got "eaten" by us
332342
rider->onContainedBy( getObject() );
333343

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -692,11 +692,10 @@ void GarrisonContain::trackTargets( void )
692692
AIUpdateInterface *ai;
693693
Object *obj;
694694

695+
DEBUG_ASSERTCRASH(m_garrisonPointsInitialized, ("garrisonPoints are not inited"));
696+
695697
for( ContainedItemsList::const_iterator it = containList.begin(); it != containList.end(); ++it )
696698
{
697-
698-
DEBUG_ASSERTCRASH(m_garrisonPointsInitialized, ("garrisonPoints are not inited"));
699-
700699
// get the object
701700
obj = *it;
702701

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,15 +341,25 @@ void OpenContain::addToContain( Object *rider )
341341
addOrRemoveObjFromWorld(rider, false);
342342
}
343343

344-
// ensure our contents are positions correctly.
344+
#if RETAIL_COMPATIBLE_CRC
345+
// ensure our occupants are positioned correctly.
346+
// TheSuperHackers @info Moving this call elsewhere will cause retail mismatch.
345347
redeployOccupants();
348+
#endif
346349

347350
// trigger an onContaining event for the object that just "ate" something
348351
if( getObject()->getContain() )
349352
{
350353
getObject()->getContain()->onContaining( rider, wasSelected );
351354
}
352355

356+
// ensure our occupants are positioned correctly.
357+
// TheSuperHackers @fix Skyaero 10/07/2025 Now (re)deploys the occupants after the garrison points
358+
// had a chance to initialize with prior call to onContaining(). No user facing bug was observed.
359+
#if !RETAIL_COMPATIBLE_CRC
360+
redeployOccupants();
361+
#endif
362+
353363
// trigger an onContainedBy event for the object that just got "eaten" by us
354364
rider->onContainedBy( getObject() );
355365

0 commit comments

Comments
 (0)