Index: client/control.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/control.c,v retrieving revision 1.84 diff -u -r1.84 control.c --- client/control.c 2002/09/11 17:04:39 1.84 +++ client/control.c 2002/10/31 17:07:47 @@ -57,6 +57,9 @@ static struct unit *punit_attacking = NULL; static struct unit *punit_defending = NULL; +/* this variable is TRUE iff a NON-AI controlled unit moved this turn */ +bool non_ai_unit_focus; + /*************************************************************************/ static struct unit *find_best_focus_candidate(void); @@ -214,11 +217,18 @@ set_unit_focus(punit_focus); + /* A unit moved, was it a good enough condition for auto end turn + * once no more units can be moved? */ + if (punit_old_focus && !punit_old_focus->ai.control) { + non_ai_unit_focus = TRUE; + } + /* Handle auto-turn-done mode: If a unit was in focus (did move), * but now none are (no more to move), then fake a Turn Done keypress. */ - if(auto_turn_done && punit_old_focus && !punit_focus) + if (auto_turn_done && punit_old_focus && !punit_focus && non_ai_unit_focus) { key_end_turn(); + } } /************************************************************************** Index: client/control.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/control.h,v retrieving revision 1.28 diff -u -r1.28 control.h --- client/control.h 2002/03/17 09:11:51 1.28 +++ client/control.h 2002/10/31 17:07:47 @@ -27,6 +27,7 @@ extern int hover_unit; /* unit hover_state applies to */ extern enum cursor_hover_state hover_state; extern bool draw_goto_line; +extern bool non_ai_unit_focus; void do_move_unit(struct unit *punit, struct packet_unit_info *pinfo); void do_unit_goto(int x, int y); Index: client/packhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v retrieving revision 1.256 diff -u -r1.256 packhand.c --- client/packhand.c 2002/09/23 22:47:09 1.256 +++ client/packhand.c 2002/10/31 17:07:47 @@ -700,6 +700,7 @@ void handle_start_turn(void) { agents_start_turn(); + non_ai_unit_focus = FALSE; turn_done_sent = FALSE; update_turn_done_button_state(); @@ -840,6 +841,7 @@ if(punit) { int dest_x,dest_y; punit->activity_count = packet->activity_count; + punit->ai.control = packet->ai; /* needed below */ if((punit->activity!=packet->activity) /* change activity */ || (punit->activity_target!=packet->activity_target)) { /* or act's target */ repaint_unit = TRUE; @@ -894,7 +896,6 @@ } } if (punit->ai.control!=packet->ai) { - punit->ai.control=packet->ai; repaint_unit = TRUE; } Index: server/unithand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v retrieving revision 1.235 diff -u -r1.235 unithand.c --- server/unithand.c 2002/10/28 17:06:12 1.235 +++ server/unithand.c 2002/10/31 17:07:47 @@ -1191,13 +1191,16 @@ } break; case ACTIVITY_EXPLORE: + punit->ai.control = TRUE; if (punit->moves_left > 0) { int id = punit->id; bool more_to_explore = ai_manage_explorer(punit); /* ai_manage_explorer sets the activity to idle, so we reset it */ - if (more_to_explore && (punit = find_unit_by_id(id))) { + if ((punit = find_unit_by_id(id)) && more_to_explore) { set_unit_activity(punit, ACTIVITY_EXPLORE); send_unit_info(NULL, punit); + } else if (punit) { + punit->ai.control = FALSE; } } break;