Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] PATCH: cleanup in fill_tile_sprite_array (PR#1016)
Home

[Freeciv-Dev] PATCH: cleanup in fill_tile_sprite_array (PR#1016)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] PATCH: cleanup in fill_tile_sprite_array (PR#1016)
From: jdorje@xxxxxxxxxxxxxxxxxxxxx
Date: Mon, 15 Oct 2001 04:59:30 -0700 (PDT)

The attached patch cleans up fill_tile_sprite_array and
fill_tile_sprite_array_iso.  The new code still has some ugliness to it
(I'm not sure how to get rid of this...), but should be safe with the
check_map_pos changes and should also be topology-independent (which
some of the old code was not).

jason
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.54
diff -u -r1.54 tilespec.c
--- client/tilespec.c   2001/10/12 10:12:13     1.54
+++ client/tilespec.c   2001/10/15 10:54:29
@@ -1066,6 +1066,18 @@
 }
 
 /**********************************************************************
+This is a hack wrapper to tile_is_known needed to make
+fill_tile_sprite_array[iso] prettier.
+***********************************************************************/
+static enum known_type is_tile_known(int x, int y)
+{
+  if (!normalize_map_pos(&x, &y))
+    return TILE_UNKNOWN;
+  else
+    return tile_is_known(x, y);
+}
+
+/**********************************************************************
 Fill in the sprite array for the tile at position (abs_x0,abs_y0).
 Does not fill in the city or unit; that have to be done seperatly in
 isometric view. Also, no fog here.
@@ -1087,10 +1099,6 @@
 {
   int ttype, ttype_near[8];
   int tspecial, tspecial_near[8];
-  int ttype_north, ttype_south, ttype_east, ttype_west;
-  int ttype_north_east, ttype_south_east, ttype_south_west, ttype_north_west;
-  int tspecial_north, tspecial_south, tspecial_east, tspecial_west;
-  int tspecial_north_east, tspecial_south_east, tspecial_south_west, 
tspecial_north_west;
 
   int tileno;
   struct tile *ptile;
@@ -1100,9 +1108,7 @@
 
   *solid_bg = 0;
 
-  if (!normalize_map_pos(&x, &y))
-    return -1;
-
+  assert(is_normal_map_pos(x, y)); /* should be check_map_pos */
   ptile = map_get_tile(x, y);
   if (!ptile->known)
     return -1;
@@ -1132,49 +1138,32 @@
       tspecial_near[dir] |= S_RIVER;
     }
   } adjc_dir_iterate_end;
