Skip to content

Commit

Permalink
fix rare antinuke bug (2956)
Browse files Browse the repository at this point in the history
  • Loading branch information
rt committed Feb 15, 2012
1 parent 51d5303 commit 7f07419
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions rts/Sim/Weapons/Weapon.cpp
Expand Up @@ -1111,13 +1111,24 @@ void CWeapon::CheckIntercept(void)
for (std::map<int, CWeaponProjectile*>::iterator pi = incomingProjectiles.begin(); pi != incomingProjectiles.end(); ++pi) {
CWeaponProjectile* p = pi->second;

// set by CWeaponProjectile's ctor when the interceptor fires
if (p->targeted)
continue;

targetType = Target_Intercept;
// NOTE:
// <incomingProjectiles> is sorted by increasing projectile ID
// however projectiles launched later in time (which are still
// likely out of range) can be assigned *lower* ID's than older
// projectiles (which might be almost in range already), so if
// we already have an interception target we should not replace
// it unless another incoming projectile <p> is closer
if ((interceptTarget != NULL) && ((p->pos - weaponPos).SqLength() >= (interceptTarget->pos - weaponPos).SqLength()))
continue;

// keep targetPos in sync with the incoming projectile's position
interceptTarget = p;
targetType = Target_Intercept;
targetPos = p->pos;

break;
}
}
Expand Down

0 comments on commit 7f07419

Please sign in to comment.