39 lines
1.5 KiB
Diff
39 lines
1.5 KiB
Diff
# UNDF: UNDF-2026-000000987
|
|
--- a/rts/Sim/Weapons/Weapon.h
|
|
+++ b/rts/Sim/Weapons/Weapon.h
|
|
@@ -1,6 +1,7 @@
|
|
#ifndef WEAPON_H
|
|
#define WEAPON_H
|
|
|
|
+#include <unordered_set>
|
|
#include <functional>
|
|
#include <vector>
|
|
|
|
@@ -46,8 +47,8 @@
|
|
virtual const float3& GetAimFromPos(bool useMuzzle = false) const { return (useMuzzle? weaponMuzzlePos: aimFromPos); }
|
|
|
|
- bool HasIncomingProjectile(int projID) const { return (std::find(incomingProjectileIDs.begin(), incomingProjectileIDs.end(), projID) != incomingProjectileIDs.end()); }
|
|
- void AddIncomingProjectile(int projID) { incomingProjectileIDs.push_back(projID); }
|
|
+ bool HasIncomingProjectile(int projID) const { return (incomingProjectileIDs.find(projID) != incomingProjectileIDs.end()); }
|
|
+ void AddIncomingProjectile(int projID) { incomingProjectileIDs.insert(projID); }
|
|
|
|
public:
|
|
/// test if the weapon is able to attack an enemy/mapspot just by its properties (no range check, no FreeLineOfFire check, ...)
|
|
@@ -203,7 +204,7 @@
|
|
float3 salvoError;
|
|
|
|
float3 errorVector;
|
|
- std::vector<int> incomingProjectileIDs;
|
|
+ std::unordered_set<int> incomingProjectileIDs;
|
|
|
|
protected:
|
|
SWeaponTarget currentTarget;
|
|
--- a/rts/Sim/Weapons/Weapon.cpp
|
|
+++ b/rts/Sim/Weapons/Weapon.cpp
|
|
@@ -724,7 +724,7 @@
|
|
// NOTE: DependentDied is called from ~CObject-->Detach, object is just barely valid
|
|
if (weaponDef->interceptor || weaponDef->isShield) {
|
|
- spring::VectorErase(incomingProjectileIDs, static_cast<CWeaponProjectile*>(o)->id);
|
|
+ incomingProjectileIDs.erase(static_cast<CWeaponProjectile*>(o)->id);
|
|
}
|
|
}
|