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

Too hard to merge, at least not in a few hours, as they are fairly
embedded in too many files.  Instead, added a single new function to
keep them synchronized whenever a unit is killed: goto_unit_killed().

This allowed the unit number to be replaced with a more efficient
pointer, eliminated the assert, thus simplifying the iterator.  Also,
renamed the iterator -- finding several places where the wrong iterator
was used!

Moreover, found a memory leak that occurred upon freeing at the end of
every client goto -- the pf structures in the part weren't freed.

Replaced a number of places where all that was needed was the head of the
list.  These probably need more examination (several already had FIXMEs).

Also, swapped the struct unit_order out of map.h into unit.h, where it
more properly belongs (where its enums are also).

Index: common/unit.h
===================================================================
--- common/unit.h       (revision 13898)
+++ common/unit.h       (working copy)
@@ -18,8 +18,6 @@
 #include "terrain.h"           /* enum tile_special_type */
 #include "unittype.h"
 
-struct unit_order;
-
 #define BARBARIAN_LIFE    5
 
 /* Changing this enum will break network compatability. */
@@ -114,6 +112,13 @@
   bool done;  /* we are done controlling this unit this turn */
 };
 
+struct unit_order {
+  enum unit_orders order;
+  enum unit_activity activity;  /* Only valid for ORDER_ACTIVITY. */
+  enum base_type_id base;       /* Only valid for activity ACTIVITY_BASE */
+  enum direction8 dir;          /* Only valid for ORDER_MOVE. */
+};
+
 struct unit {
   struct unit_type *utype;
   int id;
Index: common/map.h
===================================================================
--- common/map.h        (revision 13898)
+++ common/map.h        (working copy)
@@ -18,10 +18,7 @@
 
 #include "fc_types.h"
 
-#include "player.h"
-#include "terrain.h"
 #include "tile.h"
-#include "unit.h"
 
 /*
  * The value of MOVE_COST_FOR_VALID_SEA_STEP has no particular
@@ -437,13 +434,6 @@
 
 BV_DEFINE(dir_vector, 8);
 
-struct unit_order {
-  enum unit_orders order;
-  enum direction8 dir;         /* Only valid for ORDER_MOVE. */
-  enum unit_activity activity; /* Only valid for ORDER_ACTIVITY. */
-  enum base_type_id base;       /* Only valid for activity ACTVITY_BASE */
-};
-
 /* return the reverse of the direction */
 #define DIR_REVERSE(dir) (7 - (dir))
 
