@@ -295,14 +295,15 @@ static void resolve_network_quit_outcome(struct PlayerInfo *player)
295295 set_player_as_won_level (player );
296296}
297297
298- static TbBool network_has_connected_enemies_to_defeat (void )
298+ static TbBool network_has_enemies_to_defeat (void )
299299{
300300 struct PlayerInfo * myplyr = get_my_player ();
301301 for (int i = 0 ; i < PLAYERS_COUNT ; i ++ ) {
302302 struct PlayerInfo * player = get_player (i );
303- if (player_exists (player ) && !is_my_player (player ) && player -> is_active == 1 && (player -> allocflags & PlaF_CompCtrl ) == 0
304- && !player_cannot_win (player -> id_number ) && network_player_active (player -> packet_num )
305- && players_are_enemies (myplyr -> id_number , player -> id_number )) {
303+ TbBool is_active_enemy = player_exists (player ) && !is_my_player (player ) && player -> is_active == 1 && !player_cannot_win (player -> id_number ) && players_are_enemies (myplyr -> id_number , player -> id_number );
304+ TbBool is_connected_network_player = (player -> allocflags & PlaF_CompCtrl ) == 0 && network_player_active (player -> packet_num );
305+ TbBool is_initial_computer_player = (player -> allocflags & PlaF_CompCtrl ) != 0 && i >= game .active_players_count ;
306+ if (is_active_enemy && (is_connected_network_player || is_initial_computer_player )) {
306307 return true;
307308 }
308309 }
@@ -391,7 +392,7 @@ void process_quit_packet(struct PlayerInfo *player, short complete_quit)
391392 return ;
392393 }
393394 }
394- TbBool has_enemies_to_defeat = network_has_connected_enemies_to_defeat ();
395+ TbBool has_enemies_to_defeat = network_has_enemies_to_defeat ();
395396 if (has_enemies_to_defeat && replaced_with_ai ) {
396397 return ;
397398 }
@@ -461,17 +462,22 @@ void process_disconnected_network_players(void)
461462 }
462463 }
463464
464- if (!disconnected || (!host_disconnected && network_has_connected_enemies_to_defeat ())) {
465+ TbBool has_enemies_to_defeat = network_has_enemies_to_defeat ();
466+ if (!disconnected || (!host_disconnected && has_enemies_to_defeat )) {
465467 return ;
466468 }
469+ if (host_disconnected ) {
470+ message_add (MsgType_Blank , 0 , get_string (GUIStr_NetHostConnectionLost ));
471+ if (has_enemies_to_defeat ) {
472+ stop_network_game_and_continue_locally ();
473+ return ;
474+ }
475+ }
467476 struct PlayerInfo * myplyr = get_my_player ();
468477 resolve_network_quit_outcome (myplyr );
469478 if (!host_disconnected && network_has_connected_remote_users ()) {
470479 return ;
471480 }
472- if (host_disconnected ) {
473- message_add (MsgType_Blank , 0 , get_string (GUIStr_NetHostConnectionLost ));
474- }
475481 if (myplyr -> victory_state != VicS_Undecided ) {
476482 stop_network_game_and_continue_locally ();
477483 } else {
0 commit comments