<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39609 >

Committed trunk revision 13639.

Index: client/control.c
===================================================================
--- client/control.c    (revision 13638)
+++ client/control.c    (working copy)
@@ -59,7 +59,6 @@
 static struct unit_list *previous_focus;
 
 /* These should be set via set_hover_state() */
-struct unit_list *hover_units;
 enum cursor_hover_state hover_state = HOVER_NONE;
 struct tile *hover_tile = NULL;
 enum unit_activity connect_activity;
@@ -97,7 +96,6 @@
 
   caravan_arrival_queue = genlist_new();
   diplomat_arrival_queue = genlist_new();
-  hover_units = unit_list_new();
   pfocus_units = unit_list_new();
   previous_focus = unit_list_new();
   for (i = 0; i < MAX_NUM_BATTLEGROUPS; i++) {
@@ -114,7 +112,6 @@
 
   genlist_free(caravan_arrival_queue);
   genlist_free(diplomat_arrival_queue);
-  unit_list_free(hover_units);
   unit_list_free(pfocus_units);
   unit_list_free(previous_focus);
   for (i = 0; i < MAX_NUM_BATTLEGROUPS; i++) {
@@ -130,7 +127,10 @@
   int i;
 
   unit_list_unlink(get_units_in_focus(), punit);
-  unit_list_unlink(hover_units, punit);
+  if (get_num_units_in_focus() < 1) {
+    set_hover_state(NULL, HOVER_NONE, ACTIVITY_LAST, ORDER_LAST);
+  }
+  update_unit_info_label(get_units_in_focus());
   unit_list_unlink(previous_focus, punit);
   for (i = 0; i < MAX_NUM_BATTLEGROUPS; i++) {
     unit_list_unlink(battlegroups[i], punit);
@@ -182,12 +182,6 @@
   assert((punits && unit_list_size(punits) > 0) || state == HOVER_NONE);
   assert(state == HOVER_CONNECT || activity == ACTIVITY_LAST);
   assert(state == HOVER_GOTO || order == ORDER_LAST);
-  unit_list_unlink_all(hover_units);
-  if (punits) {
-    unit_list_iterate(punits, punit) {
-      unit_list_append(hover_units, punit);
-    } unit_list_iterate_end;
-  }
   hover_state = state;
   connect_activity = activity;
   goto_last_order = order;
@@ -1893,12 +1887,12 @@
 void do_map_click(struct tile *ptile, enum quickselect_type qtype)
 {
   struct city *pcity = tile_get_city(ptile);
-  struct unit_list *punits = hover_units;
+  struct unit_list *punits = get_units_in_focus();
   bool maybe_goto = FALSE;
   bool possible = FALSE;
   struct tile *offender = NULL;
 
-  if (unit_list_size(punits) > 0 && hover_state != HOVER_NONE) {
+  if (hover_state != HOVER_NONE) {
     switch (hover_state) {
     case HOVER_NONE:
       die("well; shouldn't get here :)");
@@ -2112,7 +2106,7 @@
 }
 
 /**************************************************************************
- Finish the goto mode and let the units stored in hover_units move
+ Finish the goto mode and let the units stored in goto_map_list move
  to a given location.
 **************************************************************************/
 void do_unit_goto(struct tile *ptile)
@@ -2182,27 +2176,24 @@
 **************************************************************************/
 void key_cancel_action(void)
 {
-  bool popped = FALSE;
-
   cancel_tile_hiliting();
 
   switch (hover_state) {
   case HOVER_GOTO:
   case HOVER_PATROL:
   case HOVER_CONNECT:
-    popped = goto_pop_waypoint();
+    if (!goto_pop_waypoint()) {
+      set_hover_state(NULL, HOVER_NONE, ACTIVITY_LAST, ORDER_LAST);
+      update_unit_info_label(get_units_in_focus());
+
+      keyboardless_goto_button_down = FALSE;
+      keyboardless_goto_active = FALSE;
+      keyboardless_goto_start_tile = NULL;
+    }
+    break;
   default:
     break;
   };
-
-  if (hover_state != HOVER_NONE && !popped) {
-    set_hover_state(NULL, HOVER_NONE, ACTIVITY_LAST, ORDER_LAST);
-    update_unit_info_label(hover_units);
-
-    keyboardless_goto_button_down = FALSE;
-    keyboardless_goto_active = FALSE;
-    keyboardless_goto_start_tile = NULL;
-  }
 }
 
 /**************************************************************************
Index: client/gui-gtk-2.0/mapctrl.c
===================================================================
--- client/gui-gtk-2.0/mapctrl.c        (revision 13638)
+++ client/gui-gtk-2.0/mapctrl.c        (working copy)
@@ -395,7 +395,6 @@
 **************************************************************************/
 gboolean leave_mapcanvas(GtkWidget *widget, GdkEventCrossing *event)
 {
-  struct unit_list *active_units = get_units_in_focus();
   int canvas_x, canvas_y;
 
   if (gtk_notebook_get_current_page(GTK_NOTEBOOK(top_notebook))
@@ -417,7 +416,7 @@
     update_mouse_cursor(CURSOR_DEFAULT);
   }
 
-  update_unit_info_label(active_units);
+  update_unit_info_label(get_units_in_focus());
   return TRUE;
 }
 
Index: client/text.c
===================================================================
--- client/text.c       (revision 13638)
+++ client/text.c       (working copy)
@@ -699,7 +699,7 @@
    * itself. */
 
   /* Line 1. Goto or activity text. */
-  if (count > 0 && unit_list_size(hover_units) > 0) {
+  if (count > 0 && hover_state != HOVER_NONE) {
     int min, max;
 
     if (!goto_get_turns(&min, &max)) {
Index: client/control.h
===================================================================
--- client/control.h    (revision 13638)
+++ client/control.h    (working copy)
@@ -37,7 +37,6 @@
 void unit_change_battlegroup(struct unit *punit, int battlegroup);
 void unit_register_battlegroup(struct unit *punit);
 
-extern struct unit_list *hover_units; /* unit hover_state applies to */
 extern enum cursor_hover_state hover_state;
 extern enum unit_activity connect_activity;
 extern enum unit_orders goto_last_order;
Index: client/gui-xaw/mapview.c
===================================================================
--- client/gui-xaw/mapview.c    (revision 13638)
+++ client/gui-xaw/mapview.c    (working copy)
@@ -212,23 +212,6 @@
   xaw_set_label(unit_info_label, buffer);
 
   if (unit_list_size(punitlist) > 0) {
-#if 0 /* Somebody sures this hack is not needed */
-    if (unit_list_size(hover_units) > 0) {
-      bool is_hover = FALSE;
-
-      unit_list_iterate(hover_units, punit2) {
-       if (hover_unit != punit->id) {
-         is_hover = TRUE;
-         break;
-       }
-      } unit_list_iterate_end;
-
-      if (!is_hover) {
-       set_hover_state(NULL, HOVER_NONE, ACTIVITY_LAST, ORDER_LAST);
-      }
-    }
-#endif
-
     switch (hover_state) {
     case HOVER_NONE:
       XUndefineCursor(display, XtWindow(map_canvas));
Index: client/mapctrl_common.c
===================================================================
--- client/mapctrl_common.c     (revision 13638)
+++ client/mapctrl_common.c     (working copy)
@@ -472,7 +472,7 @@
   if (keyboardless_goto_active && hover_state == HOVER_GOTO && ptile) {
     do_unit_goto(ptile);
     set_hover_state(NULL, HOVER_NONE, ACTIVITY_LAST, ORDER_LAST);
-    update_unit_info_label(hover_units);
+    update_unit_info_label(get_units_in_focus());
   }
   keyboardless_goto_active = FALSE;
   keyboardless_goto_button_down = FALSE;
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to