-
-  ttype_north      = ttype_near[DIR8_NORTH];
-  ttype_north_east = ttype_near[DIR8_NORTHEAST];
-  ttype_east       = ttype_near[DIR8_EAST];
-  ttype_south_east = ttype_near[DIR8_SOUTHEAST];
-  ttype_south      = ttype_near[DIR8_SOUTH];
-  ttype_south_west = ttype_near[DIR8_SOUTHWEST];
-  ttype_west       = ttype_near[DIR8_WEST];
-  ttype_north_west = ttype_near[DIR8_NORTHWEST];
-  tspecial_north      = tspecial_near[DIR8_NORTH];
-  tspecial_north_east = tspecial_near[DIR8_NORTHEAST];
-  tspecial_east       = tspecial_near[DIR8_EAST];
-  tspecial_south_east = tspecial_near[DIR8_SOUTHEAST];
-  tspecial_south      = tspecial_near[DIR8_SOUTH];
-  tspecial_south_west = tspecial_near[DIR8_SOUTHWEST];
-  tspecial_west       = tspecial_near[DIR8_WEST];
-  tspecial_north_west = tspecial_near[DIR8_NORTHWEST];
   
   if (draw_terrain) {
     if (ttype != T_OCEAN) /* painted via coasts. */
       *sprs++ = get_tile_type(ttype)->sprite[0];
 
     if (ttype == T_HILLS) {
-      tileno = INDEX_NSEW((ttype_north==T_HILLS || ttype_north==T_HILLS),
-                         (ttype_south==T_HILLS || ttype_south==T_HILLS),
-                         (ttype_east==T_HILLS || ttype_east==T_HILLS),
-                         (ttype_west==T_HILLS || ttype_west==T_HILLS));
+      tileno = INDEX_NSEW(ttype_near[DIR8_NORTH] == T_HILLS,
+                         ttype_near[DIR8_SOUTH] == T_HILLS,
+                         ttype_near[DIR8_EAST] == T_HILLS,
+                         ttype_near[DIR8_WEST] == T_HILLS);
       *sprs++=sprites.tx.spec_hill[tileno];
     }
 
     if (ttype == T_FOREST) {
-      tileno = INDEX_NSEW((ttype_north==T_FOREST || ttype_north==T_FOREST),
-                         (ttype_south==T_FOREST || ttype_south==T_FOREST),
-                         (ttype_east==T_FOREST || ttype_east==T_FOREST),
-                         (ttype_west==T_FOREST || ttype_west==T_FOREST));
+      tileno = INDEX_NSEW(ttype_near[DIR8_NORTH] == T_FOREST,
+                         ttype_near[DIR8_SOUTH] == T_FOREST,
+                         ttype_near[DIR8_EAST] == T_FOREST,
+                         ttype_near[DIR8_WEST] == T_FOREST);
       *sprs++=sprites.tx.spec_forest[tileno];
     }
 
     if (ttype == T_MOUNTAINS) {
-      tileno = INDEX_NSEW((ttype_north==T_MOUNTAINS || 
ttype_north==T_MOUNTAINS),
-                         (ttype_south==T_MOUNTAINS || 
ttype_south==T_MOUNTAINS),
-                         (ttype_east==T_MOUNTAINS || ttype_east==T_MOUNTAINS),
-                         (ttype_west==T_MOUNTAINS || ttype_west==T_MOUNTAINS));
+      tileno = INDEX_NSEW(ttype_near[DIR8_NORTH] == T_MOUNTAINS,
+                         ttype_near[DIR8_SOUTH] == T_MOUNTAINS,
+                         ttype_near[DIR8_EAST] == T_MOUNTAINS,
+                         ttype_near[DIR8_WEST] == T_MOUNTAINS);
       *sprs++=sprites.tx.spec_mountain[tileno];
     }
     
@@ -1187,21 +1176,21 @@
     }
 
     if (tspecial&S_RIVER) {
-      tileno = INDEX_NSEW((tspecial_north&S_RIVER || ttype_north==T_OCEAN),
-                         (tspecial_south&S_RIVER || ttype_south==T_OCEAN),
-                         (tspecial_east&S_RIVER || ttype_east==T_OCEAN),
-                         (tspecial_west&S_RIVER || ttype_west==T_OCEAN));
+      tileno = INDEX_NSEW(tspecial_near[DIR8_NORTH] & S_RIVER || 
ttype_near[DIR8_NORTH] == T_OCEAN,
+                         tspecial_near[DIR8_SOUTH] & S_RIVER || 
ttype_near[DIR8_SOUTH] == T_OCEAN,
+                         tspecial_near[DIR8_EAST] & S_RIVER || 
ttype_near[DIR8_EAST] == T_OCEAN,
+                         tspecial_near[DIR8_WEST] & S_RIVER || 
ttype_near[DIR8_WEST] == T_OCEAN);
       *sprs++=sprites.tx.spec_river[tileno];
     }
 
     if (ttype == T_OCEAN) {
-      if(tspecial_north&S_RIVER || ttype_north==T_RIVER)
+      if(tspecial_near[DIR8_NORTH] & S_RIVER || 
ttype_near[DIR8_NORTH]==T_RIVER)
        *sprs++ = sprites.tx.river_outlet[DIR_NORTH];
-      if(tspecial_west&S_RIVER || ttype_west==T_RIVER)
+      if(tspecial_near[DIR8_WEST] & S_RIVER || ttype_near[DIR8_WEST]==T_RIVER)
        *sprs++ = sprites.tx.river_outlet[DIR_WEST];
-      if(tspecial_south&S_RIVER || ttype_south==T_RIVER)
+      if(tspecial_near[DIR8_SOUTH] & S_RIVER || 
ttype_near[DIR8_SOUTH]==T_RIVER)
        *sprs++ = sprites.tx.river_outlet[DIR_SOUTH];
-      if(tspecial_east&S_RIVER || ttype_east==T_RIVER)
+      if(tspecial_near[DIR8_EAST] & S_RIVER || ttype_near[DIR8_EAST]==T_RIVER)
        *sprs++ = sprites.tx.river_outlet[DIR_EAST];
     }
   } else {
@@ -1267,24 +1256,24 @@
       int array_index;
       switch (i) {
       case 0: /* up */
-       ttype_adj[0] = ttype_west;
-       ttype_adj[1] = ttype_north_west;
-       ttype_adj[2] = ttype_north;
+       ttype_adj[0] = ttype_near[DIR8_WEST];
+       ttype_adj[1] = ttype_near[DIR8_NORTHWEST];
+       ttype_adj[2] = ttype_near[DIR8_NORTH];
        break;
       case 1: /* down */
-       ttype_adj[0] = ttype_east;
-       ttype_adj[1] = ttype_south_east;
-       ttype_adj[2] = ttype_south;
+       ttype_adj[0] = ttype_near[DIR8_EAST];
+       ttype_adj[1] = ttype_near[DIR8_SOUTHEAST];
+       ttype_adj[2] = ttype_near[DIR8_SOUTH];
        break;
       case 2: /* left */
-       ttype_adj[0] = ttype_south;
-       ttype_adj[1] = ttype_south_west;
-       ttype_adj[2] = ttype_west;
+       ttype_adj[0] = ttype_near[DIR8_SOUTH];
+       ttype_adj[1] = ttype_near[DIR8_SOUTHWEST];
+       ttype_adj[2] = ttype_near[DIR8_WEST];
        break;
       case 3: /* right*/
-       ttype_adj[0] = ttype_north;
-       ttype_adj[1] = ttype_north_east;
-       ttype_adj[2] = ttype_east;
+       ttype_adj[0] = ttype_near[DIR8_NORTH];
+       ttype_adj[1] = ttype_near[DIR8_NORTHEAST];
+       ttype_adj[2] = ttype_near[DIR8_EAST];
        break;
       default:
        abort();
@@ -1297,10 +1286,11 @@
     }
   }
 
