Futureproofing hypothetical type mismatches

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.
This commit is contained in:
Pasi Kallinen
2020-11-14 13:41:31 +02:00
parent 08310c8a71
commit 289c8d654d
8 changed files with 130 additions and 138 deletions

View File

@@ -803,8 +803,8 @@ struct instance_globals {
/* display.c */ /* display.c */
gbuf_entry gbuf[ROWNO][COLNO]; gbuf_entry gbuf[ROWNO][COLNO];
char gbuf_start[ROWNO]; xchar gbuf_start[ROWNO];
char gbuf_stop[ROWNO]; xchar gbuf_stop[ROWNO];
/* do.c */ /* do.c */
@@ -828,7 +828,7 @@ struct instance_globals {
int petname_used; /* user preferred pet name has been used */ int petname_used; /* user preferred pet name has been used */
xchar gtyp; /* type of dog's current goal */ xchar gtyp; /* type of dog's current goal */
xchar gx; /* x position 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 dogname[PL_PSIZ];
char catname[PL_PSIZ]; char catname[PL_PSIZ];
char horsename[PL_PSIZ]; char horsename[PL_PSIZ];
@@ -1169,9 +1169,9 @@ struct instance_globals {
Stormbringer's maliciousness. */ Stormbringer's maliciousness. */
/* vision.c */ /* vision.c */
char **viz_array; /* used in cansee() and couldsee() macros */ xchar **viz_array; /* used in cansee() and couldsee() macros */
char *viz_rmin; /* min could see indices */ xchar *viz_rmin; /* min could see indices */
char *viz_rmax; /* max could see indices */ xchar *viz_rmax; /* max could see indices */
boolean vision_full_recalc; boolean vision_full_recalc;
/* weapon.c */ /* weapon.c */

View 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(new_light_source, (XCHAR_P, XCHAR_P, int, int, ANY_P *));
E void FDECL(del_light_source, (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 FDECL(show_transient_light, (struct obj *, int, int));
E void NDECL(transient_light_cleanup); E void NDECL(transient_light_cleanup);
E struct monst *FDECL(find_mid, (unsigned, unsigned)); 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, E void FDECL(selection_floodfill, (struct selectionvar *, int, int,
BOOLEAN_P)); BOOLEAN_P));
E boolean FDECL(pm_good_location, (int, int, struct permonst *)); 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)); long));
E void FDECL(selection_setpoint, (int, int, struct selectionvar *, XCHAR_P)); E void FDECL(selection_setpoint, (int, int, struct selectionvar *, XCHAR_P));
E struct selectionvar * FDECL(selection_not, (struct selectionvar *)); E struct selectionvar * FDECL(selection_not, (struct selectionvar *));

View File

