Skip to content

Commit 12f7de9

Browse files
authored
bugfix(behavior): Do not fire weapons via the InstantDeathBehavior module while under construction (TheSuperHackers#3002)
1 parent 84e7402 commit 12f7de9

2 files changed

Lines changed: 30 additions & 16 deletions

File tree

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,23 @@ void InstantDeathBehavior::onDie( const DamageInfo *damageInfo )
159159
ObjectCreationList::create(ocl, getObject(), nullptr);
160160
}
161161

162-
listSize = d->m_weapons.size();
163-
if (listSize > 0)
162+
#if !RETAIL_COMPATIBLE_CRC
163+
// TheSuperHackers @bugfix Stubbjax 23/07/2026 Prevent firing weapons when a scaffold is cancelled
164+
// or destroyed. This logic matches the condition in the FireWeaponWhenDeadBehavior module.
165+
if (!getObject()->getStatusBits().test(OBJECT_STATUS_UNDER_CONSTRUCTION))
166+
#endif
164167
{
165-
idx = (size_t)GameLogicRandomValue(0, listSize-1);
166-
const WeaponTemplateVec& v = d->m_weapons;
167-
DEBUG_ASSERTCRASH(idx>=0&&idx<v.size(),("bad idx"));
168-
const WeaponTemplate* wt = v[idx];
169-
if (wt)
168+
listSize = d->m_weapons.size();
169+
if (listSize > 0)
170170
{
171-
TheWeaponStore->createAndFireTempWeapon(wt, getObject(), getObject()->getPosition());
171+
idx = (size_t)GameLogicRandomValue(0, listSize-1);
172+
const WeaponTemplateVec& v = d->m_weapons;
173+
DEBUG_ASSERTCRASH(idx>=0&&idx<v.size(),("bad idx"));
174+
const WeaponTemplate* wt = v[idx];
175+
if (wt)
176+
{
177+
TheWeaponStore->createAndFireTempWeapon(wt, getObject(), getObject()->getPosition());
178+
}
172179
}
173180
}
174181

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,23 @@ void InstantDeathBehavior::onDie( const DamageInfo *damageInfo )
159159
ObjectCreationList::create(ocl, getObject(), nullptr);
160160
}
161161

162-
listSize = d->m_weapons.size();
163-
if (listSize > 0)
162+
#if !RETAIL_COMPATIBLE_CRC
163+
// TheSuperHackers @bugfix Stubbjax 23/07/2026 Prevent firing weapons when a scaffold is cancelled
164+
// or destroyed. This logic matches the condition in the FireWeaponWhenDeadBehavior module.
165+
if (!getObject()->getStatusBits().test(OBJECT_STATUS_UNDER_CONSTRUCTION))
166+
#endif
164167
{
165-
idx = (size_t)GameLogicRandomValue(0, listSize-1);
166-
const WeaponTemplateVec& v = d->m_weapons;
167-
DEBUG_ASSERTCRASH(idx>=0&&idx<v.size(),("bad idx"));
168-
const WeaponTemplate* wt = v[idx];
169-
if (wt)
168+
listSize = d->m_weapons.size();
169+
if (listSize > 0)
170170
{
171-
TheWeaponStore->createAndFireTempWeapon(wt, getObject(), getObject()->getPosition());
171+
idx = (size_t)GameLogicRandomValue(0, listSize-1);
172+
const WeaponTemplateVec& v = d->m_weapons;
173+
DEBUG_ASSERTCRASH(idx>=0&&idx<v.size(),("bad idx"));
174+
const WeaponTemplate* wt = v[idx];
175+
if (wt)
176+
{
177+
TheWeaponStore->createAndFireTempWeapon(wt, getObject(), getObject()->getPosition());
178+
}
172179
}
173180
}
174181

0 commit comments

Comments
 (0)