Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#12354) move red-frame-tile into tilespec
Home

[Freeciv-Dev] (PR#12354) move red-frame-tile into tilespec

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12354) move red-frame-tile into tilespec
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 25 Feb 2005 12:13:30 -0800
Reply-to: bugs@xxxxxxxxxxx

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

This patch adds the red frame tile as an "unavailable" sprite in the 
tileset, instead of having it drawn automatically by the mapview code.

This will make for simpler code in the long run, because the really-ugly 
boundary drawing code can be removed.  It fixes an updating bug in the 
citydlg because the new code doesn't drawn worked-by-other-cities tiles 
as worked.  It is the first example of grid sprites actually being 
useful, as the iso-view frame tile is pixel-perfect (quite unlike the 
old boundary drawing code).  And it will allow different-sized tilesets 
to have larger or smaller frames.

For the moment the mapview frame-tile drawing code is left in place, 
since it's needed by isophex.  As soon as I bring isophex up-to-date and 
  make a frame tile for it we can drop this code (then tilesets without 
this sprite will still work, until we make it manditory, but won't draw 
anything here).

-jason

Index: client/citydlg_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/citydlg_common.c,v
retrieving revision 1.62
diff -u -r1.62 citydlg_common.c
--- client/citydlg_common.c     24 Feb 2005 01:56:40 -0000      1.62
+++ client/citydlg_common.c     25 Feb 2005 20:04:37 -0000
@@ -203,7 +203,8 @@
        put_city_tile_output(pcity, city_x, city_y,
                             pcanvas, canvas_x, canvas_y);
       }
-      if (pcity->city_map[city_x][city_y] == C_TILE_UNAVAILABLE) {
+      if (!sprites.grid.main[EDGE_NS]
+         && pcity->city_map[city_x][city_y] == C_TILE_UNAVAILABLE) {
        put_red_frame_tile(pcanvas, canvas_x, canvas_y);
       }
     }
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.195
diff -u -r1.195 mapview_common.c
--- client/mapview_common.c     24 Feb 2005 01:56:40 -0000      1.195
+++ client/mapview_common.c     25 Feb 2005 20:04:38 -0000
@@ -1271,7 +1271,6 @@
   return FALSE;
 }
 
-
 /****************************************************************************
   Draw a red frame around the tile.  (canvas_x, canvas_y) is the tile origin.
 ****************************************************************************/
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.241
diff -u -r1.241 tilespec.c
--- client/tilespec.c   25 Feb 2005 17:31:49 -0000      1.241
+++ client/tilespec.c   25 Feb 2005 20:04:38 -0000
@@ -1469,6 +1469,8 @@
       SET_SPRITE(colors.player[i], buffer);
     }
 
+    SET_SPRITE(grid.unavailable, "grid.unavailable");
+
     for (i = 0; i < EDGE_COUNT; i++) {
       char *name[EDGE_COUNT] = {"ns", "we"};
       int j, p;
@@ -1482,9 +1484,6 @@
       my_snprintf(buffer, sizeof(buffer), "grid.worked.%s", name[i]);
       SET_SPRITE(grid.worked[i], buffer);
 
-      my_snprintf(buffer, sizeof(buffer), "grid.unavailable.%s", name[i]);
-      SET_SPRITE(grid.unavailable[i], buffer);
-
       my_snprintf(buffer, sizeof(buffer), "grid.selected.%s", name[i]);
       SET_SPRITE(grid.selected[i], buffer);
 
@@ -2806,7 +2805,7 @@
     }
   } else if (pedge) {
     bool known[EDGE_COUNT], city[EDGE_COUNT], unit[EDGE_COUNT];
-    bool worked[EDGE_COUNT], blocked[EDGE_COUNT];
+    bool worked[EDGE_COUNT];
     int i;
     struct unit *pfocus = get_unit_in_focus();
 
@@ -2816,26 +2815,35 @@
       int dummy_x, dummy_y;
 
       known[i] = tile && tile_get_known(tile) != TILE_UNKNOWN;
-      city[i] = tile && (powner == NULL || powner == game.player_ptr)
-       && player_in_city_radius(game.player_ptr, tile);
       unit[i] = tile && pfocus && unit_flag(pfocus, F_CITIES)
        && city_can_be_built_here(pfocus->tile, pfocus)
        && base_map_to_city_map(&dummy_x, &dummy_y, pfocus->tile, tile);
-      worked[i] = blocked[i] = FALSE;
+      worked[i] = FALSE;
+
+      city[i] = tile && (powner == NULL || powner == game.player_ptr)
+       && player_in_city_radius(game.player_ptr, tile);
       if (city[i]) {
-       enum city_tile_type ttype;
-       struct city *dummy;
+       if (citymode) {
+         int cx, cy;
 
-       get_worker_on_map_position(tile, &ttype, &dummy);
-       switch (ttype) {
-       case C_TILE_EMPTY:
-         break;
-       case C_TILE_WORKER:
-         worked[i] = TRUE;
-         break;
-       case C_TILE_UNAVAILABLE:
-         blocked[i] = TRUE;
-         break;
+         if (map_to_city_map(&cx, &cy, citymode, tile)) {
+           /* In citymode, we only draw worked tiles for this city - other
+            * tiles may be marked as unavailable. */
+           worked[i] = citymode->city_map[cx][cy] == C_TILE_WORKER;
+         }
+       } else {
+         enum city_tile_type ttype;
+         struct city *dummy;
+
+         get_worker_on_map_position(tile, &ttype, &dummy);
+         switch (ttype) {
+         case C_TILE_EMPTY:
+         case C_TILE_UNAVAILABLE:
+           break;
+         case C_TILE_WORKER:
+           worked[i] = TRUE;
+           break;
+         }
        }
       }
     }
@@ -2852,9 +2860,7 @@
                   ^ is_ocean(pedge->tile[1]->terrain))) {
       ADD_SPRITE_SIMPLE(sprites.grid.coastline[pedge->type]);
     } else if (draw_map_grid) {
-      if (blocked[0] || blocked[1]) {
-       ADD_SPRITE_SIMPLE(sprites.grid.unavailable[pedge->type]);
-      } else if (worked[0] || worked[1]) {
+      if (worked[0] || worked[1]) {
        ADD_SPRITE_SIMPLE(sprites.grid.worked[pedge->type]);
       } else if (city[0] || city[1]) {
        ADD_SPRITE_SIMPLE(sprites.grid.city[pedge->type]);
@@ -2885,6 +2891,18 @@
        }
       }
     }
