@@ -860,17 +860,27 @@ void red_alert_bash_wingman_status()
860860 char prospective_name[NAME_LENGTH];
861861 int prospective_wave = Latest_wave_stored[wingnum] + 1 ; // on the first iteration, the map will return 0 so the wave will be 1
862862
863- // find the wing leader name for this wave
864- wing_bash_ship_name (prospective_name, wingp->name , ((prospective_wave - 1 ) * wingp->wave_count ) + 1 );
865-
866- // see if this wing leader was stored
867- auto it = std::find_if (Red_alert_wingman_status.begin (), Red_alert_wingman_status.end (), [&](const red_alert_ship_status &ras) -> bool
863+ // look for any ship in this wave
864+ bool found = false ;
865+ for (int pos_in_wing = 0 ; pos_in_wing < wingp->wave_count ; ++pos_in_wing)
868866 {
869- return stricmp (ras. name . c_str (), prospective_name) == 0 ;
870- } );
867+ // find the name for this wingman in this position and wave
868+ wing_bash_ship_name (prospective_name, wingp-> name , ((prospective_wave - 1 ) * wingp-> wave_count ) + pos_in_wing + 1 );
871869
872- // found?
873- if (it != Red_alert_wingman_status.end ())
870+ // see if this ship was stored
871+ auto it = std::find_if (Red_alert_wingman_status.begin (), Red_alert_wingman_status.end (), [&](const red_alert_ship_status &ras) -> bool
872+ {
873+ return stricmp (ras.name .c_str (), prospective_name) == 0 ;
874+ });
875+ if (it != Red_alert_wingman_status.end ())
876+ {
877+ found = true ;
878+ break ;
879+ }
880+ }
881+
882+ // any ship found?
883+ if (found)
874884 {
875885 Latest_wave_stored[wingnum] = prospective_wave;
876886 if (prospective_wave > 1 )
@@ -907,8 +917,9 @@ void red_alert_bash_wingman_status()
907917 int latest_wave = Latest_wave_stored[shipp->wingnum ];
908918 auto wingp = &Wings[shipp->wingnum ];
909919
910- // assign the wave number to the wing
911- wingp->current_wave = latest_wave;
920+ // assign the wave number to the wing, but only if it was stored
921+ if (latest_wave > 0 )
922+ wingp->current_wave = latest_wave;
912923
913924 if (latest_wave > 1 )
914925 {
0 commit comments