Index: client/control.c
===================================================================
--- client/control.c    (revision 13898)
+++ client/control.c    (working copy)
@@ -88,7 +88,7 @@
                         enum quickselect_type qtype);
 
 /**************************************************************************
-...
+  Called only by main() in client/civclient.c.
 **************************************************************************/
 void control_init(void)
 {
@@ -104,7 +104,7 @@
 }
 
 /**************************************************************************
-...
+  Called only by client_exit() in client/civclient.c.
 **************************************************************************/
 void control_done(void)
 {
@@ -126,6 +126,7 @@
 {
   int i;
 
+  goto_unit_killed(punit);
   unit_list_unlink(get_units_in_focus(), punit);
   if (get_num_units_in_focus() < 1) {
     set_hover_state(NULL, HOVER_NONE, ACTIVITY_LAST, ORDER_LAST);
@@ -211,16 +212,24 @@
 }
 
 /****************************************************************************
+  Return head of focus units list.
+****************************************************************************/
+struct unit *head_of_units_in_focus(void)
+{
+  return unit_list_get(pfocus_units, 0);
+}
+
+/****************************************************************************
   Finds a single focus unit that we can center on.  May return NULL.
 ****************************************************************************/
 static struct tile *find_a_focus_unit_tile_to_center_on(void)
 {
   struct unit *punit;
 
-  if ((punit = get_focus_unit_on_tile(get_center_tile_mapcanvas()))) {
+  if (NULL != (punit = get_focus_unit_on_tile(get_center_tile_mapcanvas()))) {
     return punit->tile;
   } else if (get_num_units_in_focus() > 0) {
-    return unit_list_get(get_units_in_focus(), 0)->tile;
+    return head_of_units_in_focus()->tile;
   } else {
     return NULL;
   }
@@ -260,7 +269,7 @@
    * battlegroup twice in a row will store the focus erronously.  The only
    * solution would be a set_units_focus() */
   if (!(get_num_units_in_focus() == 1
-       && punit == unit_list_get(get_units_in_focus(), 0))) {
+       && punit == head_of_units_in_focus())) {
     store_focus();
     focus_changed = TRUE;
   }
@@ -498,7 +507,7 @@
   }
 
   if (!get_focus_unit_on_tile(ptile)) {
-    struct unit *pfirst = unit_list_get(get_units_in_focus(), 0);
+    struct unit *pfirst = head_of_units_in_focus();
 
     if (pfirst) {
       ptile = pfirst->tile;
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
--- client/gui-gtk-2.0/gui_main.c       (revision 13898)
+++ client/gui-gtk-2.0/gui_main.c       (working copy)
@@ -894,7 +894,7 @@
   gtk_widget_hide(more_arrow_pixmap);
   set_unit_icons_more_arrow(FALSE);
   if (get_num_units_in_focus() == 1) {
-    set_unit_icon(-1, unit_list_get(get_units_in_focus(), 0));
+    set_unit_icon(-1, head_of_units_in_focus());
   } else {
     set_unit_icon(-1, NULL);
   }
Index: client/control.h
===================================================================
--- client/control.h    (revision 13898)
+++ client/control.h    (working copy)
@@ -116,6 +116,7 @@
 
 bool unit_is_in_focus(const struct unit *punit);
 struct unit *get_focus_unit_on_tile(const struct tile *ptile);
+struct unit *head_of_units_in_focus(void);
 void auto_center_on_focus_unit(void);
 void advance_unit_focus(void);
 struct unit_list *get_units_in_focus(void);
Index: client/gui-xaw/gui_main.c
===================================================================
--- client/gui-xaw/gui_main.c   (revision 13898)
+++ client/gui-xaw/gui_main.c   (working copy)
@@ -1008,7 +1008,7 @@
 
   set_unit_icons_more_arrow(FALSE);
   if (get_num_units_in_focus() == 1) {
-    set_unit_icon(-1, unit_list_get(get_units_in_focus(), 0));
+    set_unit_icon(-1, head_of_units_in_focus());
   } else {
     set_unit_icon(-1, NULL);
   }
@@ -1040,7 +1040,7 @@
   if (game.player_ptr && can_client_issue_orders()) {
     struct unit *punit;
 
-    punit = unit_list_get(get_units_in_focus(), 0);
+    punit = head_of_units_in_focus();
     if (punit && punit->battlegroup == battlegroup) {
       /* If top unit already in the same battlegroup, detach it */
       unit_change_battlegroup(punit, BATTLEGROUP_NONE);
Index: client/gui-win32/gotodlg.c
===================================================================
--- client/gui-win32/gotodlg.c  (revision 13898)
+++ client/gui-win32/gotodlg.c  (working copy)
@@ -80,8 +80,8 @@
       switch(LOWORD(wParam))
        {
        case ID_LIST:
-         if((pdestcity=get_selected_city())) {
-           struct unit *punit=unit_list_get(get_units_in_focus(), 0);
+         if (NULL != (pdestcity=get_selected_city())) {
+           struct unit *punit = head_of_units_in_focus();
            center_tile_mapcanvas(pdestcity->tile);
            if(punit && unit_can_airlift_to(punit, pdestcity)) {
              EnableWindow(GetDlgItem(dlg,ID_AIRLIFT),TRUE);
Index: client/gui-win32/menu.c
===================================================================
--- client/gui-win32/menu.c     (revision 13898)
+++ client/gui-win32/menu.c     (working copy)
@@ -1103,7 +1103,7 @@
       return;
     }
 
-    if ((punit = unit_list_get(get_units_in_focus(), 0))) {
+    if (NULL != (punit = head_of_units_in_focus())) {
       const char *irrfmt = _("Change to %s");
       const char *minfmt = _("Change to %s");
       const char *transfmt = _("Transform to %s");
Index: client/goto.c
===================================================================
--- client/goto.c       (revision 13898)
+++ client/goto.c       (working copy)
@@ -38,20 +38,6 @@
 #define PATH_LOG_LEVEL          LOG_DEBUG
 #define PACKET_LOG_LEVEL        LOG_DEBUG
 
-/*
- * The whole path is separated by waypoints into parts.  Each part has its
- * own starting position and requires its own map.  When the unit is unable
- * to move, end_tile equals start_tile.
- */
-struct part {
-  int start_moves_left, start_fuel_left;
-  struct tile *start_tile, *end_tile;
-  int end_moves_left, end_fuel_left;
-  int time;
-  struct pf_path *path;
-  struct pf_map *map;
-};
-
 /* For each tile and each direction we store the number of lines going out 
  * of the tile in this direction.  Since each line is undirected, we only 
  * store the 4 lower-numbered directions for each tile; the 4 upper-numbered
@@ -67,10 +53,24 @@
 };
 static struct goto_tiles *tiles = NULL;
 
+/*
+ * The whole path is separated by waypoints into parts.  Each part has its
+ * own starting position and requires its own map.  When the unit is unable
+ * to move, end_tile equals start_tile.
+ */
+struct part {
+  int start_moves_left, start_fuel_left;
+  struct tile *start_tile, *end_tile;
+  int end_moves_left, end_fuel_left;
+  int time;
+  struct pf_path *path;
+  struct pf_map *map;
+};
+
 struct goto_map {
+  struct unit *focus;
   struct part *parts;
   int num_parts;
-  int unit_id;                  /* One of the hover_units */
   int connect_initial;
   int connect_speed;
   struct pf_parameter template;
@@ -86,17 +86,11 @@
   LIST_ITERATE_END
 
 /* Iterate over goto maps, filtering out dead units. */
-#define goto_map_iterate(gotolist, pgoto, punit)                           \
+#define goto_map_unit_iterate(gotolist, pgoto, punit)                      \
   goto_map_list_iterate(gotolist, pgoto) {                                 \
-    struct unit *punit = game_find_unit_by_number(pgoto->unit_id);         \
-                                                                           \
-    if (punit) {                                                           \
-      assert(unit_is_in_focus(punit));                                     \
-      {
+    struct unit *punit = pgoto->focus;
 
-#define goto_map_iterate_end                                               \
-      }                                                                        
    \
-    }                                                                      \
+#define goto_map_unit_iterate_end                                          \
   } goto_map_list_iterate_end;
 
 static struct goto_map_list *goto_maps = NULL;
@@ -106,6 +100,7 @@
 static void increment_drawn(struct tile *src_tile, enum direction8 dir);
 static void decrement_drawn(struct tile *src_tile, enum direction8 dir);
 static void reset_last_part(struct goto_map *goto_map);
+static void remove_last_part(struct goto_map *goto_map);
 
 
 /**************************************************************************
@@ -120,7 +115,7 @@
 {
   struct goto_map *goto_map = fc_malloc(sizeof(*goto_map));
 
-  goto_map->unit_id = -1;
+  goto_map->focus = NULL;
   goto_map->parts = NULL;
   goto_map->num_parts = 0;
   goto_map->connect_initial = 0;
@@ -134,7 +129,10 @@
 ****************************************************************************/
 static void goto_map_free(struct goto_map *goto_map)
 {
-  if (goto_map->parts) {
+  if (NULL != goto_map->parts) {
+    while (goto_map->num_parts > 0) {
+      remove_last_part(goto_map);
+    }
     free(goto_map->parts);
   }
   free(goto_map);
@@ -296,7 +294,7 @@
 {
   struct part *p;
   struct pf_parameter parameter = goto_map->template;
-  struct unit *punit = game_find_unit_by_number(goto_map->unit_id);
+  struct unit *punit = goto_map->focus;
 
   if (!punit) {
     return;
@@ -360,7 +358,7 @@
     return FALSE;
   }
 
-  goto_map_iterate(goto_maps, goto_map, punit) {
+  goto_map_list_iterate(goto_maps, goto_map) {
     struct part *first_part = &goto_map->parts[0];
     struct part *last_part = &goto_map->parts[goto_map->num_parts - 1];
 
@@ -373,11 +371,11 @@
       /* Scattered group (not all in same location). */
       return FALSE;
     }
-  } goto_map_iterate_end;
+  } goto_map_list_iterate_end;
 
-  goto_map_iterate(goto_maps, goto_map, punit) {
+  goto_map_list_iterate(goto_maps, goto_map) {
     add_part(goto_map);
-  } goto_map_iterate_end;
+  } goto_map_list_iterate_end;
   return TRUE;
 }
 
@@ -390,7 +388,7 @@
   bool popped = FALSE;
 
   assert(goto_is_active());
-  goto_map_iterate(goto_maps, goto_map, punit) {
+  goto_map_list_iterate(goto_maps, goto_map) {
     struct part *p = &goto_map->parts[goto_map->num_parts - 1];
     struct tile *end_tile = p->end_tile;
 
@@ -408,7 +406,7 @@
      * the mouse position. 
      */
     update_last_part(goto_map, end_tile);
-  } goto_map_iterate_end;
+  } goto_map_list_iterate_end;
   return popped;
 }
 
@@ -812,7 +810,7 @@
   unit_list_iterate(punits, punit) {
     struct goto_map *goto_map = goto_map_new();
 
-    goto_map->unit_id = punit->id;
+    goto_map->focus = punit;
 
     fill_client_goto_parameter(punit, &goto_map->template,
                                &goto_map->connect_initial,
@@ -834,9 +832,6 @@
   }
 
   goto_map_list_iterate(goto_maps, goto_map) {
-    while (goto_map->num_parts > 0) {
-      remove_last_part(goto_map);
-    }
     goto_map_free(goto_map);
   } goto_map_list_iterate_end;
   goto_map_list_unlink_all(goto_maps);
@@ -845,6 +840,27 @@
 }
 
 /********************************************************************** 
+  Called from control_unit_killed() in control.c
+***********************************************************************/
+void goto_unit_killed(struct unit *punit)
+{
+  if (!goto_is_active()) {
+    return;
+  }
+
+  goto_map_unit_iterate(goto_maps, goto_map, ptest) {
+    if (ptest == punit) {
+      goto_map_free(goto_map);
+      /* Still safe using goto_map pointer, as it is not used for 
+       * dereferencing, only as value. */
+      goto_map_list_unlink(goto_maps, goto_map);
+      /* stop now, links are gone! */
+      break;
+    }
+  } goto_map_unit_iterate_end;
+}
+
+/********************************************************************** 
   Is goto state active?
 ***********************************************************************/
 bool goto_is_active(void)
@@ -872,7 +888,7 @@
     return FALSE;
   }
 
-  goto_map_iterate(goto_maps, goto_map, punit) {
+  goto_map_list_iterate(goto_maps, goto_map) {
     int i, time = 0;
 
     for (i = 0; i < goto_map->num_parts; i++) {
@@ -885,7 +901,7 @@
     if (max) {
       *max = MAX(*max, time);
     }
-  } goto_map_iterate_end;
+  } goto_map_list_iterate_end;
   return TRUE;
 }
 
@@ -904,11 +920,11 @@
   /* assume valid destination */
   goto_destination = dest_tile;
 
-  goto_map_iterate(goto_maps, goto_map, punit) {
+  goto_map_list_iterate(goto_maps, goto_map) {
     if (!update_last_part(goto_map, dest_tile)) {
       goto_destination = NULL;
     }
-  } goto_map_iterate_end;
+  } goto_map_list_iterate_end;
 
   /* Update goto data in info label. */
   update_unit_info_label(get_units_in_focus());
@@ -1047,7 +1063,7 @@
 void send_patrol_route(void)
 {
   assert(goto_is_active());
-  goto_map_iterate(goto_maps, goto_map, punit) {
+  goto_map_unit_iterate(goto_maps, goto_map, punit) {
     int i;
     struct pf_map *map;
     struct pf_path *return_path;
@@ -1080,7 +1096,7 @@
     send_path_orders(punit, path, TRUE, TRUE, NULL);
 
     pf_destroy_path(path);
-  } goto_map_iterate_end;
+  } goto_map_unit_iterate_end;
 }
 
 /**************************************************************************
@@ -1090,7 +1106,7 @@
 void send_connect_route(enum unit_activity activity)
 {
   assert(goto_is_active());
-  goto_map_iterate(goto_maps, goto_map, punit) {
+  goto_map_unit_iterate(goto_maps, goto_map, punit) {
     int i;
     struct packet_unit_orders p;
     struct tile *old_tile;
@@ -1166,7 +1182,7 @@
     p.dest_y = old_tile->y;
 
     send_packet_unit_orders(&aconnection, &p);
-  } goto_map_iterate_end;
+  } goto_map_unit_iterate_end;
 }
 
 /**************************************************************************
@@ -1177,7 +1193,7 @@
 void send_goto_route(void)
 {
   assert(goto_is_active());
-  goto_map_iterate(goto_maps, goto_map, punit) {
+  goto_map_unit_iterate(goto_maps, goto_map, punit) {
     int i;
     struct pf_path *path = NULL;
     struct part *last_part = &goto_map->parts[goto_map->num_parts - 1];
@@ -1200,7 +1216,7 @@
       send_goto_path(punit, path, &order);
     }
     pf_destroy_path(path);
-  } goto_map_iterate_end;
+  } goto_map_unit_iterate_end;
 }
 
 /* ================= drawn functions ============================ */
Index: client/goto.h
===================================================================
--- client/goto.h       (revision 13898)
+++ client/goto.h       (working copy)
@@ -19,9 +19,12 @@
 
 void init_client_goto(void);
 void free_client_goto(void);
+
 void enter_goto_state(struct unit_list *punits);
 void exit_goto_state(void);
 
+void goto_unit_killed(struct unit *punit);
+
 bool goto_is_active(void);
 bool goto_get_turns(int *min, int *max);
 bool goto_add_waypoint(void);
Index: client/gui-sdl/gotodlg.c
===================================================================
--- client/gui-sdl/gotodlg.c    (revision 13898)
+++ client/gui-sdl/gotodlg.c    (working copy)
@@ -82,7 +82,7 @@
     struct city *pDestcity = game_find_city_by_number(MAX_ID - pWidget->ID);
   
     if (pDestcity) {
-      struct unit *pUnit = unit_list_get(get_units_in_focus(), 0);
+      struct unit *pUnit = head_of_units_in_focus();
       if (pUnit) {
         if(GOTO) {
           send_goto_tile(pUnit, pDestcity->tile);
@@ -358,7 +358,7 @@
 **************************************************************************/
 void popup_goto_dialog(void)
 {
-  if (!can_client_issue_orders() || !unit_list_get(get_units_in_focus(), 0)) {
+  if (!can_client_issue_orders() || 0 == get_num_units_in_focus()) {
     return;
   }
   all_players = (1u << (player_index(game.player_ptr)));
@@ -370,7 +370,7 @@
 **************************************************************************/
 void popup_airlift_dialog(void)
 {
-  if (!can_client_issue_orders() || !unit_list_get(get_units_in_focus(), 0)) {
+  if (!can_client_issue_orders() || 0 == get_num_units_in_focus()) {
     return;
   }
   all_players = (1u << (player_index(game.player_ptr)));
Index: client/gui-sdl/gui_main.c
===================================================================
--- client/gui-sdl/gui_main.c   (revision 13898)
+++ client/gui-sdl/gui_main.c   (working copy)
@@ -259,7 +259,7 @@
             } else {              
               struct unit *pUnit;
               struct city *pCity;
-              if((pUnit = unit_list_get(get_units_in_focus(), 0)) != NULL && 
+              if (NULL != (pUnit = head_of_units_in_focus()) && 
                 (pCity = pUnit->tile->city) != NULL &&
                 city_owner(pCity) == game.player_ptr) {
                 popup_city_dialog(pCity);
Index: client/gui-sdl/menu.c
===================================================================
--- client/gui-sdl/menu.c       (revision 13898)
+++ client/gui-sdl/menu.c       (working copy)
@@ -79,7 +79,7 @@
 static int unit_order_callback(struct widget *pOrder_Widget)
 {
   if (Main.event.button.button == SDL_BUTTON_LEFT) {
-    struct unit *pUnit = unit_list_get(get_units_in_focus(), 0);
+    struct unit *pUnit = head_of_units_in_focus();
   
     set_wstate(pOrder_Widget, FC_WS_SELLECTED);
     pSellected_Widget = pOrder_Widget;
Index: client/gui-sdl/dialogs.c
===================================================================
--- client/gui-sdl/dialogs.c    (revision 13898)
+++ client/gui-sdl/dialogs.c    (working copy)
@@ -607,7 +607,7 @@
 {
   struct widget *pBuf = NULL, *pWindow;
   SDL_String16 *pStr;
-  struct unit *pUnit = NULL, *pFocus = unit_list_get(get_units_in_focus(), 0);
+  struct unit *pUnit = NULL, *pFocus = head_of_units_in_focus();
   struct unit_type *pUnitType;
   char cBuf[255];  
   int i, w = 0, n;
@@ -1078,7 +1078,7 @@
     popdown_advanced_terrain_dialog();
     
     /* may not work */
-    send_goto_tile(unit_list_get(get_units_in_focus(), 0), map_pos_to_tile(x, 
y));
+    send_goto_tile(head_of_units_in_focus(), map_pos_to_tile(x, y));
   }
   return -1;
 }
@@ -1094,7 +1094,7 @@
 #if 0    
     int x = pWidget->data.cont->id0;
     int y = pWidget->data.cont->id1;
-    struct unit *pUnit = unit_list_get(get_units_in_focus(), 0);
+    struct unit *pUnit = head_of_units_in_focus();
 #endif
 
     popdown_advanced_terrain_dialog();
@@ -1170,7 +1170,7 @@
   
   pCity = ptile->city;
   n = unit_list_size(ptile->units);
-  pFocus_Unit = unit_list_get(get_units_in_focus(), 0);
+  pFocus_Unit = head_of_units_in_focus();
   
   if (!n && !pCity && !pFocus_Unit)
   {
Index: client/gui-sdl/diplomat_dialog.c
===================================================================
--- client/gui-sdl/diplomat_dialog.c    (revision 13898)
+++ client/gui-sdl/diplomat_dialog.c    (working copy)
@@ -786,7 +786,7 @@
 {
   struct widget *pWindow = NULL, *pBuf = NULL , *pLast = NULL;
   struct CONTAINER *pCont;
-  struct unit *pUnit = unit_list_get(get_units_in_focus(), 0);
+  struct unit *pUnit = head_of_units_in_focus();
   SDL_String16 *pStr;
   SDL_Rect area, area2;
   int n, w = 0, h, imp_h = 0;
@@ -1082,7 +1082,7 @@
   }
   
   /* ugly hack */
-  pUnit = unit_list_get(get_units_in_focus(), 0);
+  pUnit = head_of_units_in_focus();
   
   if (!pUnit || !is_diplomat_unit(pUnit)) {
     return;
@@ -1323,7 +1323,7 @@
   }
     
   /* ugly hack */
-  pDiplomatUnit = unit_list_get(get_units_in_focus(), 0);
+  pDiplomatUnit = head_of_units_in_focus();
   
   if (!pDiplomatUnit || !is_diplomat_unit(pDiplomatUnit)) {
     return;
Index: client/gui-sdl/mapctrl.c
===================================================================
--- client/gui-sdl/mapctrl.c    (revision 13898)
+++ client/gui-sdl/mapctrl.c    (working copy)
@@ -360,7 +360,7 @@
 static int toggle_map_window_callback(struct widget *pMap_Button)
 {
   if (Main.event.button.button == SDL_BUTTON_LEFT) {
-    struct unit *pFocus = unit_list_get(get_units_in_focus(), 0);
+    struct unit *pFocus = head_of_units_in_focus();
     struct widget *pWidget;
       
     /* make new map icon */
Index: client/gui-ftwl/gotodlg.c
===================================================================
--- client/gui-ftwl/gotodlg.c   (revision 13898)
+++ client/gui-ftwl/gotodlg.c   (working copy)
@@ -30,7 +30,7 @@
   if (get_client_state() != CLIENT_GAME_RUNNING_STATE) {
     return;
   }
-  if (!get_units_in_focus()) {
+  if (0 == get_num_units_in_focus()) {
     return;
   }
   /* PORTME */
Index: client/gui-ftwl/gui_text.c
===================================================================
--- client/gui-ftwl/gui_text.c  (revision 13898)
+++ client/gui-ftwl/gui_text.c  (working copy)
@@ -430,7 +430,7 @@
     add_line(_("Unit: %s(%s%s)"), utype_name_translation(ptype),
             nation_name_translation(nation_of_unit(punit)), tmp);
     if (player_number(punit->owner) != game.info.player_idx) {
-      struct unit *apunit = unit_list_get(get_units_in_focus(), 0);
+      struct unit *apunit = head_of_units_in_focus();  /* FIXME, need best in 
stack */
 
       if (apunit) {
        /* chance to win when active unit is attacking the selected unit */
Index: client/climap.h
===================================================================
--- client/climap.h     (revision 13898)
+++ client/climap.h     (working copy)
@@ -14,7 +14,7 @@
 #ifndef FC__CLIMAP_H
 #define FC__CLIMAP_H
 
-#include "map.h"                /* enum direction8 */
+#include "fc_types.h"           /* enum direction8, struct tile */
 #include "terrain.h"            /* enum known_type */
 
 #define map_exists() (map.tiles != NULL)
Index: client/climisc.c
===================================================================
--- client/climisc.c    (revision 13898)
+++ client/climisc.c    (working copy)
@@ -379,7 +379,7 @@
 
   can_slide = FALSE;
   if (get_num_units_in_focus() > 0) {
-    center_tile_mapcanvas(unit_list_get(get_units_in_focus(), 0)->tile);
+    center_tile_mapcanvas(head_of_units_in_focus()->tile);
   } else if (game.player_ptr && (pcity = find_palace(game.player_ptr))) {
     /* Else focus on the capital. */
     center_tile_mapcanvas(pcity->tile);
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to