Skip to content

Commit a7ca25f

Browse files
committed
Simplify the code and fix the manual for Straight
1 parent cf4dba5 commit a7ca25f

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

docs/New-or-Enhanced-Logics.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,7 @@ Trajectory.Straight.CountAttenuation=1.0 ; floating point value
817817

818818
```{note}
819819
- Make sure you set a low `Trajectory.Straight.ProximityRadius` value unless necessary.
820-
- Note that if `Trajectory.Straight.ProximityFlight` is true, it will consume more CPU performance.
821-
- Note that the listed Warheads in `Trajectory.Straight.PassDetonateWarhead` and `Trajectory.Straight.ProximityWarhead` must be listed in `[Warheads]` for them to work.
820+
- The listed Warheads in `Trajectory.Straight.PassDetonateWarhead` and `Trajectory.Straight.ProximityWarhead` must be listed in `[Warheads]` for them to work.
822821
```
823822

824823
#### Bombard trajectory

src/Ext/Bullet/Trajectories/StraightTrajectory.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,9 @@ void StraightTrajectoryType::Read(CCINIClass* const pINI, const char* pSection)
9898
this->SubjectToGround.Read(exINI, pSection, "Trajectory.Straight.SubjectToGround");
9999
this->ConfineAtHeight.Read(exINI, pSection, "Trajectory.Straight.ConfineAtHeight");
100100
this->EdgeAttenuation.Read(exINI, pSection, "Trajectory.Straight.EdgeAttenuation");
101-
102-
if (this->EdgeAttenuation < 0.0)
103-
this->EdgeAttenuation = 0.0;
104-
101+
this->EdgeAttenuation = Math::max(0.0, this->EdgeAttenuation);
105102
this->CountAttenuation.Read(exINI, pSection, "Trajectory.Straight.CountAttenuation");
106-
107-
if (this->CountAttenuation < 0.0)
108-
this->CountAttenuation = 0.0;
103+
this->CountAttenuation = Math::max(0.0, this->CountAttenuation);
109104
}
110105

111106
template<typename T>
@@ -663,8 +658,10 @@ void StraightTrajectory::BulletDetonateLastCheck(BulletClass* pBullet, HouseClas
663658

664659
if (pType->ProximityDirect)
665660
pDetonateAt->ReceiveDamage(&damage, 0, pWH, pBullet->Owner, false, false, pOwner);
661+
else if (pType->ProximityMedial)
662+
WarheadTypeExt::DetonateAt(pWH, pBullet->Location, pBullet->Owner, damage, pOwner);
666663
else
667-
WarheadTypeExt::DetonateAt(pWH, pType->ProximityMedial ? pBullet->Location : position, pBullet->Owner, damage, pOwner, pType->ProximityMedial ? nullptr : pDetonateAt);
664+
WarheadTypeExt::DetonateAt(pWH, position, pBullet->Owner, damage, pOwner, pDetonateAt);
668665

669666
this->CalculateNewDamage(pBullet);
670667
}
@@ -790,7 +787,7 @@ void StraightTrajectory::PrepareForDetonateAt(BulletClass* pBullet, HouseClass*
790787
return;
791788

792789
// Step 1: Find valid targets on the ground within range.
793-
std::vector<CellClass*> recCellClass = PhobosTrajectoryType::GetCellsInProximityRadius(pBullet, this->Type->ProximityRadius.Get());
790+
std::vector<CellClass*> recCellClass = PhobosTrajectoryType::GetCellsInProximityRadius(pBullet, pType->ProximityRadius.Get());
794791
const size_t cellSize = recCellClass.size() * 2;
795792
size_t vectSize = cellSize;
796793
size_t thisSize = 0;
@@ -968,8 +965,10 @@ void StraightTrajectory::PrepareForDetonateAt(BulletClass* pBullet, HouseClass*
968965

969966
if (pType->ProximityDirect)
970967
pTechno->ReceiveDamage(&damage, 0, pWH, pBullet->Owner, false, false, pOwner);
968+
else if (pType->ProximityMedial)
969+
WarheadTypeExt::DetonateAt(pWH, pBullet->Location, pBullet->Owner, damage, pOwner);
971970
else
972-
WarheadTypeExt::DetonateAt(pWH, pType->ProximityMedial ? pBullet->Location : pTechno->GetCoords(), pBullet->Owner, damage, pOwner, pType->ProximityMedial ? nullptr : pTechno);
971+
WarheadTypeExt::DetonateAt(pWH, pTechno->GetCoords(), pBullet->Owner, damage, pOwner, pTechno);
973972

974973
this->CalculateNewDamage(pBullet);
975974

0 commit comments

Comments
 (0)