Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2005:
[Freeciv-Dev] Re: (PR#13773) Improved cursors
Home

[Freeciv-Dev] Re: (PR#13773) Improved cursors

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#13773) Improved cursors
From: "Andreas Røsdal" <andrearo@xxxxxxxxxxxx>
Date: Mon, 12 Dec 2005 09:56:05 -0800
Reply-to: bugs@xxxxxxxxxxx

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

On Sat, 10 Dec 2005, Jason Short wrote:
> For valid_goto_dest, the problem is that we are unnecessarily doing the
> PF lookup a second (or more) times.  When we're in the goto hover state
> and the mouse moves over a tile, the PF search is already done inside
> update_last_part and is then duplicated inside
> is_valid_goto_destination.  This would be easy to fix except that
> is_valid_goto_destination is called _before_ update_last_part.

This fix should remove the duplicated PF search.

Andreas R.
diff -ruN -X freeciv-fixed/diff_ignore freeciv-svn-Dec-11/client/control.c 
freeciv-fixed/client/control.c
--- freeciv-svn-Dec-11/client/control.c 2005-12-11 00:01:46.000000000 +0100
+++ freeciv-fixed/client/control.c      2005-12-12 18:42:31.000000000 +0100
@@ -685,9 +685,9 @@
 
   if (hover_state != HOVER_GOTO) {
     set_hover_state(punit, HOVER_GOTO, ACTIVITY_LAST, last_order);
-    handle_mouse_cursor(NULL);
     enter_goto_state(punit);
     create_line_at_mouse_pos();
+    handle_mouse_cursor(NULL);
   } else {
     assert(goto_is_active());
     goto_add_waypoint();
diff -ruN -X freeciv-fixed/diff_ignore freeciv-svn-Dec-11/client/goto.c 
freeciv-fixed/client/goto.c
--- freeciv-svn-Dec-11/client/goto.c    2005-12-11 00:01:46.000000000 +0100
+++ freeciv-fixed/client/goto.c 2005-12-12 18:51:15.000000000 +0100
@@ -81,6 +81,7 @@
 **************************************************************************/
 static bool is_active = FALSE;
 static bool is_init = FALSE;
+static bool is_goto_valid = FALSE;
 static int connect_initial;
 
 /********************************************************************** 
@@ -125,27 +126,10 @@
 
 /**********************************************************************
   Determines if a goto to the destination tile is allowed.
-
-  FIXME: This requires a duplicate and unnecessary PF search, since when
-  we're in hover mode the search is already done once when calculating
-  how to draw the map...then we do it again here.
 ***********************************************************************/
 bool is_valid_goto_destination(struct tile *ptile) 
 {
-  struct part *p = &goto_map.parts[goto_map.num_parts - 1];
-  struct pf_path *new_path;
-
-  if (!goto_is_active()) {
-    return FALSE;
-  } 
-
-  new_path = pf_get_path(p->map, ptile);
-
-  if (new_path) {
-    return TRUE;
-  } else {
-    return FALSE;
-  }
+  return is_goto_valid;
 }
 
 /********************************************************************** 
@@ -163,6 +147,8 @@
           TILE_XY(ptile), TILE_XY(p->start_tile), TILE_XY(p->end_tile));
   new_path = pf_get_path(p->map, ptile);
 
+  is_goto_valid = (new_path != NULL);
+
   if (!new_path) {
     freelog(PATH_LOG_LEVEL, "  no path found");
     reset_last_part();

[Prev in Thread] Current Thread [Next in Thread]