@@ -4210,7 +4210,9 @@ else if ((atype != null)
42104210
42114211 // Aerospace target modifiers
42124212 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 ;
42144216
42154217 // is the target at zero velocity
42164218 if ((a .getCurrentVelocity () == 0 ) && !(a .isSpheroid () && !game .getBoard ().inSpace ())) {
@@ -4234,19 +4236,24 @@ else if ((atype != null)
42344236 // Target hidden in the sensor shadow of a larger spacecraft
42354237 if (game .getOptions ().booleanOption (OptionsConstants .ADVAERORULES_STRATOPS_SENSOR_SHADOW )
42364238 && 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" ));
42504257 }
42514258 }
42524259 }
0 commit comments