Skip to content

Commit 3a58ec4

Browse files
authored
bugfix(object): Fix crash when an object is created with veterancy and an upgrade that applies a terrain decal (#1359)
Most notably happens when spawning the USA Pilot with the Chemical Suits upgrade
1 parent 6ad992f commit 3a58ec4

File tree

2 files changed

+8
-6
lines changed
  • GeneralsMD/Code/GameEngine/Source/GameLogic/Object
  • Generals/Code/GameEngine/Source/GameLogic/Object

2 files changed

+8
-6
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,11 @@ Object::Object( const ThingTemplate *tt, const ObjectStatusMaskType &objectStatu
430430
m_soleHealingBenefactorID = INVALID_ID; ///< who is the only other object that can give me this non-stacking heal benefit?
431431
m_soleHealingBenefactorExpirationFrame = 0; ///< on what frame can I accept healing (thus to switch) from a new benefactor
432432

433+
// TheSuperHackers @bugfix Mauller/xezon 02/08/2025 sendObjectCreated needs calling before CreateModule's are initialized to prevent drawable related crashes
434+
// This predominantly occurs with the veterancy create module when the chemical suits upgrade is unlocked as it tries to set the terrain decal.
433435

436+
// emit message announcing object's creation
437+
TheGameLogic->sendObjectCreated( this );
434438

435439
} // end Object
436440

@@ -455,9 +459,6 @@ void Object::initObject()
455459
// If I have a valid team assigned, I can run through my Upgrade modules with his flags
456460
updateUpgradeModules();
457461

458-
// emit message announcing object's creation
459-
TheGameLogic->sendObjectCreated( this );
460-
461462
//If the player has battle plans (America Strategy Center), then apply those bonuses
462463
//to this object if applicable. Internally it validates certain kinds of objects.
463464
const Player* controller = getControllingPlayer();

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,11 @@ Object::Object( const ThingTemplate *tt, const ObjectStatusMaskType &objectStatu
499499
m_soleHealingBenefactorID = INVALID_ID; ///< who is the only other object that can give me this non-stacking heal benefit?
500500
m_soleHealingBenefactorExpirationFrame = 0; ///< on what frame can I accept healing (thus to switch) from a new benefactor
501501

502+
// TheSuperHackers @bugfix Mauller/xezon 02/08/2025 sendObjectCreated needs calling before CreateModule's are initialized to prevent drawable related crashes
503+
// This predominantly occurs with the veterancy create module when the chemical suits upgrade is unlocked as it tries to set the terrain decal.
502504

505+
// emit message announcing object's creation
506+
TheGameLogic->sendObjectCreated( this );
503507

504508
} // end Object
505509

@@ -524,9 +528,6 @@ void Object::initObject()
524528
for (int i = 0; i < WEAPONSLOT_COUNT; ++i)
525529
m_lastWeaponCondition[i] = WSF_INVALID;
526530

527-
// emit message announcing object's creation
528-
TheGameLogic->sendObjectCreated( this );
529-
530531
// If I have a valid team assigned, I can run through my Upgrade modules with his flags
531532
updateUpgradeModules();
532533

0 commit comments

Comments
 (0)