-  dither[0] = get_dither(ttype, tile_is_known(x, y-1) ? ttype_north : 
T_UNKNOWN);
-  dither[1] = get_dither(ttype, tile_is_known(x, y+1) ? ttype_south : 
T_UNKNOWN);
-  dither[2] = get_dither(ttype, tile_is_known(x+1, y) ? ttype_east : 
T_UNKNOWN);
-  dither[3] = get_dither(ttype, tile_is_known(x-1, y) ? ttype_west : 
T_UNKNOWN);
+  /* To make this work cleanly I wrote is_tile_known as a wrapper to 
tile_is_known.  Ugly! */
+  dither[0] = get_dither(ttype, is_tile_known(x, y-1) ? ttype_near[DIR8_NORTH] 
: T_UNKNOWN);
+  dither[1] = get_dither(ttype, is_tile_known(x, y+1) ? ttype_near[DIR8_SOUTH] 
: T_UNKNOWN);
+  dither[2] = get_dither(ttype, is_tile_known(x+1, y) ? ttype_near[DIR8_EAST] 
: T_UNKNOWN);
+  dither[3] = get_dither(ttype, is_tile_known(x-1, y) ? ttype_near[DIR8_WEST] 
: T_UNKNOWN);
 
   return sprs - save_sprs;
 }
