]> granicus.if.org Git - nethack/commitdiff
Futureproofing hypothetical type mismatches
authorPasi Kallinen <paxed@alt.org>
Sat, 14 Nov 2020 11:41:31 +0000 (13:41 +0200)
committerPasi Kallinen <paxed@alt.org>
Sat, 14 Nov 2020 11:53:09 +0000 (13:53 +0200)
If we ever want huge maps with COLNO or ROWNO larger than signed char,
this will at least allow the game to compile and start when typedef'ing
xchar to int. Trying to use huge maps exposes more bugs.

include/decl.h
include/extern.h
include/mkroom.h
include/patchlevel.h
src/light.c
src/nhlsel.c
src/sp_lev.c
src/vision.c

index dc1039c22c785d67f7c20cd3a41e5272421870c8..87000f88c83237b5ec6b434c57a4204298b0762f 100644 (file)
@@ -803,8 +803,8 @@ struct instance_globals {
 
     /* display.c */
     gbuf_entry gbuf[ROWNO][COLNO];
-    char gbuf_start[ROWNO];
-    char gbuf_stop[ROWNO];
+    xchar gbuf_start[ROWNO];
+    xchar gbuf_stop[ROWNO];
 
 
     /* do.c */
@@ -828,7 +828,7 @@ struct instance_globals {
     int petname_used; /* user preferred pet name has been used */
     xchar gtyp;  /* type of dog's current goal */
     xchar gx; /* x position of dog's current goal */
-    char  gy; /* y position of dog's current goal */
+    xchar gy; /* y position of dog's current goal */
     char dogname[PL_PSIZ];
     char catname[PL_PSIZ];
     char horsename[PL_PSIZ];
@@ -1169,9 +1169,9 @@ struct instance_globals {
                                       Stormbringer's maliciousness. */
 
     /* vision.c */
-    char **viz_array; /* used in cansee() and couldsee() macros */
-    char *viz_rmin;                    /* min could see indices */
-    char *viz_rmax;                    /* max could see indices */
+    xchar **viz_array; /* used in cansee() and couldsee() macros */
+    xchar *viz_rmin;                   /* min could see indices */
+    xchar *viz_rmax;                   /* max could see indices */
     boolean vision_full_recalc;
 
     /* weapon.c */
index 9280b47b6f494dd2306245d13218876d0915f3f7..74de4f1e79afba60f927af71e7ee3bd31a559dca 100644 (file)
@@ -1119,7 +1119,7 @@ E int NDECL(dosuspend);
 
 E void FDECL(new_light_source, (XCHAR_P, XCHAR_P, int, int, ANY_P *));
 E void FDECL(del_light_source, (int, ANY_P *));
-E void FDECL(do_light_sources, (char **));
+E void FDECL(do_light_sources, (xchar **));
 E void FDECL(show_transient_light, (struct obj *, int, int));
 E void NDECL(transient_light_cleanup);
 E struct monst *FDECL(find_mid, (unsigned, unsigned));
@@ -2497,7 +2497,7 @@ E void FDECL(set_selection_floodfillchk, (int FDECL((*), (int,int))));
 E void FDECL(selection_floodfill, (struct selectionvar *, int, int,
                                    BOOLEAN_P));
 E boolean FDECL(pm_good_location, (int, int, struct permonst *));
-E void FDECL(get_location_coord, (schar *, schar *, int, struct mkroom *,
+E void FDECL(get_location_coord, (xchar *, xchar *, int, struct mkroom *,
                                   long));
 E void FDECL(selection_setpoint, (int, int, struct selectionvar *, XCHAR_P));
 E struct selectionvar * FDECL(selection_not, (struct selectionvar *));
index e707aa69527c2b949961d9273e7b6198463622c1..07d2318aad7b12d41e366d810623f1ecec09ba60 100644 (file)
@@ -9,7 +9,7 @@
 /* mkroom.h - types and structures for room and shop initialization */
 
 struct mkroom {
-    schar lx, hx, ly, hy; /* usually xchar, but hx may be -1 */
+    xchar lx, hx, ly, hy; /* usually xchar, but hx may be -1 */
     schar rtype;          /* type of room (zoo, throne, etc...) */
     schar orig_rtype;     /* same as rtype, but not zeroed later */
     schar rlit;           /* is the room lit ? */
index 0ca768ddb1d33522963052492b83b4c28ba46550..5e1557d7921c74b21afd660c4eb39cf26d14804a 100644 (file)
@@ -17,7 +17,7 @@
  * Incrementing EDITLEVEL can be used to force invalidation of old bones
  * and save files.
  */
-#define EDITLEVEL 25
+#define EDITLEVEL 26
 
 /*
  * Development status possibilities.
index 02ddaf03f7bccb2ac771ab10feee47e9b097ea76..26f832777333f63c2f8ee50be7ebad47da1f644b 100644 (file)
@@ -48,8 +48,8 @@ static void FDECL(write_ls, (NHFILE *, light_source *));
 static int FDECL(maybe_write_ls, (NHFILE *, int, BOOLEAN_P));
 
 /* imported from vision.c, for small circles */
-extern char circle_data[];
-extern char circle_start[];
+extern xchar circle_data[];
+extern xchar circle_start[];
 
 
 /* Create a new light source.  Caller (and extern.h) doesn't need to know
@@ -144,13 +144,13 @@ anything *id;
 /* Mark locations that are temporarily lit via mobile light sources. */
 void
 do_light_sources(cs_rows)
-char **cs_rows;
+xchar **cs_rows;
 {
     int x, y, min_x, max_x, max_y, offset;
-    char *limits;
+    xchar *limits;
     short at_hero_range = 0;
     light_source *ls;
-    char *row;
+    xchar *row;
 
     for (ls = g.light_base; ls; ls = ls->next) {
         ls->flags &= ~LSF_SHOW;
index 26edad48344aa8d69dd1afe1397d746381d9b41f..953b7c241e61863b090c990ec37c75ba7eff3599 100644 (file)
@@ -14,7 +14,7 @@ static int FDECL(l_selection_not, (lua_State *));
 static int FDECL(l_selection_filter_percent, (lua_State *));
 static int FDECL(l_selection_rndcoord, (lua_State *));
 static boolean FDECL(params_sel_2coords, (lua_State *, struct selectionvar **,
-                                          schar *, schar *, schar *, schar *));
+                                          xchar *, xchar *, xchar *, xchar *));
 static int FDECL(l_selection_line, (lua_State *));
 static int FDECL(l_selection_randline, (lua_State *));
 static int FDECL(l_selection_rect, (lua_State *));
@@ -143,7 +143,7 @@ l_selection_setpoint(L)
 lua_State *L;
 {
     struct selectionvar *sel = (struct selectionvar *) 0;
-    schar x = -1, y = -1;
+    xchar x = -1, y = -1;
     int val = 1;
     int argc = lua_gettop(L);
     long crd = 0L;
@@ -153,15 +153,15 @@ lua_State *L;
     } else if (argc == 1) {
         sel = l_selection_check(L, 1);
     } else if (argc == 2) {
-        x = (schar) luaL_checkinteger(L, 1);
-        y = (schar) luaL_checkinteger(L, 2);
+        x = (xchar) luaL_checkinteger(L, 1);
+        y = (xchar) luaL_checkinteger(L, 2);
         lua_pop(L, 2);
         (void) l_selection_new(L);
         sel = l_selection_check(L, 1);
     } else {
         sel = l_selection_check(L, 1);
-        x = (schar) luaL_checkinteger(L, 2);
-        y = (schar) luaL_checkinteger(L, 3);
+        x = (xchar) luaL_checkinteger(L, 2);
+        y = (xchar) luaL_checkinteger(L, 3);
         val = (int) luaL_optinteger(L, 4, 1);
     }
 
@@ -188,8 +188,8 @@ l_selection_getpoint(L)
 lua_State *L;
 {
     struct selectionvar *sel = l_selection_check(L, 1);
-    schar x = (schar) luaL_checkinteger(L, 2);
-    schar y = (schar) luaL_checkinteger(L, 3);
+    xchar x = (xchar) luaL_checkinteger(L, 2);
+    xchar y = (xchar) luaL_checkinteger(L, 3);
     int val;
     long crd;
 
@@ -344,16 +344,16 @@ static boolean
 params_sel_2coords(L, sel, x1,y1, x2,y2)
 lua_State *L;
 struct selectionvar **sel;
-schar *x1, *y1, *x2, *y2;
+xchar *x1, *y1, *x2, *y2;
 {
     int argc = lua_gettop(L);
 
     if (argc == 4) {
         (void) l_selection_new(L);
-        *x1 = (schar) luaL_checkinteger(L, 1);
-        *y1 = (schar) luaL_checkinteger(L, 2);
-        *x2 = (schar) luaL_checkinteger(L, 3);
-        *y2 = (schar) luaL_checkinteger(L, 4);
+        *x1 = (xchar) luaL_checkinteger(L, 1);
+        *y1 = (xchar) luaL_checkinteger(L, 2);
+        *x2 = (xchar) luaL_checkinteger(L, 3);
+        *y2 = (xchar) luaL_checkinteger(L, 4);
         *sel = l_selection_check(L, 5);
         lua_remove(L, 1);
         lua_remove(L, 1);
@@ -362,10 +362,10 @@ schar *x1, *y1, *x2, *y2;
         return TRUE;
     } else if (argc == 5) {
         *sel = l_selection_check(L, 1);
-        *x1 = (schar) luaL_checkinteger(L, 2);
-        *y1 = (schar) luaL_checkinteger(L, 3);
-        *x2 = (schar) luaL_checkinteger(L, 4);
-        *y2 = (schar) luaL_checkinteger(L, 5);
+        *x1 = (xchar) luaL_checkinteger(L, 2);
+        *y1 = (xchar) luaL_checkinteger(L, 3);
+        *x2 = (xchar) luaL_checkinteger(L, 4);
+        *y2 = (xchar) luaL_checkinteger(L, 5);
         lua_pop(L, 4);
         return TRUE;
     }
@@ -380,10 +380,7 @@ l_selection_line(L)
 lua_State *L;
 {
     struct selectionvar *sel = NULL;
-    schar x1;
-    schar y1;
-    schar x2;
-    schar y2;
+    xchar x1, y1, x2, y2;
 
     if (!params_sel_2coords(L, &sel, &x1, &y1, &x2, &y2)) {
         nhl_error(L, "selection.line: illegal arguments");
@@ -404,10 +401,7 @@ l_selection_rect(L)
 lua_State *L;
 {
     struct selectionvar *sel = NULL;
-    schar x1;
-    schar y1;
-    schar x2;
-    schar y2;
+    xchar x1, y1, x2, y2;
 
     if (!params_sel_2coords(L, &sel, &x1, &y1, &x2, &y2)) {
         nhl_error(L, "selection.rect: illegal arguments");
@@ -437,10 +431,7 @@ lua_State *L;
 {
     struct selectionvar *sel = NULL;
     int y;
-    schar x1;
-    schar y1;
-    schar x2;
-    schar y2;
+    xchar x1, y1, x2, y2;
 
     if (!params_sel_2coords(L, &sel, &x1, &y1, &x2, &y2)) {
         nhl_error(L, "selection.fillrect: illegal arguments");
@@ -473,22 +464,22 @@ lua_State *L;
 {
     int argc = lua_gettop(L);
     struct selectionvar *sel = (struct selectionvar *) 0;
-    schar x1, y1, x2, y2;
+    xchar x1, y1, x2, y2;
     int roughness = 7;
 
     if (argc == 6) {
         sel = l_selection_check(L, 1);
-        x1 = (schar) luaL_checkinteger(L, 2);
-        y1 = (schar) luaL_checkinteger(L, 3);
-        x2 = (schar) luaL_checkinteger(L, 4);
-        y2 = (schar) luaL_checkinteger(L, 5);
+        x1 = (xchar) luaL_checkinteger(L, 2);
+        y1 = (xchar) luaL_checkinteger(L, 3);
+        x2 = (xchar) luaL_checkinteger(L, 4);
+        y2 = (xchar) luaL_checkinteger(L, 5);
         roughness = (int) luaL_checkinteger(L, 6);
         lua_pop(L, 5);
     } else if (argc == 5 && lua_type(L, 1) == LUA_TNUMBER) {
-        x1 = (schar) luaL_checkinteger(L, 1);
-        y1 = (schar) luaL_checkinteger(L, 2);
-        x2 = (schar) luaL_checkinteger(L, 3);
-        y2 = (schar) luaL_checkinteger(L, 4);
+        x1 = (xchar) luaL_checkinteger(L, 1);
+        y1 = (xchar) luaL_checkinteger(L, 2);
+        x2 = (xchar) luaL_checkinteger(L, 3);
+        y2 = (xchar) luaL_checkinteger(L, 4);
         roughness = (int) luaL_checkinteger(L, 5);
         lua_pop(L, 5);
         (void) l_selection_new(L);
@@ -610,11 +601,11 @@ lua_State *L;
 {
     int argc = lua_gettop(L);
     struct selectionvar *sel = (struct selectionvar *) 0;
-    schar x, y;
+    xchar x, y;
 
     if (argc == 2) {
-        x = (schar) luaL_checkinteger(L, 1);
-        y = (schar) luaL_checkinteger(L, 2);
+        x = (xchar) luaL_checkinteger(L, 1);
+        y = (xchar) luaL_checkinteger(L, 2);
         lua_pop(L, 2);
         (void) l_selection_new(L);
         sel = l_selection_check(L, 1);
@@ -644,20 +635,20 @@ lua_State *L;
 {
     int argc = lua_gettop(L);
     struct selectionvar *sel = (struct selectionvar *) 0;
-    schar x = 0, y = 0;
+    xchar x = 0, y = 0;
     int r = 0, filled = 0;
 
     if (argc == 3) {
-        x = (schar) luaL_checkinteger(L, 1);
-        y = (schar) luaL_checkinteger(L, 2);
+        x = (xchar) luaL_checkinteger(L, 1);
+        y = (xchar) luaL_checkinteger(L, 2);
         r = (int) luaL_checkinteger(L, 3);
         lua_pop(L, 3);
         (void) l_selection_new(L);
         sel = l_selection_check(L, 1);
         filled = 0;
     } else if (argc == 4 && lua_type(L, 1) == LUA_TNUMBER) {
-        x = (schar) luaL_checkinteger(L, 1);
-        y = (schar) luaL_checkinteger(L, 2);
+        x = (xchar) luaL_checkinteger(L, 1);
+        y = (xchar) luaL_checkinteger(L, 2);
         r = (int) luaL_checkinteger(L, 3);
         filled = (int) luaL_checkinteger(L, 4); /* TODO: boolean*/
         lua_pop(L, 4);
@@ -665,8 +656,8 @@ lua_State *L;
         sel = l_selection_check(L, 1);
     } else if (argc == 4 || argc == 5) {
         sel = l_selection_check(L, 1);
-        x = (schar) luaL_checkinteger(L, 2);
-        y = (schar) luaL_checkinteger(L, 3);
+        x = (xchar) luaL_checkinteger(L, 2);
+        y = (xchar) luaL_checkinteger(L, 3);
         r = (int) luaL_checkinteger(L, 4);
         filled = (int) luaL_optinteger(L, 5, 0); /* TODO: boolean */
     } else {
@@ -693,12 +684,12 @@ lua_State *L;
 {
     int argc = lua_gettop(L);
     struct selectionvar *sel = (struct selectionvar *) 0;
-    schar x = 0, y = 0;
+    xchar x = 0, y = 0;
     int r1 = 0, r2 = 0, filled = 0;
 
     if (argc == 4) {
-        x = (schar) luaL_checkinteger(L, 1);
-        y = (schar) luaL_checkinteger(L, 2);
+        x = (xchar) luaL_checkinteger(L, 1);
+        y = (xchar) luaL_checkinteger(L, 2);
         r1 = (int) luaL_checkinteger(L, 3);
         r2 = (int) luaL_checkinteger(L, 4);
         lua_pop(L, 4);
@@ -706,8 +697,8 @@ lua_State *L;
         sel = l_selection_check(L, 1);
         filled = 0;
     } else if (argc == 5 && lua_type(L, 1) == LUA_TNUMBER) {
-        x = (schar) luaL_checkinteger(L, 1);
-        y = (schar) luaL_checkinteger(L, 2);
+        x = (xchar) luaL_checkinteger(L, 1);
+        y = (xchar) luaL_checkinteger(L, 2);
         r1 = (int) luaL_checkinteger(L, 3);
         r2 = (int) luaL_checkinteger(L, 4);
         filled = (int) luaL_optinteger(L, 5, 0); /* TODO: boolean */
@@ -716,8 +707,8 @@ lua_State *L;
         sel = l_selection_check(L, 1);
     } else if (argc == 5 || argc == 6) {
         sel = l_selection_check(L, 1);
-        x = (schar) luaL_checkinteger(L, 2);
-        y = (schar) luaL_checkinteger(L, 3);
+        x = (xchar) luaL_checkinteger(L, 2);
+        y = (xchar) luaL_checkinteger(L, 3);
         r1 = (int) luaL_checkinteger(L, 4);
         r2 = (int) luaL_checkinteger(L, 5);
         filled = (int) luaL_optinteger(L, 6, 0); /* TODO: boolean */
index 5767744c95c03093b0806d10311d41f3a153fc04..c03d08f260ca605d75d4993dd3440d40f2fd2174 100755 (executable)
@@ -42,11 +42,11 @@ static void FDECL(maybe_add_door, (int, int, struct mkroom *));
 static void NDECL(link_doors_rooms);
 static int NDECL(rnddoor);
 static int NDECL(rndtrap);
-static void FDECL(get_location, (schar *, schar *, int, struct mkroom *));
+static void FDECL(get_location, (xchar *, xchar *, int, struct mkroom *));
 static boolean FDECL(is_ok_location, (SCHAR_P, SCHAR_P, int));
 static unpacked_coord FDECL(get_unpacked_coord, (long, int));
-static void FDECL(get_room_loc, (schar *, schar *, struct mkroom *));
-static void FDECL(get_free_room_loc, (schar *, schar *,
+static void FDECL(get_room_loc, (xchar *, xchar *, struct mkroom *));
+static void FDECL(get_free_room_loc, (xchar *, xchar *,
                                           struct mkroom *, packed_coord));
 static boolean FDECL(create_subroom, (struct mkroom *, XCHAR_P, XCHAR_P,
                                       XCHAR_P, XCHAR_P, XCHAR_P, XCHAR_P));
@@ -1075,7 +1075,7 @@ rndtrap()
  */
 static void
 get_location(x, y, humidity, croom)
-schar *x, *y;
+xchar *x, *y;
 int humidity;
 struct mkroom *croom;
 {
@@ -1207,7 +1207,7 @@ int defhumidity;
 
 void
 get_location_coord(x, y, humidity, croom, crd)
-schar *x, *y;
+xchar *x, *y;
 int humidity;
 struct mkroom *croom;
 long crd;
@@ -1230,7 +1230,7 @@ long crd;
 
 static void
 get_room_loc(x, y, croom)
-schar *x, *y;
+xchar *x, *y;
 struct mkroom *croom;
 {
     coord c;
@@ -1257,11 +1257,11 @@ struct mkroom *croom;
  */
 static void
 get_free_room_loc(x, y, croom, pos)
-schar *x, *y;
+xchar *x, *y;
 struct mkroom *croom;
 packed_coord pos;
 {
-    schar try_x, try_y;
+    xchar try_x, try_y;
     register int trycnt = 0;
 
     get_location_coord(&try_x, &try_y, DRY, croom, pos);
@@ -1741,7 +1741,7 @@ create_trap(t, croom)
 spltrap *t;
 struct mkroom *croom;
 {
-    schar x = -1, y = -1;
+    xchar x = -1, y = -1;
     coord tm;
 
     if (croom) {
@@ -1825,7 +1825,7 @@ monster *m;
 struct mkroom *croom;
 {
     struct monst *mtmp;
-    schar x, y;
+    xchar x, y;
     char class;
     aligntyp amask;
     coord cc;
@@ -2088,7 +2088,7 @@ object *o;
 struct mkroom *croom;
 {
     struct obj *otmp;
-    schar x, y;
+    xchar x, y;
     char c;
     boolean named; /* has a name been supplied in level description? */
 
@@ -2324,7 +2324,8 @@ create_altar(a, croom)
 altar *a;
 struct mkroom *croom;
 {
-    schar sproom, x = -1, y = -1;
+    schar sproom;
+    xchar x = -1, y = -1;
     aligntyp amask;
     boolean croom_is_temple = TRUE;
     int oldtyp;
@@ -3922,7 +3923,7 @@ lspo_grave(L)
 lua_State *L;
 {
     int argc = lua_gettop(L);
-    schar x, y;
+    xchar x, y;
     long scoord;
     int ax,ay;
     char *txt;
@@ -4134,7 +4135,7 @@ lspo_gold(L)
 lua_State *L;
 {
     int argc = lua_gettop(L);
-    schar x, y;
+    xchar x, y;
     long amount;
     long gcoord;
     int gx, gy;
@@ -4885,7 +4886,7 @@ lua_State *L;
         -1, D_ISOPEN, D_CLOSED, D_LOCKED, D_NODOOR, D_BROKEN, D_SECRET
     };
     int msk;
-    schar x,y;
+    xchar x,y;
     xchar typ;
     int argc = lua_gettop(L);
 
@@ -4966,7 +4967,7 @@ lua_State *L;
                                             "throne", "tree", NULL };
     static const int features2i[] = { FOUNTAIN, SINK, POOL,
                                       THRONE, TREE, STONE };
-    schar x,y;
+    xchar x,y;
     int typ;
     int argc = lua_gettop(L);
     boolean can_have_flags = FALSE;
@@ -5167,7 +5168,7 @@ lua_State *L;
         if (x1 == -1 && y1 == -1 && x2 == -1 && y2 == -1) {
             (void) selection_not(sel);
         } else {
-            schar rx1, ry1, rx2, ry2;
+            xchar rx1, ry1, rx2, ry2;
             rx1 = x1, ry1 = y1, rx2 = x2, ry2 = x2;
             get_location(&rx1, &ry1, ANY_LOC, g.coder->croom);
             get_location(&rx2, &ry2, ANY_LOC, g.coder->croom);
@@ -5825,7 +5826,7 @@ lua_State *L;
 {
     static const char *const wprops[] = { "nondiggable", "nonpasswall", NULL };
     static const int wprop2i[] = { W_NONDIGGABLE, W_NONPASSWALL, -1 };
-    schar dx1 = -1, dy1 = -1, dx2 = -1, dy2 = -1;
+    xchar dx1 = -1, dy1 = -1, dx2 = -1, dy2 = -1;
     int wprop;
 
     create_des_coder();
index 45cd1fe9b5cb1da272a6a514424b212f6f9aef1d..3136cf0e389ba8a7aa2cf7396bcfe3946ff897a2 100644 (file)
@@ -23,7 +23,7 @@
  *              @...X   +4
  *
  */
-const char circle_data[] = {
+const xchar circle_data[] = {
     /*  0*/ 0,
     /*  1*/ 1,  1,
     /*  3*/ 2,  2,  1,
@@ -49,7 +49,7 @@ const char circle_data[] = {
  * used for a single point:  temporary light source of a camera flash
  * as it traverses its path.
  */
-const char circle_start[] = {
+const xchar circle_start[] = {
     /* 0*/ 0,
     /* 1*/ 1,
     /* 2*/ 3,
@@ -74,26 +74,26 @@ const char circle_start[] = {
 
 /*------ local variables ------*/
 
-static char could_see[2][ROWNO][COLNO]; /* vision work space */
-static char *cs_rows0[ROWNO], *cs_rows1[ROWNO];
-static char cs_rmin0[ROWNO], cs_rmax0[ROWNO];
-static char cs_rmin1[ROWNO], cs_rmax1[ROWNO];
+static xchar could_see[2][ROWNO][COLNO]; /* vision work space */
+static xchar *cs_rows0[ROWNO], *cs_rows1[ROWNO];
+static xchar cs_rmin0[ROWNO], cs_rmax0[ROWNO];
+static xchar cs_rmin1[ROWNO], cs_rmax1[ROWNO];
 
 static char viz_clear[ROWNO][COLNO]; /* vision clear/blocked map */
 static char *viz_clear_rows[ROWNO];
 
-static char left_ptrs[ROWNO][COLNO]; /* LOS algorithm helpers */
-static char right_ptrs[ROWNO][COLNO];
+static xchar left_ptrs[ROWNO][COLNO]; /* LOS algorithm helpers */
+static xchar right_ptrs[ROWNO][COLNO];
 
 /* Forward declarations. */
 static void FDECL(fill_point, (int, int));
 static void FDECL(dig_point, (int, int));
 static void NDECL(view_init);
-static void FDECL(view_from, (int, int, char **, char *, char *, int,
+static void FDECL(view_from, (int, int, xchar **, xchar *, xchar *, int,
                                   void (*)(int, int, genericptr_t),
                                   genericptr_t));
-static void FDECL(get_unused_cs, (char ***, char **, char **));
-static void FDECL(rogue_vision, (char **, char *, char *));
+static void FDECL(get_unused_cs, (xchar ***, xchar **, xchar **));
+static void FDECL(rogue_vision, (xchar **, xchar *, xchar *));
 
 /* Macro definitions that I can't find anywhere. */
 #define sign(z) ((z) < 0 ? -1 : ((z) ? 1 : 0))
@@ -246,11 +246,11 @@ vision_reset()
  */
 static void
 get_unused_cs(rows, rmin, rmax)
-char ***rows;
-char **rmin, **rmax;
+xchar ***rows;
+xchar **rmin, **rmax;
 {
     register int row;
-    register char *nrmin, *nrmax;
+    register xchar *nrmin, *nrmax;
 
     if (g.viz_array == cs_rows0) {
         *rows = cs_rows1;
@@ -287,8 +287,8 @@ char **rmin, **rmax;
  */
 static void
 rogue_vision(next, rmin, rmax)
-char **next; /* could_see array pointers */
-char *rmin, *rmax;
+xchar **next; /* could_see array pointers */
+xchar *rmin, *rmax;
 {
     int rnum = levl[u.ux][u.uy].roomno - ROOMOFFSET; /* no SHARED... */
     int start, stop, in_door, xhi, xlo, yhi, ylo;
@@ -494,13 +494,13 @@ int control;
 {
     extern unsigned char seenv_matrix[3][3]; /* from display.c */
     static unsigned char colbump[COLNO + 1]; /* cols to bump sv */
-    char **temp_array; /* points to the old vision array */
-    char **next_array; /* points to the new vision array */
-    char *next_row;    /* row pointer for the new array */
-    char *old_row;     /* row pointer for the old array */
-    char *next_rmin;   /* min pointer for the new array */
-    char *next_rmax;   /* max pointer for the new array */
-    const char *ranges; /* circle ranges -- used for xray & night vision */
+    xchar **temp_array; /* points to the old vision array */
+    xchar **next_array; /* points to the new vision array */
+    xchar *next_row;    /* row pointer for the new array */
+    xchar *old_row;     /* row pointer for the old array */
+    xchar *next_rmin;   /* min pointer for the new array */
+    xchar *next_rmax;   /* max pointer for the new array */
+    const xchar *ranges; /* circle ranges -- used for xray & night vision */
     int row = 0;       /* row counter (outer loop)  */
     int start, stop;   /* inner loop starting/stopping index */
     int dx, dy;        /* one step from a lit door or lit wall (see below) */
@@ -1092,9 +1092,9 @@ int row, col;
 static int start_row;
 static int start_col;
 static int step;
-static char **cs_rows;
-static char *cs_left;
-static char *cs_right;
+static xchar **cs_rows;
+static xchar *cs_left;
+static xchar *cs_right;
 
 static void FDECL((*vis_func), (int, int, genericptr_t));
 static genericptr_t varg;
@@ -1605,9 +1605,9 @@ static close2d *close_dy[CLOSE_MAX_BC_DY];
 static far2d *far_dy[FAR_MAX_BC_DY];
 
 static void FDECL(right_side,  (int, int, int, int, int,
-                                    int, int, const char *));
+                                    int, int, const xchar *));
 static void FDECL(left_side, (int, int, int, int, int, int, int, 
-                                    const char *));
+                                    const xchar *));
 static int FDECL(close_shadow, (int, int, int, int));
 static int FDECL(far_shadow, (int, int, int, int));
 
@@ -1720,7 +1720,7 @@ int cb_row, cb_col; /* close block row and col */
 int fb_row, fb_col; /* far block row and col */
 int left;           /* left mark of the previous row */
 int right_mark;     /* right mark of previous row */
-char *limits;       /* points at range limit for current row, or NULL */
+xchar *limits;       /* points at range limit for current row, or NULL */
 {
     register int i;
     register char *rowp = NULL;
@@ -1998,7 +1998,7 @@ int cb_row, cb_col; /* close block row and col */
 int fb_row, fb_col; /* far block row and col */
 int left_mark;      /* left mark of previous row */
 int right;          /* right mark of the previous row */
-const char *limits;
+const xchar *limits;
 {
     register int i;
     register char *rowp = NULL;
@@ -2196,8 +2196,8 @@ const char *limits;
 static void
 view_from(srow, scol, loc_cs_rows, left_most, right_most, range, func, arg)
 int srow, scol;               /* source row and column */
-char **loc_cs_rows;           /* could_see array (row pointers) */
-char *left_most, *right_most; /* limits of what could be seen */
+xchar **loc_cs_rows;           /* could_see array (row pointers) */
+xchar *left_most, *right_most; /* limits of what could be seen */
 int range;                    /* 0 if unlimited */
 void FDECL((*func), (int, int, genericptr_t));
 genericptr_t arg;
@@ -2289,8 +2289,8 @@ genericptr_t arg;
 /*
  * Defines local to Algorithm C.
  */
-static void FDECL(right_side, (int, int, int, const char *));
-static void FDECL(left_side, (int, int, int, const char *));
+static void FDECL(right_side, (int, int, int, const xchar *));
+static void FDECL(left_side, (int, int, int, const xchar *));
 
 /* Initialize algorithm C (nothing). */
 static void
@@ -2307,7 +2307,7 @@ right_side(row, left, right_mark, limits)
 int row;        /* current row */
 int left;       /* first (left side) visible spot on prev row */
 int right_mark; /* last (right side) visible spot on prev row */
-const char *limits;   /* points at range limit for current row, or NULL */
+const xchar *limits;   /* points at range limit for current row, or NULL */
 {
     int right;                  /* right limit of "could see" */
     int right_edge;             /* right edge of an opening */
@@ -2315,9 +2315,9 @@ const char *limits;   /* points at range limit for current row, or NULL */
     int deeper;                 /* if TRUE, call self as needed */
     int result;                 /* set by q?_path() */
     register int i;             /* loop counter */
-    register char *rowp = NULL; /* row optimization */
-    char *row_min = NULL;       /* left most  [used by macro set_min()] */
-    char *row_max = NULL;       /* right most [used by macro set_max()] */
+    register xchar *rowp = NULL; /* row optimization */
+    xchar *row_min = NULL;       /* left most  [used by macro set_min()] */
+    xchar *row_max = NULL;       /* right most [used by macro set_max()] */
     int lim_max;                /* right most limit of circle */
 
     nrow = row + step;
@@ -2497,13 +2497,13 @@ const char *limits;   /* points at range limit for current row, or NULL */
 static void
 left_side(row, left_mark, right, limits)
 int row, left_mark, right;
-const char *limits;
+const xchar *limits;
 {
     int left, left_edge, nrow, deeper, result;
     register int i;
-    register char *rowp = NULL;
-    char *row_min = NULL;
-    char *row_max = NULL;
+    register xchar *rowp = NULL;
+    xchar *row_min = NULL;
+    xchar *row_max = NULL;
     int lim_min;
 
 #ifdef GCC_WARN
@@ -2633,19 +2633,19 @@ const char *limits;
 static void
 view_from(srow, scol, loc_cs_rows, left_most, right_most, range, func, arg)
 int srow, scol;     /* starting row and column */
-char **loc_cs_rows; /* pointers to the rows of the could_see array */
-char *left_most;    /* min mark on each row */
-char *right_most;   /* max mark on each row */
+xchar **loc_cs_rows; /* pointers to the rows of the could_see array */
+xchar *left_most;    /* min mark on each row */
+xchar *right_most;   /* max mark on each row */
 int range;          /* 0 if unlimited */
 void FDECL((*func), (int, int, genericptr_t));
 genericptr_t arg;
 {
     register int i; /* loop counter */
-    char *rowp;     /* optimization for setting could_see */
+    xchar *rowp;     /* optimization for setting could_see */
     int nrow;       /* the next row */
     int left;       /* the left-most visible column */
     int right;      /* the right-most visible column */
-    const char *limits;   /* range limit for next row */
+    const xchar *limits;   /* range limit for next row */
 
     /* Set globals for q?_path(), left_side(), and right_side() to use. */
     start_col = scol;
@@ -2685,7 +2685,7 @@ genericptr_t arg;
         if (right > scol + range)
             right = scol + range;
     } else
-        limits = (char *) 0;
+        limits = (xchar *) 0;
 
     if (func) {
         for (i = left; i <= right; i++)
@@ -2744,12 +2744,12 @@ genericptr_t arg;
 {
     /* If not centered on hero, do the hard work of figuring the area */
     if (scol != u.ux || srow != u.uy) {
-        view_from(srow, scol, (char **) 0, (char *) 0, (char *) 0, range,
+        view_from(srow, scol, (xchar **) 0, (xchar *) 0, (xchar *) 0, range,
                   func, arg);
     } else {
         register int x;
         int y, min_x, max_x, max_y, offset;
-        const char *limits;
+        const xchar *limits;
         boolean override_vision;
 
         /* vision doesn't pass through water or clouds, detection should