@@ -4210,7 +4210,9 @@ else if ((atype != null)
4210
4210
4211
4211
// Aerospace target modifiers
4212
4212
if (te != null && te .isAero () && te .isAirborne ()) {
4213
- IAero a = (IAero ) te ;
4213
+ // Finalized for concurrency reasons
4214
+ final Entity targetEntity = te ;
4215
+ IAero a = (IAero ) targetEntity
4214
4216
4215
4217
// is the target at zero velocity
4216
4218
if ((a .getCurrentVelocity () == 0 ) && !(a .isSpheroid () && !game .getBoard ().inSpace ())) {
@@ -4234,19 +4236,24 @@ else if ((atype != null)
4234
4236
// Target hidden in the sensor shadow of a larger spacecraft
4235
4237
if (game .getOptions ().booleanOption (OptionsConstants .ADVAERORULES_STRATOPS_SENSOR_SHADOW )
4236
4238
&& game .getBoard ().inSpace ()) {
4237
- for (Entity en : Compute .getAdjacentEntitiesAlongAttack (ae .getPosition (), target .getPosition (), game )) {
4238
- if (!en .isEnemyOf (te ) && en .isLargeCraft ()
4239
- && ((en .getWeight () - te .getWeight ()) >= -STRATOPS_SENSOR_SHADOW_WEIGHT_DIFF )) {
4240
- toHit .addModifier (+1 , Messages .getString ("WeaponAttackAction.SensorShadow" ));
4241
- break ;
4242
- }
4243
- }
4244
- for (Entity en : game .getEntitiesVector (target .getPosition ())) {
4245
- if (!en .isEnemyOf (te ) && en .isLargeCraft () && !en .equals ((Entity ) a )
4246
- && ((en .getWeight () - te .getWeight ()) >= -STRATOPS_SENSOR_SHADOW_WEIGHT_DIFF )) {
4247
- toHit .addModifier (+1 , Messages .getString ("WeaponAttackAction.SensorShadow" ));
4248
- break ;
4249
- }
4239
+ if (Compute .getAdjacentEntitiesAlongAttack (ae .getPosition (), target .getPosition (), game ).stream ()
4240
+ .anyMatch (en ->
4241
+ !en .isEnemyOf (targetEntity )
4242
+ && en .isLargeCraft ()
4243
+ && en .getWeight () - targetEntity .getWeight () >= -STRATOPS_SENSOR_SHADOW_WEIGHT_DIFF
4244
+ )
4245
+ ) {
4246
+ toHit .addModifier (+1 , Messages .getString ("WeaponAttackAction.SensorShadow" ));
4247
+ }
4248
+ if (game .getEntitiesVector (target .getPosition ()).stream ()
4249
+ .anyMatch (en ->
4250
+ !en .isEnemyOf (targetEntity )
4251
+ && en .isLargeCraft ()
4252
+ && !en .equals (targetEntity )
4253
+ && en .getWeight () - targetEntity .getWeight () >= -STRATOPS_SENSOR_SHADOW_WEIGHT_DIFF
4254
+ )
4255
+ ) {
4256
+ toHit .addModifier (+1 , Messages .getString ("WeaponAttackAction.SensorShadow" ));
4250
4257
}
4251
4258
}
4252
4259
}
0 commit comments