@@ -1325,13 +1315,12 @@
 int fill_tile_sprite_array(struct Sprite **sprs, int abs_x0, int abs_y0,
                           int citymode, int *solid_bg, struct player **pplayer)
 {
-  int ttype, ttype_north, ttype_south, ttype_east, ttype_west;
-  int ttype_north_east, ttype_south_east, ttype_south_west, ttype_north_west;
-  int tspecial, tspecial_north, tspecial_south, tspecial_east, tspecial_west;
-  int tspecial_north_east, tspecial_south_east, tspecial_south_west, 
tspecial_north_west;
+  int ttype, ttype_near[8];
+  int tspecial, tspecial_near[8];
   int rail_card_tileno=0, rail_semi_tileno=0, road_card_tileno=0, 
road_semi_tileno=0;
   int rail_card_count=0, rail_semi_count=0, road_card_count=0, 
road_semi_count=0;
 
+  int dir;
   int tileno;
   struct tile *ptile;
   struct Sprite *mysprite;
@@ -1344,9 +1333,10 @@
   *solid_bg = 0;
   *pplayer = NULL;
 
+  assert(is_normal_map_pos(abs_x0, abs_y0)); /* should be check_map_pos */
   ptile=map_get_tile(abs_x0, abs_y0);
 
-  if(abs_y0>=map.ysize || ptile->known == TILE_UNKNOWN) {
+  if (ptile->known == TILE_UNKNOWN) {
     return 0;
   }
 
@@ -1373,53 +1363,37 @@
   }
 
   ttype=map_get_terrain(abs_x0, abs_y0);
-  ttype_east=map_get_terrain(abs_x0+1, abs_y0);
-  ttype_west=map_get_terrain(abs_x0-1, abs_y0);
-
-  /* make north and south pole seamless: */
-  if(abs_y0==0) {
-    ttype_north=ttype;
-    ttype_north_east=ttype_east;
-    ttype_north_west=ttype_west;
-  } else {
-    ttype_north=map_get_terrain(abs_x0, abs_y0-1);
-    ttype_north_east=map_get_terrain(abs_x0+1, abs_y0-1);
-    ttype_north_west=map_get_terrain(abs_x0-1, abs_y0-1);
-  }
-  if(abs_y0==map.ysize-1) {
-    ttype_south=ttype;
-    ttype_south_east=ttype_east;
-    ttype_south_west=ttype_west;
-  } else {
-    ttype_south=map_get_terrain(abs_x0, abs_y0+1);
-    ttype_south_east=map_get_terrain(abs_x0+1, abs_y0+1);
-    ttype_south_west=map_get_terrain(abs_x0-1, abs_y0+1);
+  for (dir=0; dir<8; dir++) {
+    /* nearest_real_pos is used to make the poles seamless */
+    int x, y, dx, dy;
+    DIRSTEP(dx, dy, dir);
+    x = abs_x0 + dx, y = abs_y0 + dy;
+    nearest_real_pos(&x, &y);
+    ttype_near[dir] = map_get_terrain(x, y);
   }
 
-  /* map_get_special() returns S_NO_SPECIAL past poles anyway */
+  /* make sure we set S_NO_SPECIAL past poles */
   tspecial=map_get_special(abs_x0, abs_y0);
-  tspecial_north=map_get_special(abs_x0, abs_y0-1);
-  tspecial_east=map_get_special(abs_x0+1, abs_y0);
-  tspecial_south=map_get_special(abs_x0, abs_y0+1);
-  tspecial_west=map_get_special(abs_x0-1, abs_y0);
-  tspecial_north_east=map_get_special(abs_x0+1, abs_y0-1);
-  tspecial_south_east=map_get_special(abs_x0+1, abs_y0+1);
-  tspecial_south_west=map_get_special(abs_x0-1, abs_y0+1);
-  tspecial_north_west=map_get_special(abs_x0-1, abs_y0-1);
+  for (dir = 0; dir < 8; dir++) {
+    tspecial_near[dir] = S_NO_SPECIAL;
+  }
+  adjc_dir_iterate(abs_x0, abs_y0, x, y, dir) {
+    tspecial_near[dir] = map_get_special(x, y);
+  } adjc_dir_iterate_end;
 
   if(map.is_earth &&
      abs_x0>=34 && abs_x0<=36 && abs_y0>=den_y && abs_y0<=den_y+1) {
     mysprite = sprites.tx.denmark[abs_y0-den_y][abs_x0-34];
   } else {
-    tileno = INDEX_NSEW((ttype_north==ttype),
-                       (ttype_south==ttype),
-                       (ttype_east==ttype),    
-                       (ttype_west==ttype));
+    tileno = INDEX_NSEW(ttype_near[DIR8_NORTH] == ttype,
+                       ttype_near[DIR8_SOUTH] == ttype,
+                       ttype_near[DIR8_EAST] == ttype, 
+                       ttype_near[DIR8_WEST] == ttype);
     if(ttype==T_RIVER) {
-      tileno |= INDEX_NSEW((ttype_north==T_OCEAN),
-                          (ttype_south==T_OCEAN),
-                          (ttype_east==T_OCEAN),
-                          (ttype_west==T_OCEAN));
+      tileno |= INDEX_NSEW(ttype_near[DIR8_NORTH] == T_OCEAN,
+                          ttype_near[DIR8_SOUTH] == T_OCEAN,
+                          ttype_near[DIR8_EAST] == T_OCEAN,
+                          ttype_near[DIR8_WEST] == T_OCEAN);
     }
     mysprite = get_tile_type(ttype)->sprite[tileno];
   }
@@ -1428,32 +1402,28 @@
   else *solid_bg = 1;
 
   if(ttype==T_OCEAN && draw_terrain) {
-    tileno = INDEX_NSEW((ttype_north==T_OCEAN && ttype_east==T_OCEAN && 
-                         ttype_north_east!=T_OCEAN),
-                        (ttype_south==T_OCEAN && ttype_west==T_OCEAN && 
-                         ttype_south_west!=T_OCEAN),
-                        (ttype_east==T_OCEAN && ttype_south==T_OCEAN && 
-                         ttype_south_east!=T_OCEAN),
-                        (ttype_north==T_OCEAN && ttype_west==T_OCEAN && 
-                         ttype_north_west!=T_OCEAN));
+    tileno = INDEX_NSEW(ttype_near[DIR8_NORTH]==T_OCEAN && 
ttype_near[DIR8_EAST]==T_OCEAN && ttype_near[DIR8_NORTHEAST]!=T_OCEAN,
+                        ttype_near[DIR8_SOUTH]==T_OCEAN && 
ttype_near[DIR8_WEST]==T_OCEAN && ttype_near[DIR8_SOUTHWEST]!=T_OCEAN,
+                        ttype_near[DIR8_EAST]==T_OCEAN && 
ttype_near[DIR8_SOUTH]==T_OCEAN && ttype_near[DIR8_SOUTHEAST]!=T_OCEAN,
+                        ttype_near[DIR8_NORTH]==T_OCEAN && 
ttype_near[DIR8_WEST]==T_OCEAN && ttype_near[DIR8_NORTHWEST]!=T_OCEAN);
     if(tileno!=0)
       *sprs++ = sprites.tx.coast_cape[tileno];
 
-    if(tspecial_north&S_RIVER || ttype_north==T_RIVER)
+    if(tspecial_near[DIR8_NORTH] & S_RIVER || ttype_near[DIR8_NORTH] == 
T_RIVER)
       *sprs++ = sprites.tx.river_outlet[DIR_NORTH];
-    if(tspecial_west&S_RIVER || ttype_west==T_RIVER)
+    if(tspecial_near[DIR8_WEST] & S_RIVER || ttype_near[DIR8_WEST] == T_RIVER)
       *sprs++ = sprites.tx.river_outlet[DIR_WEST];
-    if(tspecial_south&S_RIVER || ttype_south==T_RIVER)
+    if(tspecial_near[DIR8_SOUTH] & S_RIVER || ttype_near[DIR8_SOUTH]==T_RIVER)
       *sprs++ = sprites.tx.river_outlet[DIR_SOUTH];
-    if(tspecial_east&S_RIVER || ttype_east==T_RIVER)
+    if(tspecial_near[DIR8_EAST] & S_RIVER || ttype_near[DIR8_EAST]==T_RIVER)
       *sprs++ = sprites.tx.river_outlet[DIR_EAST];
   }
 
   if (tspecial&S_RIVER && draw_terrain) {
-    tileno = INDEX_NSEW((tspecial_north&S_RIVER || ttype_north==T_OCEAN),
-                       (tspecial_south&S_RIVER || ttype_south==T_OCEAN),
-                       (tspecial_east&S_RIVER  || ttype_east==T_OCEAN),
-                       (tspecial_west&S_RIVER  || ttype_west== T_OCEAN));
+    tileno = INDEX_NSEW(tspecial_near[DIR8_NORTH]&S_RIVER || 
ttype_near[DIR8_NORTH]==T_OCEAN,
+                       tspecial_near[DIR8_SOUTH]&S_RIVER || 
ttype_near[DIR8_SOUTH]==T_OCEAN,
+                       tspecial_near[DIR8_EAST]&S_RIVER  || 
ttype_near[DIR8_EAST]==T_OCEAN,
+                       tspecial_near[DIR8_WEST]&S_RIVER  || 
ttype_near[DIR8_WEST]== T_OCEAN);
     *sprs++=sprites.tx.spec_river[tileno];
   }
 
@@ -1464,32 +1434,32 @@
 
   if(((tspecial & S_ROAD) || (tspecial & S_RAILROAD)) && draw_roads_rails) {
     int n, s, e, w;
-    
-    n = BOOL_VAL(tspecial_north&S_RAILROAD);
-    s = BOOL_VAL(tspecial_south&S_RAILROAD);
-    e = BOOL_VAL(tspecial_east&S_RAILROAD);
-    w = BOOL_VAL(tspecial_west&S_RAILROAD);
+
+    n = BOOL_VAL(tspecial_near[DIR8_NORTH]&S_RAILROAD);
+    s = BOOL_VAL(tspecial_near[DIR8_SOUTH]&S_RAILROAD);
+    e = BOOL_VAL(tspecial_near[DIR8_EAST]&S_RAILROAD);
+    w = BOOL_VAL(tspecial_near[DIR8_WEST]&S_RAILROAD);
     rail_card_count = n + s + e + w;
     rail_card_tileno = INDEX_NSEW(n,s,e,w);
     
-    n = BOOL_VAL(tspecial_north&S_ROAD);
-    s = BOOL_VAL(tspecial_south&S_ROAD);
-    e = BOOL_VAL(tspecial_east&S_ROAD);
-    w = BOOL_VAL(tspecial_west&S_ROAD);
+    n = BOOL_VAL(tspecial_near[DIR8_NORTH]&S_ROAD);
+    s = BOOL_VAL(tspecial_near[DIR8_SOUTH]&S_ROAD);
+    e = BOOL_VAL(tspecial_near[DIR8_EAST]&S_ROAD);
+    w = BOOL_VAL(tspecial_near[DIR8_WEST]&S_ROAD);
     road_card_count = n + s + e + w;
     road_card_tileno = INDEX_NSEW(n,s,e,w);
     
-    n = BOOL_VAL(tspecial_north_east&S_RAILROAD);
-    s = BOOL_VAL(tspecial_south_west&S_RAILROAD);
-    e = BOOL_VAL(tspecial_south_east&S_RAILROAD);
-    w = BOOL_VAL(tspecial_north_west&S_RAILROAD);
+    n = BOOL_VAL(tspecial_near[DIR8_NORTHEAST]&S_RAILROAD);
+    s = BOOL_VAL(tspecial_near[DIR8_SOUTHWEST]&S_RAILROAD);
+    e = BOOL_VAL(tspecial_near[DIR8_SOUTHEAST]&S_RAILROAD);
+    w = BOOL_VAL(tspecial_near[DIR8_NORTHWEST]&S_RAILROAD);
     rail_semi_count = n + s + e + w;
     rail_semi_tileno = INDEX_NSEW(n,s,e,w);
     
-    n = BOOL_VAL(tspecial_north_east&S_ROAD);
-    s = BOOL_VAL(tspecial_south_west&S_ROAD);
-    e = BOOL_VAL(tspecial_south_east&S_ROAD);
-    w = BOOL_VAL(tspecial_north_west&S_ROAD);
+    n = BOOL_VAL(tspecial_near[DIR8_NORTHEAST]&S_ROAD);
+    s = BOOL_VAL(tspecial_near[DIR8_SOUTHWEST]&S_ROAD);
+    e = BOOL_VAL(tspecial_near[DIR8_SOUTHEAST]&S_ROAD);
+    w = BOOL_VAL(tspecial_near[DIR8_NORTHWEST]&S_ROAD);
     road_semi_count = n + s + e + w;
     road_semi_tileno = INDEX_NSEW(n,s,e,w);
 
@@ -1573,10 +1543,11 @@
   if(ptile->known==TILE_KNOWN_FOGGED && draw_fog_of_war) *sprs++ = 
sprites.tx.fog;
 
   if(!citymode) {
-    tileno = INDEX_NSEW((tile_is_known(abs_x0, abs_y0-1)==TILE_UNKNOWN),
-                        (tile_is_known(abs_x0, abs_y0+1)==TILE_UNKNOWN),
-                        (tile_is_known(abs_x0+1, abs_y0)==TILE_UNKNOWN),
-                        (tile_is_known(abs_x0-1, abs_y0)==TILE_UNKNOWN));
+    /* To make this work cleanly I wrote is_tile_known as a wrapper to 
tile_is_known.  Ugly! */
+    tileno = INDEX_NSEW((is_tile_known(abs_x0, abs_y0-1)==TILE_UNKNOWN),
+                        (is_tile_known(abs_x0, abs_y0+1)==TILE_UNKNOWN),
+                        (is_tile_known(abs_x0+1, abs_y0)==TILE_UNKNOWN),
+                        (is_tile_known(abs_x0-1, abs_y0)==TILE_UNKNOWN));
     if (tileno) 
       *sprs++ = sprites.tx.darkness[tileno];
   }

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