Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2003:
[Freeciv-Dev] Re: (PR#4718) topology cleanup for client autocenter code
Home

[Freeciv-Dev] Re: (PR#4718) topology cleanup for client autocenter code

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#4718) topology cleanup for client autocenter code
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 30 Jul 2003 06:14:14 -0700
Reply-to: rt@xxxxxxxxxxxxxx

rwetmore@xxxxxxxxxxxx wrote:
> Actually, the correct solution is probably even easier and certainly less
> code change impact.

So what would that correct solution be?  I looked at the most recent 
corecleanups (1yr ago) to see if you had any clever ideas, but the 
solution you use there is wrong.

Admittedly this code is not called very much and isn't particularly 
important, so it may be okay to have slightly wrong behavior in exchange 
for shorter code.  But I'm not in favor of misusing native dimensions as 
map ones; it sets a bad example.  And the logic also works the othe way: 
since the code is not particularly important it's okay to have it be a 
little bit inefficient.

      assert(punit != NULL);
      center_tile_mapcanvas(punit->x, punit->y);
    } else {
+    int  x0 = map.xsize / 2, y0 = map.ysize / 2;
+    native_to_map_pos(&x0, &y0, x0, y0);
+
      /* Just any known tile will do; search near the middle first. */
-    iterate_outward(map.xsize / 2, map.ysize / 2,
-                   MAX(map.xsize / 2, map.ysize / 2), x, y) {
+    iterate_outward(x0, y0, MAX(map.xsize / 2, map.ysize / 2), x, y) {
        if (tile_get_known(x, y) != TILE_UNKNOWN) {
        center_tile_mapcanvas(x, y);
        goto OUT;
@@ -525,13 +526,14 @@
      }
      iterate_outward_end;
      /* If we get here we didn't find a known tile.
-       Refresh a random place to clear the intro gfx. */
-    center_tile_mapcanvas(map.xsize / 2, map.ysize / 2);
+     * Refresh a random place to clear the intro gfx.
+     */
+    center_tile_mapcanvas(x0, y0);
    OUT:
      ;                         /* do nothing */
    }
  }

jason




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