Skip to content

Commit bf70918

Browse files
committed
Revert weapon/WH detonate function optimization using shared bullet instance
Recursive detonation chains using features like DetonateOnAllMapObjects, ExtraWarheads, Crit etc. keep causing various issues with bullet properties being overwritten prematurely, impossible to cover for all cases which is why this needs to be reverted.
1 parent 40ad9ad commit bf70918

File tree

4 files changed

+4
-28
lines changed

4 files changed

+4
-28
lines changed

src/Ext/Bullet/Body.cpp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -395,29 +395,12 @@ void BulletExt::ApplyArcingFix(BulletClass* pThis, const CoordStruct& sourceCoor
395395
}
396396
}
397397

398-
// Detonate weapon/warhead using master bullet instance.
398+
// Detonate weapon/warhead using a bullet.
399399
void BulletExt::Detonate(const CoordStruct& coords, TechnoClass* pOwner, int damage, HouseClass* pFiringHouse, AbstractClass* pTarget, bool isBright, WeaponTypeClass* pWeapon, WarheadTypeClass* pWarhead)
400400
{
401-
auto pBullet = ScenarioExt::Global()->MasterDetonationBullet;
402401
auto const pType = pWeapon ? pWeapon->Projectile : BulletTypeExt::GetDefaultBulletType();
403-
404-
// Oct 24, 2025 - Starkku: If the warhead is supposed to detonate on all map objects we actually need to create new BulletClass instance.
405-
// Otherwise the master bullet instance can have its properties overwritten prematurely and cause weird issues.
406-
if (WarheadTypeExt::ExtMap.Find(pWarhead)->DetonateOnAllMapObjects)
407-
{
408-
pBullet = pType->CreateBullet(pTarget, pOwner, damage, pWarhead, 100, isBright);
409-
pBullet->WeaponType = pWeapon;
410-
}
411-
else
412-
{
413-
pBullet->Type = pType;
414-
pBullet->WeaponType = pWeapon;
415-
pBullet->Owner = pOwner;
416-
pBullet->Health = damage;
417-
pBullet->Target = pTarget;
418-
pBullet->WH = pWarhead;
419-
pBullet->Bright = isBright;
420-
}
402+
auto const pBullet = pType->CreateBullet(pTarget, pOwner, damage, pWarhead, 100, isBright);
403+
pBullet->WeaponType = pWeapon;
421404

422405
auto const pBulletExt = BulletExt::ExtMap.Find(pBullet);
423406
pBulletExt->IsInstantDetonation = true;
@@ -429,7 +412,6 @@ void BulletExt::Detonate(const CoordStruct& coords, TechnoClass* pOwner, int dam
429412
pBullet->Explode(true);
430413
}
431414

432-
433415
// =============================
434416
// load / save
435417

src/Ext/Rules/Body.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "Body.h"
1+
#include "Body.h"
22
#include <Ext/Side/Body.h>
33
#include <Utilities/TemplateDef.h>
44
#include <FPSCounter.h>
@@ -389,9 +389,6 @@ void RulesExt::ExtData::InitializeAfterAllLoaded()
389389
this->TintColorIronCurtain = GeneralUtils::GetColorFromColorAdd(pRules->IronCurtainColor);
390390
this->TintColorForceShield = GeneralUtils::GetColorFromColorAdd(pRules->ForceShieldColor);
391391
this->TintColorBerserk = GeneralUtils::GetColorFromColorAdd(pRules->BerserkColor);
392-
393-
// Init master bullet
394-
ScenarioExt::Global()->MasterDetonationBullet = BulletTypeExt::GetDefaultBulletType()->CreateBullet(nullptr, nullptr, 0, nullptr, 0, false);
395392
}
396393

397394
// =============================

src/Ext/Scenario/Body.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ void ScenarioExt::ExtData::Serialize(T& Stm)
167167
.Process(this->DefaultLS640BkgdName)
168168
.Process(this->DefaultLS800BkgdName)
169169
.Process(this->DefaultLS800BkgdPal)
170-
.Process(this->MasterDetonationBullet)
171170
.Process(this->LimboLaunchers)
172171
.Process(this->UndergroundTracker)
173172
.Process(this->SpecialTracker)

src/Ext/Scenario/Body.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class ScenarioExt
4646
PhobosFixedString<64u> DefaultLS800BkgdName;
4747
PhobosFixedString<64u> DefaultLS800BkgdPal;
4848

49-
BulletClass* MasterDetonationBullet; // Used to do warhead/weapon detonations on spot without having to create new BulletClass instance every time.
5049
std::vector<TechnoExt::ExtData*> LimboLaunchers;
5150

5251
DynamicVectorClass<TechnoClass*> UndergroundTracker; // Technos that are underground.
@@ -66,7 +65,6 @@ class ScenarioExt
6665
, DefaultLS640BkgdName {}
6766
, DefaultLS800BkgdName {}
6867
, DefaultLS800BkgdPal {}
69-
, MasterDetonationBullet {}
7068
, LimboLaunchers {}
7169
, UndergroundTracker {}
7270
, SpecialTracker {}

0 commit comments

Comments
 (0)