Menu ▾ ▴

[BETA TEST] Target Select logic should never allow Player #1 to select Mission object #1 as current target.

bbosen
2026-10-14
2026-10-21
  • bbosen

    bbosen - 2026-10-14

    Sometimes LAC allows the player to select, as his target, the aircraft designated as HIS. I have definitely seen this when I have flown as Player #1 and am permitted to select aircraft #1 as my current target. The target selection logic should always prevent any player from designating the aircraft with his own "MyNetworkId" value as his current target. Whenever his request to select "Next Target" or "Previous Target" would naturally lead him to select himself, the logic should skip over his own MyNetworkId value and select the next one (up or down) in the sequence. Hereafter let's refer to this bug as "Target Select allows Self-Select bug".

     

    Last edit: bbosen 2026-10-14
  • bbosen

    bbosen - 2026-10-14

    I think I found the source of this bug. In main.cpp's "event_targetNextRed()" function, take a look at this little block of code:

    if (RadarOnOff)
       { //@ Get here if Radar is active. Select individual aircraft as user demands.
       if (SelectedMissionTarget % 2)
          { //@ Get here if a RedTeam target was selected
          sound->play (SOUND_BEEP1, false);
          SelectedMissionTarget += 2; //@ Advance to next RedTeam target
          if (SelectedMissionTarget == MyNetworkId)
             {
             SelectedMissionTarget += 2; //@ Advance to next RedTeam Target
             }
          if (SelectedMissionTarget > 29)
             { //@ Do not allow overflow beyond object 29.
             SelectedMissionTarget = 1;
             }
          while ((SelectedMissionTarget < 30) && !(ThreeDObjects[SelectedMissionTarget]->active))
             { //@ Get here if selected target is not alive. Skip it.
             SelectedMissionTarget += 2; //@ Advance to next RedTeam Target;
             }
          }
    

    As you can see, that little block of code is only active if "SelectedMissionTarget" is an odd number, which is always true for RedTeam mission objects. But consider what happens if the value of "SelectedMissionObject is "29" (this will always be the case when the player continues to press "TargetNextRed" until there are no more RedTeam objects, since the last RedTeam object is always #29). The logic adds 2, so "SelectedMissionTarget" becomes 31. Then the value is tested for overflow, and if it is higher than "29", it is reset to "1", resulting in selection of object "1" which is the very definition of this bug!

    That block of code should be changed to THIS:

    if (RadarOnOff)
       { //@ Get here if Radar is active. Select individual aircraft as user demands.
       if (SelectedMissionTarget % 2)
          { //@ Get here if a RedTeam target was selected
          sound->play (SOUNDBEEP1, false);
          SelectedMissionTarget += 2; //@ Advance to next RedTeam target
          if (SelectedMissionTarget == MyNetworkId)
             {
             SelectedMissionTarget += 2; //@ Advance to next RedTeam Target
             }
          if (SelectedMissionTarget > 29)
             { //@ Do not allow overflow beyond object 29.
             SelectedMissionTarget = 1;
             if (SelectedMissionTarget == MyNetworkId)
                { 
                // Get here if resetting overflow of SelectedMissionTarget back to 1
                // Causes improper selection of the player's own MyNetworkId as his target.
                SelectedMissionTarget += 2; // In this special case, skip Target "1" and choose "3".
                }
             }
          while ((SelectedMissionTarget < 30) && !(ThreeDObjects[SelectedMissionTarget]->active))
             { //@ Get here if selected target is not alive. Skip it.
             SelectedMissionTarget += 2; //@ Advance to next RedTeam Target;
             }
          }
    

    As you can see, the suggested new code includes additional logic to detect cases when overflow beyond the last mission object that can be selected attempts to select object
    "1" but the player's "MyNetworkId" is already equal to "1" (which would try to select
    his own aircraft as his target). In that case, the suggested new logic skips over object "1"
    and thereafter tries to select the next RedTeam object. Since RedTeam objects always have
    odd numbers, the next available value is "3" which is calculated by adding "2" to the "1"
    in "SelectedMissionTarget".

     

    Last edit: bbosen 2026-10-14

Log in to post a comment.