+  } else if (ptile && tile_get_known(ptile) != TILE_UNKNOWN) {
+    int cx, cy;
+    enum city_tile_type ttype;
+    struct city *dummy;
+
+    if ((citymode
+        && map_to_city_map(&cx, &cy, citymode, ptile)
+        && citymode->city_map[cx][cy] == C_TILE_UNAVAILABLE)
+       || (get_worker_on_map_position(ptile, &ttype, &dummy),
+           ttype == C_TILE_UNAVAILABLE)) {
+      ADD_SPRITE_SIMPLE(sprites.grid.unavailable);
+    }
   }
 
   return sprs - saved_sprs;
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.107
diff -u -r1.107 tilespec.h
--- client/tilespec.h   25 Feb 2005 17:31:50 -0000      1.107
+++ client/tilespec.h   25 Feb 2005 20:04:38 -0000
@@ -329,7 +329,7 @@
       *main[EDGE_COUNT],
       *city[EDGE_COUNT],
       *worked[EDGE_COUNT],
-      *unavailable[EDGE_COUNT],
+      *unavailable,
       *selected[EDGE_COUNT],
       *coastline[EDGE_COUNT],
       *borders[EDGE_COUNT][2],
Index: data/isotrident/grid.png
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isotrident/grid.png,v
retrieving revision 1.1
diff -u -r1.1 grid.png
Binary files /tmp/cvshLiTnM and grid.png differ
Index: data/isotrident/grid.spec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isotrident/grid.spec,v
retrieving revision 1.1
diff -u -r1.1 grid.spec
--- data/isotrident/grid.spec   25 Feb 2005 17:31:50 -0000      1.1
+++ data/isotrident/grid.spec   25 Feb 2005 20:04:38 -0000
@@ -28,8 +28,7 @@
   1, 1, "grid.city.ns"
   0, 2, "grid.worked.we"
   1, 2, "grid.worked.ns"
-  0, 3, "grid.unavailable.we"
-  1, 3, "grid.unavailable.ns"
+  0, 3, "grid.unavailable"
   0, 4, "grid.selected.we"
   1, 4, "grid.selected.ns"
   0, 5, "grid.coastline.we"
Index: data/trident/grid.png
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/trident/grid.png,v
retrieving revision 1.1
diff -u -r1.1 grid.png
Binary files /tmp/cvsfbgB4J and grid.png differ
Index: data/trident/grid.spec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/trident/grid.spec,v
retrieving revision 1.1
diff -u -r1.1 grid.spec
--- data/trident/grid.spec      25 Feb 2005 17:31:50 -0000      1.1
+++ data/trident/grid.spec      25 Feb 2005 20:04:39 -0000
@@ -28,8 +28,7 @@
   1, 1, "grid.city.ns"
   0, 2, "grid.worked.we"
   1, 2, "grid.worked.ns"
-  0, 3, "grid.unavailable.we"
-  1, 3, "grid.unavailable.ns"
+  0, 3, "grid.unavailable"
   0, 4, "grid.selected.we"
   1, 4, "grid.selected.ns"
   0, 5, "grid.coastline.we"

Attachment: frame.tar.gz
Description: GNU Zip compressed data


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12354) move red-frame-tile into tilespec, Jason Short <=