@@ -9,7 +9,7 @@
/* mkroom.h - types and structures for room and shop initialization */ /* mkroom.h - types and structures for room and shop initialization */
struct mkroom { 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 rtype; /* type of room (zoo, throne, etc...) */
schar orig_rtype; /* same as rtype, but not zeroed later */ schar orig_rtype; /* same as rtype, but not zeroed later */
schar rlit; /* is the room lit ? */ schar rlit; /* is the room lit ? */

View File

@@ -17,7 +17,7 @@
* Incrementing EDITLEVEL can be used to force invalidation of old bones * Incrementing EDITLEVEL can be used to force invalidation of old bones
* and save files. * and save files.
*/ */
#define EDITLEVEL 25 #define EDITLEVEL 26
/* /*
* Development status possibilities. * Development status possibilities.

View File

@@ -48,8 +48,8 @@ static void FDECL(write_ls, (NHFILE *, light_source *));
static int FDECL(maybe_write_ls, (NHFILE *, int, BOOLEAN_P)); static int FDECL(maybe_write_ls, (NHFILE *, int, BOOLEAN_P));
/* imported from vision.c, for small circles */ /* imported from vision.c, for small circles */
extern char circle_data[]; extern xchar circle_data[];
extern char circle_start[]; extern xchar circle_start[];
/* Create a new light source. Caller (and extern.h) doesn't need to know /* 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. */ /* Mark locations that are temporarily lit via mobile light sources. */
void void
do_light_sources(cs_rows) do_light_sources(cs_rows)
char **cs_rows; xchar **cs_rows;
{ {
int x, y, min_x, max_x, max_y, offset; int x, y, min_x, max_x, max_y, offset;
char *limits; xchar *limits;
short at_hero_range = 0; short at_hero_range = 0;
light_source *ls; light_source *ls;
char *row; xchar *row;
for (ls = g.light_base; ls; ls = ls->next) { for (ls = g.light_base; ls; ls = ls->next) {
ls->flags &= ~LSF_SHOW; ls->flags &= ~LSF_SHOW;

View 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_filter_percent, (lua_State *));
static int FDECL(l_selection_rndcoord, (lua_State *)); static int FDECL(l_selection_rndcoord, (lua_State *));
static boolean FDECL(params_sel_2coords, (lua_State *, struct selectionvar **, 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_line, (lua_State *));
static int FDECL(l_selection_randline, (lua_State *)); static int FDECL(l_selection_randline, (lua_State *));
static int FDECL(l_selection_rect, (lua_State *)); static int FDECL(l_selection_rect, (lua_State *));
@@ -143,7 +143,7 @@ l_selection_setpoint(L)
lua_State *L; lua_State *L;
{ {
struct selectionvar *sel = (struct selectionvar *) 0; struct selectionvar *sel = (struct selectionvar *) 0;
schar x = -1, y = -1; xchar x = -1, y = -1;
int val = 1; int val = 1;
int argc = lua_gettop(L); int argc = lua_gettop(L);
long crd = 0L; long crd = 0L;
@@ -153,15 +153,15 @@ lua_State *L;
} else if (argc == 1) { } else if (argc == 1) {
sel = l_selection_check(L, 1); sel = l_selection_check(L, 1);
} else if (argc == 2) { } else if (argc == 2) {
x = (schar) luaL_checkinteger(L, 1); x = (xchar) luaL_checkinteger(L, 1);
y = (schar) luaL_checkinteger(L, 2); y = (xchar) luaL_checkinteger(L, 2);
lua_pop(L, 2); lua_pop(L, 2);
(void) l_selection_new(L); (void) l_selection_new(L);
sel = l_selection_check(L, 1); sel = l_selection_check(L, 1);
} else { } else {
sel = l_selection_check(L, 1); sel = l_selection_check(L, 1);
x = (schar) luaL_checkinteger(L, 2); x = (xchar) luaL_checkinteger(L, 2);
y = (schar) luaL_checkinteger(L, 3); y = (xchar) luaL_checkinteger(L, 3);
val = (int) luaL_optinteger(L, 4, 1); val = (int) luaL_optinteger(L, 4, 1);
} }
@@ -188,8 +188,8 @@ l_selection_getpoint(L)
lua_State *L; lua_State *L;
{ {
struct selectionvar *sel = l_selection_check(L, 1); struct selectionvar *sel = l_selection_check(L, 1);
schar x = (schar) luaL_checkinteger(L, 2); xchar x = (xchar) luaL_checkinteger(L, 2);
schar y = (schar) luaL_checkinteger(L, 3); xchar y = (xchar) luaL_checkinteger(L, 3);
int val; int val;
long crd; long crd;
@@ -344,16 +344,16 @@ static boolean
params_sel_2coords(L, sel, x1,y1, x2,y2) params_sel_2coords(L, sel, x1,y1, x2,y2)
lua_State *L; lua_State *L;
struct selectionvar **sel; struct selectionvar **sel;
schar *x1, *y1, *x2, *y2; xchar *x1, *y1, *x2, *y2;
{ {
int argc = lua_gettop(L); int argc = lua_gettop(L);
if (argc == 4) { if (argc == 4) {
(void) l_selection_new(L); (void) l_selection_new(L);
*x1 = (schar) luaL_checkinteger(L, 1); *x1 = (xchar) luaL_checkinteger(L, 1);
*y1 = (schar) luaL_checkinteger(L, 2); *y1 = (xchar) luaL_checkinteger(L, 2);
*x2 = (schar) luaL_checkinteger(L, 3); *x2 = (xchar) luaL_checkinteger(L, 3);
*y2 = (schar) luaL_checkinteger(L, 4); *y2 = (xchar) luaL_checkinteger(L, 4);
*sel = l_selection_check(L, 5); *sel = l_selection_check(L, 5);
lua_remove(L, 1); lua_remove(L, 1);
lua_remove(L, 1); lua_remove(L, 1);
@@ -362,10 +362,10 @@ schar *x1, *y1, *x2, *y2;
return TRUE; return TRUE;
} else if (argc == 5) { } else if (argc == 5) {
*sel = l_selection_check(L, 1); *sel = l_selection_check(L, 1);
*x1 = (schar) luaL_checkinteger(L, 2); *x1 = (xchar) luaL_checkinteger(L, 2);
*y1 = (schar) luaL_checkinteger(L, 3); *y1 = (xchar) luaL_checkinteger(L, 3);
*x2 = (schar) luaL_checkinteger(L, 4); *x2 = (xchar) luaL_checkinteger(L, 4);
*y2 = (schar) luaL_checkinteger(L, 5); *y2 = (xchar) luaL_checkinteger(L, 5);
lua_pop(L, 4); lua_pop(L, 4);
return TRUE; return TRUE;
} }
@@ -380,10 +380,7 @@ l_selection_line(L)
lua_State *L; lua_State *L;
{ {
struct selectionvar *sel = NULL; struct selectionvar *sel = NULL;
schar x1; xchar x1, y1, x2, y2;
schar y1;
schar x2;
schar y2;
if (!params_sel_2coords(L, &sel, &x1, &y1, &x2, &y2)) { if (!params_sel_2coords(L, &sel, &x1, &y1, &x2, &y2)) {
nhl_error(L, "selection.line: illegal arguments"); nhl_error(L, "selection.line: illegal arguments");
@@ -404,10 +401,7 @@ l_selection_rect(L)
lua_State *L; lua_State *L;
{ {
struct selectionvar *sel = NULL; struct selectionvar *sel = NULL;
schar x1; xchar x1, y1, x2, y2;
schar y1;
schar x2;
schar y2;
if (!params_sel_2coords(L, &sel, &x1, &y1, &x2, &y2)) { if (!params_sel_2coords(L, &sel, &x1, &y1, &x2, &y2)) {
nhl_error(L, "selection.rect: illegal arguments"); nhl_error(L, "selection.rect: illegal arguments");
@@ -437,10 +431,7 @@ lua_State *L;
{ {
struct selectionvar *sel = NULL; struct selectionvar *sel = NULL;
int y; int y;
schar x1; xchar x1, y1, x2, y2;
schar y1;
schar x2;
schar y2;
if (!params_sel_2coords(L, &sel, &x1, &y1, &x2, &y2)) { if (!params_sel_2coords(L, &sel, &x1, &y1, &x2, &y2)) {
nhl_error(L, "selection.fillrect: illegal arguments"); nhl_error(L, "selection.fillrect: illegal arguments");
@@ -473,22 +464,22 @@ lua_State *L;
{ {
int argc = lua_gettop(L); int argc = lua_gettop(L);
struct selectionvar *sel = (struct selectionvar *) 0; struct selectionvar *sel = (struct selectionvar *) 0;
schar x1, y1, x2, y2; xchar x1, y1, x2, y2;
int roughness = 7; int roughness = 7;
if (argc == 6) { if (argc == 6) {
sel = l_selection_check(L, 1); sel = l_selection_check(L, 1);
x1 = (schar) luaL_checkinteger(L, 2); x1 = (xchar) luaL_checkinteger(L, 2);
y1 = (schar) luaL_checkinteger(L, 3); y1 = (xchar) luaL_checkinteger(L, 3);
x2 = (schar) luaL_checkinteger(L, 4); x2 = (xchar) luaL_checkinteger(L, 4);
y2 = (schar) luaL_checkinteger(L, 5); y2 = (xchar) luaL_checkinteger(L, 5);
roughness = (int) luaL_checkinteger(L, 6); roughness = (int) luaL_checkinteger(L, 6);
lua_pop(L, 5); lua_pop(L, 5);
} else if (argc == 5 && lua_type(L, 1) == LUA_TNUMBER) { } else if (argc == 5 && lua_type(L, 1) == LUA_TNUMBER) {
x1 = (schar) luaL_checkinteger(L, 1); x1 = (xchar) luaL_checkinteger(L, 1);
y1 = (schar) luaL_checkinteger(L, 2); y1 = (xchar) luaL_checkinteger(L, 2);
x2 = (schar) luaL_checkinteger(L, 3); x2 = (xchar) luaL_checkinteger(L, 3);
y2 = (schar) luaL_checkinteger(L, 4); y2 = (xchar) luaL_checkinteger(L, 4);
roughness = (int) luaL_checkinteger(L, 5); roughness = (int) luaL_checkinteger(L, 5);
lua_pop(L, 5); lua_pop(L, 5);
(void) l_selection_new(L); (void) l_selection_new(L);
@@ -610,11 +601,11 @@ lua_State *L;
{ {
int argc = lua_gettop(L); int argc = lua_gettop(L);
struct selectionvar *sel = (struct selectionvar *) 0; struct selectionvar *sel = (struct selectionvar *) 0;
schar x, y; xchar x, y;
if (argc == 2) { if (argc == 2) {
x = (schar) luaL_checkinteger(L, 1); x = (xchar) luaL_checkinteger(L, 1);
y = (schar) luaL_checkinteger(L, 2); y = (xchar) luaL_checkinteger(L, 2);
lua_pop(L, 2); lua_pop(L, 2);
(void) l_selection_new(L); (void) l_selection_new(L);
sel = l_selection_check(L, 1); sel = l_selection_check(L, 1);
@@ -644,20 +635,20 @@ lua_State *L;
{ {
int argc = lua_gettop(L); int argc = lua_gettop(L);
struct selectionvar *sel = (struct selectionvar *) 0; struct selectionvar *sel = (struct selectionvar *) 0;
schar x = 0, y = 0; xchar x = 0, y = 0;
int r = 0, filled = 0; int r = 0, filled = 0;
if (argc == 3) { if (argc == 3) {
x = (schar) luaL_checkinteger(L, 1); x = (xchar) luaL_checkinteger(L, 1);
y = (schar) luaL_checkinteger(L, 2); y = (xchar) luaL_checkinteger(L, 2);
r = (int) luaL_checkinteger(L, 3); r = (int) luaL_checkinteger(L, 3);
lua_pop(L, 3); lua_pop(L, 3);
(void) l_selection_new(L); (void) l_selection_new(L);
sel = l_selection_check(L, 1); sel = l_selection_check(L, 1);
filled = 0; filled = 0;
} else if (argc == 4 && lua_type(L, 1) == LUA_TNUMBER) { } else if (argc == 4 && lua_type(L, 1) == LUA_TNUMBER) {
x = (schar) luaL_checkinteger(L, 1); x = (xchar) luaL_checkinteger(L, 1);
y = (schar) luaL_checkinteger(L, 2); y = (xchar) luaL_checkinteger(L, 2);
r = (int) luaL_checkinteger(L, 3); r = (int) luaL_checkinteger(L, 3);
filled = (int) luaL_checkinteger(L, 4); /* TODO: boolean*/ filled = (int) luaL_checkinteger(L, 4); /* TODO: boolean*/
lua_pop(L, 4); lua_pop(L, 4);
@@ -665,8 +656,8 @@ lua_State *L;
sel = l_selection_check(L, 1); sel = l_selection_check(L, 1);
} else if (argc == 4 || argc == 5) { } else if (argc == 4 || argc == 5) {
sel = l_selection_check(L, 1); sel = l_selection_check(L, 1);
x = (schar) luaL_checkinteger(L, 2); x = (xchar) luaL_checkinteger(L, 2);
y = (schar) luaL_checkinteger(L, 3); y = (xchar) luaL_checkinteger(L, 3);
r = (int) luaL_checkinteger(L, 4); r = (int) luaL_checkinteger(L, 4);
filled = (int) luaL_optinteger(L, 5, 0); /* TODO: boolean */ filled = (int) luaL_optinteger(L, 5, 0); /* TODO: boolean */
} else { } else {
@@ -693,12 +684,12 @@ lua_State *L;
{ {
int argc = lua_gettop(L); int argc = lua_gettop(L);
struct selectionvar *sel = (struct selectionvar *) 0; struct selectionvar *sel = (struct selectionvar *) 0;
schar x = 0, y = 0; xchar x = 0, y = 0;
int r1 = 0, r2 = 0, filled = 0; int r1 = 0, r2 = 0, filled = 0;
if (argc == 4) { if (argc == 4) {
x = (schar) luaL_checkinteger(L, 1); x = (xchar) luaL_checkinteger(L, 1);
y = (schar) luaL_checkinteger(L, 2); y = (xchar) luaL_checkinteger(L, 2);
r1 = (int) luaL_checkinteger(L, 3); r1 = (int) luaL_checkinteger(L, 3);
r2 = (int) luaL_checkinteger(L, 4); r2 = (int) luaL_checkinteger(L, 4);
lua_pop(L, 4); lua_pop(L, 4);
@@ -706,8 +697,8 @@ lua_State *L;
sel = l_selection_check(L, 1); sel = l_selection_check(L, 1);
filled = 0; filled = 0;
} else if (argc == 5 && lua_type(L, 1) == LUA_TNUMBER) { } else if (argc == 5 && lua_type(L, 1) == LUA_TNUMBER) {
x = (schar) luaL_checkinteger(L, 1); x = (xchar) luaL_checkinteger(L, 1);
y = (schar) luaL_checkinteger(L, 2); y = (xchar) luaL_checkinteger(L, 2);
r1 = (int) luaL_checkinteger(L, 3); r1 = (int) luaL_checkinteger(L, 3);
r2 = (int) luaL_checkinteger(L, 4); r2 = (int) luaL_checkinteger(L, 4);
filled = (int) luaL_optinteger(L, 5, 0); /* TODO: boolean */ filled = (int) luaL_optinteger(L, 5, 0); /* TODO: boolean */
@@ -716,8 +707,8 @@ lua_State *L;
sel = l_selection_check(L, 1); sel = l_selection_check(L, 1);
} else if (argc == 5 || argc == 6) { } else if (argc == 5 || argc == 6) {
sel = l_selection_check(L, 1); sel = l_selection_check(L, 1);
x = (schar) luaL_checkinteger(L, 2); x = (xchar) luaL_checkinteger(L, 2);
y = (schar) luaL_checkinteger(L, 3); y = (xchar) luaL_checkinteger(L, 3);
r1 = (int) luaL_checkinteger(L, 4); r1 = (int) luaL_checkinteger(L, 4);
r2 = (int) luaL_checkinteger(L, 5); r2 = (int) luaL_checkinteger(L, 5);
filled = (int) luaL_optinteger(L, 6, 0); /* TODO: boolean */ filled = (int) luaL_optinteger(L, 6, 0); /* TODO: boolean */

View File

@@ -42,11 +42,11 @@ static void FDECL(maybe_add_door, (int, int, struct mkroom *));
static void NDECL(link_doors_rooms); static void NDECL(link_doors_rooms);
static int NDECL(rnddoor); static int NDECL(rnddoor);
static int NDECL(rndtrap); 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 boolean FDECL(is_ok_location, (SCHAR_P, SCHAR_P, int));
static unpacked_coord FDECL(get_unpacked_coord, (long, int)); static unpacked_coord FDECL(get_unpacked_coord, (long, int));
static void FDECL(get_room_loc, (schar *, schar *, struct mkroom *)); static void FDECL(get_room_loc, (xchar *, xchar *, struct mkroom *));
static void FDECL(get_free_room_loc, (schar *, schar *, static void FDECL(get_free_room_loc, (xchar *, xchar *,
struct mkroom *, packed_coord)); struct mkroom *, packed_coord));
static boolean FDECL(create_subroom, (struct mkroom *, XCHAR_P, XCHAR_P, static boolean FDECL(create_subroom, (struct mkroom *, XCHAR_P, XCHAR_P,
XCHAR_P, XCHAR_P, XCHAR_P, XCHAR_P)); XCHAR_P, XCHAR_P, XCHAR_P, XCHAR_P));
@@ -1075,7 +1075,7 @@ rndtrap()
*/ */
static void static void
get_location(x, y, humidity, croom) get_location(x, y, humidity, croom)
schar *x, *y; xchar *x, *y;
int humidity; int humidity;
struct mkroom *croom; struct mkroom *croom;
{ {
@@ -1207,7 +1207,7 @@ int defhumidity;
void void
get_location_coord(x, y, humidity, croom, crd) get_location_coord(x, y, humidity, croom, crd)
schar *x, *y; xchar *x, *y;
int humidity; int humidity;
struct mkroom *croom; struct mkroom *croom;
long crd; long crd;
@@ -1230,7 +1230,7 @@ long crd;
static void static void
get_room_loc(x, y, croom) get_room_loc(x, y, croom)
schar *x, *y; xchar *x, *y;
struct mkroom *croom; struct mkroom *croom;
{ {
coord c; coord c;
@@ -1257,11 +1257,11 @@ struct mkroom *croom;
*/ */
static void static void
get_free_room_loc(x, y, croom, pos) get_free_room_loc(x, y, croom, pos)
schar *x, *y; xchar *x, *y;
struct mkroom *croom; struct mkroom *croom;
packed_coord pos; packed_coord pos;
{ {
schar try_x, try_y; xchar try_x, try_y;
register int trycnt = 0; register int trycnt = 0;
get_location_coord(&try_x, &try_y, DRY, croom, pos); get_location_coord(&try_x, &try_y, DRY, croom, pos);
@@ -1741,7 +1741,7 @@ create_trap(t, croom)
spltrap *t; spltrap *t;
struct mkroom *croom; struct mkroom *croom;
{ {
schar x = -1, y = -1; xchar x = -1, y = -1;
coord tm; coord tm;
if (croom) { if (croom) {
@@ -1825,7 +1825,7 @@ monster *m;
struct mkroom *croom; struct mkroom *croom;
{ {
struct monst *mtmp; struct monst *mtmp;
schar x, y; xchar x, y;
char class; char class;
aligntyp amask; aligntyp amask;
coord cc; coord cc;
@@ -2088,7 +2088,7 @@ object *o;
struct mkroom *croom; struct mkroom *croom;
{ {
struct obj *otmp; struct obj *otmp;
schar x, y; xchar x, y;
char c; char c;
boolean named; /* has a name been supplied in level description? */ boolean named; /* has a name been supplied in level description? */
@@ -2324,7 +2324,8 @@ create_altar(a, croom)
altar *a; altar *a;
struct mkroom *croom; struct mkroom *croom;
{ {
schar sproom, x = -1, y = -1; schar sproom;
xchar x = -1, y = -1;
aligntyp amask; aligntyp amask;
boolean croom_is_temple = TRUE; boolean croom_is_temple = TRUE;
int oldtyp; int oldtyp;
@@ -3922,7 +3923,7 @@ lspo_grave(L)
lua_State *L; lua_State *L;
{ {
int argc = lua_gettop(L); int argc = lua_gettop(L);
schar x, y; xchar x, y;
long scoord; long scoord;
int ax,ay; int ax,ay;
char *txt; char *txt;
@@ -4134,7 +4135,7 @@ lspo_gold(L)
lua_State *L; lua_State *L;
{ {
int argc = lua_gettop(L); int argc = lua_gettop(L);
schar x, y; xchar x, y;
long amount; long amount;
long gcoord; long gcoord;
int gx, gy; int gx, gy;
@@ -4885,7 +4886,7 @@ lua_State *L;
-1, D_ISOPEN, D_CLOSED, D_LOCKED, D_NODOOR, D_BROKEN, D_SECRET -1, D_ISOPEN, D_CLOSED, D_LOCKED, D_NODOOR, D_BROKEN, D_SECRET
}; };
int msk; int msk;
schar x,y; xchar x,y;
xchar typ; xchar typ;
int argc = lua_gettop(L); int argc = lua_gettop(L);
@@ -4966,7 +4967,7 @@ lua_State *L;
"throne", "tree", NULL }; "throne", "tree", NULL };
static const int features2i[] = { FOUNTAIN, SINK, POOL, static const int features2i[] = { FOUNTAIN, SINK, POOL,
THRONE, TREE, STONE }; THRONE, TREE, STONE };
schar x,y; xchar x,y;
int typ; int typ;
int argc = lua_gettop(L); int argc = lua_gettop(L);
boolean can_have_flags = FALSE; boolean can_have_flags = FALSE;
@@ -5167,7 +5168,7 @@ lua_State *L;
if (x1 == -1 && y1 == -1 && x2 == -1 && y2 == -1) { if (x1 == -1 && y1 == -1 && x2 == -1 && y2 == -1) {
(void) selection_not(sel); (void) selection_not(sel);
} else { } else {
schar rx1, ry1, rx2, ry2; xchar rx1, ry1, rx2, ry2;
rx1 = x1, ry1 = y1, rx2 = x2, ry2 = x2; rx1 = x1, ry1 = y1, rx2 = x2, ry2 = x2;
get_location(&rx1, &ry1, ANY_LOC, g.coder->croom); get_location(&rx1, &ry1, ANY_LOC, g.coder->croom);
get_location(&rx2, &ry2, 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 char *const wprops[] = { "nondiggable", "nonpasswall", NULL };
static const int wprop2i[] = { W_NONDIGGABLE, W_NONPASSWALL, -1 }; 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; int wprop;
create_des_coder(); create_des_coder();

View File

@@ -23,7 +23,7 @@
* @...X +4 * @...X +4
* *
*/ */
const char circle_data[] = { const xchar circle_data[] = {
/* 0*/ 0, /* 0*/ 0,
/* 1*/ 1, 1, /* 1*/ 1, 1,
/* 3*/ 2, 2, 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 * used for a single point: temporary light source of a camera flash
* as it traverses its path. * as it traverses its path.
*/ */
const char circle_start[] = { const xchar circle_start[] = {
/* 0*/ 0, /* 0*/ 0,
/* 1*/ 1, /* 1*/ 1,
/* 2*/ 3, /* 2*/ 3,
@@ -74,26 +74,26 @@ const char circle_start[] = {
/*------ local variables ------*/ /*------ local variables ------*/
static char could_see[2][ROWNO][COLNO]; /* vision work space */ static xchar could_see[2][ROWNO][COLNO]; /* vision work space */
static char *cs_rows0[ROWNO], *cs_rows1[ROWNO]; static xchar *cs_rows0[ROWNO], *cs_rows1[ROWNO];
static char cs_rmin0[ROWNO], cs_rmax0[ROWNO]; static xchar cs_rmin0[ROWNO], cs_rmax0[ROWNO];
static char cs_rmin1[ROWNO], cs_rmax1[ROWNO]; static xchar cs_rmin1[ROWNO], cs_rmax1[ROWNO];
static char viz_clear[ROWNO][COLNO]; /* vision clear/blocked map */ static char viz_clear[ROWNO][COLNO]; /* vision clear/blocked map */
static char *viz_clear_rows[ROWNO]; static char *viz_clear_rows[ROWNO];
static char left_ptrs[ROWNO][COLNO]; /* LOS algorithm helpers */ static xchar left_ptrs[ROWNO][COLNO]; /* LOS algorithm helpers */
static char right_ptrs[ROWNO][COLNO]; static xchar right_ptrs[ROWNO][COLNO];
/* Forward declarations. */ /* Forward declarations. */
static void FDECL(fill_point, (int, int)); static void FDECL(fill_point, (int, int));
static void FDECL(dig_point, (int, int)); static void FDECL(dig_point, (int, int));
static void NDECL(view_init); 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), void (*)(int, int, genericptr_t),
genericptr_t)); genericptr_t));
static void FDECL(get_unused_cs, (char ***, char **, char **)); static void FDECL(get_unused_cs, (xchar ***, xchar **, xchar **));
static void FDECL(rogue_vision, (char **, char *, char *)); static void FDECL(rogue_vision, (xchar **, xchar *, xchar *));
/* Macro definitions that I can't find anywhere. */ /* Macro definitions that I can't find anywhere. */
#define sign(z) ((z) < 0 ? -1 : ((z) ? 1 : 0)) #define sign(z) ((z) < 0 ? -1 : ((z) ? 1 : 0))
@@ -246,11 +246,11 @@ vision_reset()
*/ */
static void static void
get_unused_cs(rows, rmin, rmax) get_unused_cs(rows, rmin, rmax)
char ***rows; xchar ***rows;
char **rmin, **rmax; xchar **rmin, **rmax;
{ {
register int row; register int row;
register char *nrmin, *nrmax; register xchar *nrmin, *nrmax;
if (g.viz_array == cs_rows0) { if (g.viz_array == cs_rows0) {
*rows = cs_rows1; *rows = cs_rows1;
@@ -287,8 +287,8 @@ char **rmin, **rmax;
*/ */
static void static void
rogue_vision(next, rmin, rmax) rogue_vision(next, rmin, rmax)
char **next; /* could_see array pointers */ xchar **next; /* could_see array pointers */
char *rmin, *rmax; xchar *rmin, *rmax;
{ {
int rnum = levl[u.ux][u.uy].roomno - ROOMOFFSET; /* no SHARED... */ int rnum = levl[u.ux][u.uy].roomno - ROOMOFFSET; /* no SHARED... */
int start, stop, in_door, xhi, xlo, yhi, ylo; 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 */ extern unsigned char seenv_matrix[3][3]; /* from display.c */
static unsigned char colbump[COLNO + 1]; /* cols to bump sv */ static unsigned char colbump[COLNO + 1]; /* cols to bump sv */
char **temp_array; /* points to the old vision array */ xchar **temp_array; /* points to the old vision array */
char **next_array; /* points to the new vision array */ xchar **next_array; /* points to the new vision array */
char *next_row; /* row pointer for the new array */ xchar *next_row; /* row pointer for the new array */
char *old_row; /* row pointer for the old array */ xchar *old_row; /* row pointer for the old array */
char *next_rmin; /* min pointer for the new array */ xchar *next_rmin; /* min pointer for the new array */
char *next_rmax; /* max pointer for the new array */ xchar *next_rmax; /* max pointer for the new array */
const char *ranges; /* circle ranges -- used for xray & night vision */ const xchar *ranges; /* circle ranges -- used for xray & night vision */
int row = 0; /* row counter (outer loop) */ int row = 0; /* row counter (outer loop) */
int start, stop; /* inner loop starting/stopping index */ int start, stop; /* inner loop starting/stopping index */
int dx, dy; /* one step from a lit door or lit wall (see below) */ 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_row;
static int start_col; static int start_col;
static int step; static int step;
static char **cs_rows; static xchar **cs_rows;
static char *cs_left; static xchar *cs_left;
static char *cs_right; static xchar *cs_right;
static void FDECL((*vis_func), (int, int, genericptr_t)); static void FDECL((*vis_func), (int, int, genericptr_t));
static genericptr_t varg; 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 far2d *far_dy[FAR_MAX_BC_DY];
static void FDECL(right_side, (int, int, int, int, int, 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, 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(close_shadow, (int, int, int, int));
static int FDECL(far_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 fb_row, fb_col; /* far block row and col */
int left; /* left mark of the previous row */ int left; /* left mark of the previous row */
int right_mark; /* right mark of 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 int i;
register char *rowp = NULL; 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 fb_row, fb_col; /* far block row and col */
int left_mark; /* left mark of previous row */ int left_mark; /* left mark of previous row */
int right; /* right mark of the previous row */ int right; /* right mark of the previous row */
const char *limits; const xchar *limits;
{ {
register int i; register int i;
register char *rowp = NULL; register char *rowp = NULL;
@@ -2196,8 +2196,8 @@ const char *limits;
static void static void
view_from(srow, scol, loc_cs_rows, left_most, right_most, range, func, arg) view_from(srow, scol, loc_cs_rows, left_most, right_most, range, func, arg)
int srow, scol; /* source row and column */ int srow, scol; /* source row and column */
char **loc_cs_rows; /* could_see array (row pointers) */ xchar **loc_cs_rows; /* could_see array (row pointers) */
char *left_most, *right_most; /* limits of what could be seen */ xchar *left_most, *right_most; /* limits of what could be seen */
int range; /* 0 if unlimited */ int range; /* 0 if unlimited */
void FDECL((*func), (int, int, genericptr_t)); void FDECL((*func), (int, int, genericptr_t));
genericptr_t arg; genericptr_t arg;
@@ -2289,8 +2289,8 @@ genericptr_t arg;
/* /*
* Defines local to Algorithm C. * Defines local to Algorithm C.
*/ */
static void FDECL(right_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 char *)); static void FDECL(left_side, (int, int, int, const xchar *));
/* Initialize algorithm C (nothing). */ /* Initialize algorithm C (nothing). */
static void static void
@@ -2307,7 +2307,7 @@ right_side(row, left, right_mark, limits)
int row; /* current row */ int row; /* current row */
int left; /* first (left side) visible spot on prev row */ int left; /* first (left side) visible spot on prev row */
int right_mark; /* last (right 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; /* right limit of "could see" */
int right_edge; /* right edge of an opening */ 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 deeper; /* if TRUE, call self as needed */
int result; /* set by q?_path() */ int result; /* set by q?_path() */
register int i; /* loop counter */ register int i; /* loop counter */
register char *rowp = NULL; /* row optimization */ register xchar *rowp = NULL; /* row optimization */
char *row_min = NULL; /* left most [used by macro set_min()] */ xchar *row_min = NULL; /* left most [used by macro set_min()] */
char *row_max = NULL; /* right most [used by macro set_max()] */ xchar *row_max = NULL; /* right most [used by macro set_max()] */
int lim_max; /* right most limit of circle */ int lim_max; /* right most limit of circle */
nrow = row + step; nrow = row + step;
@@ -2497,13 +2497,13 @@ const char *limits; /* points at range limit for current row, or NULL */
static void static void
left_side(row, left_mark, right, limits) left_side(row, left_mark, right, limits)
int row, left_mark, right; int row, left_mark, right;
const char *limits; const xchar *limits;
{ {
int left, left_edge, nrow, deeper, result; int left, left_edge, nrow, deeper, result;
register int i; register int i;
register char *rowp = NULL; register xchar *rowp = NULL;
char *row_min = NULL; xchar *row_min = NULL;
char *row_max = NULL; xchar *row_max = NULL;
int lim_min; int lim_min;
#ifdef GCC_WARN #ifdef GCC_WARN
@@ -2633,19 +2633,19 @@ const char *limits;
static void static void
view_from(srow, scol, loc_cs_rows, left_most, right_most, range, func, arg) view_from(srow, scol, loc_cs_rows, left_most, right_most, range, func, arg)
int srow, scol; /* starting row and column */ int srow, scol; /* starting row and column */
char **loc_cs_rows; /* pointers to the rows of the could_see array */ xchar **loc_cs_rows; /* pointers to the rows of the could_see array */
char *left_most; /* min mark on each row */ xchar *left_most; /* min mark on each row */
char *right_most; /* max mark on each row */ xchar *right_most; /* max mark on each row */
int range; /* 0 if unlimited */ int range; /* 0 if unlimited */
void FDECL((*func), (int, int, genericptr_t)); void FDECL((*func), (int, int, genericptr_t));
genericptr_t arg; genericptr_t arg;
{ {
register int i; /* loop counter */ 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 nrow; /* the next row */
int left; /* the left-most visible column */ int left; /* the left-most visible column */
int right; /* the right-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. */ /* Set globals for q?_path(), left_side(), and right_side() to use. */
start_col = scol; start_col = scol;
@@ -2685,7 +2685,7 @@ genericptr_t arg;
if (right > scol + range) if (right > scol + range)
right = scol + range; right = scol + range;
} else } else
limits = (char *) 0; limits = (xchar *) 0;
if (func) { if (func) {
for (i = left; i <= right; i++) 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 not centered on hero, do the hard work of figuring the area */
if (scol != u.ux || srow != u.uy) { 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); func, arg);
} else { } else {
register int x; register int x;
int y, min_x, max_x, max_y, offset; int y, min_x, max_x, max_y, offset;
const char *limits; const xchar *limits;
boolean override_vision; boolean override_vision;
/* vision doesn't pass through water or clouds, detection should /* vision doesn't pass through water or clouds, detection should