change xchar to other typedefs

One of the drivers of this change was that screen coordinates require a
type that can hold values greater than 127. Parameters to the window
port routines require a large type in order to be able to have values
a fair bit larger than COLNO and ROWNO passed to them, particularly for
their use to the right of the map window.

This splits the uses of xchar into 3 different situations, and adjusts
their type and size:

                        xchar
                          |
               -----------------------
               |          |          |
            coordxy     xint16     xint8

coordxy: Actual x or y coordinates for various things (moved to 16-bits).

xint16:  Same data size as coordxy, but for non-coordinate use (16-bits).

xint8:   There are only a few use cases initially, where it was very
         plain to see that the variable could remain as 8-bits, rather
         than be bumped to 16-bits.  There are probably more such cases
         that could be changed after additional review.

Note: This first changed all xchar variables to coordxy. Some were
reviewed and got changed to xint16 or xint8 when it became apparent that
their usage was not for coordinates.

This increments EDITLEVEL in patchlevel.h
This commit is contained in:
nhmall
2022-06-30 23:48:18 -04:00
parent 751b6e646f
commit 30b557f7d5
104 changed files with 1016 additions and 996 deletions

View File

@@ -522,7 +522,7 @@ void NetHackQtBind::qt_cliparound_window(winid wid, int x, int y)
}
void NetHackQtBind::qt_print_glyph(
winid wid, xchar x, xchar y,
winid wid, coordxy x, coordxy y,
const glyph_info *glyphinfo,
const glyph_info *bkglyphinfo UNUSED)
{
@@ -533,7 +533,7 @@ void NetHackQtBind::qt_print_glyph(
#if 0
void NetHackQtBind::qt_print_glyph_compose(
winid wid, xchar x, xchar y, int glyph1, int glyph2)
winid wid, coordxy x, coordxy y, int glyph1, int glyph2)
{
NetHackQtWindow *window = id_to_window[(int) wid];
window->PrintGlyphCompose(x, y, glyph1, glyph2);

View File

@@ -63,7 +63,7 @@ public:
static void qt_cliparound(int x, int y);
static void qt_cliparound_window(winid wid, int x, int y);
static void qt_print_glyph(winid wid, xchar x, xchar y,
static void qt_print_glyph(winid wid, coordxy x, coordxy y,
const glyph_info *glyphingo,
const glyph_info *bkglyphinfo);
static void qt_raw_print(const char *str);

View File

@@ -73,7 +73,7 @@ static void display_cursor(struct xwindow *);
void
X11_print_glyph(
winid window,
xchar x, xchar y,
coordxy x, coordxy y,
const glyph_info *glyphinfo,
const glyph_info *bkglyphinfo UNUSED)
{
@@ -894,7 +894,7 @@ display_map_window(struct xwindow *wp)
check_cursor_visibility(wp);
highlight_yn(TRUE); /* change fg/bg to match map */
} else if (wp->prevx != wp->cursx || wp->prevy != wp->cursy) {
register xchar x = wp->prevx, y = wp->prevy;
register coordxy x = wp->prevx, y = wp->prevy;
/*
* Previous cursor position is not the same as the current

View File

@@ -37,7 +37,7 @@ void chainin_cliparound(int, int);
#ifdef POSITIONBAR
void chainin_update_positionbar(char *);
#endif
void chainin_print_glyph(winid, xchar, xchar,
void chainin_print_glyph(winid, coordxy, coordxy,
const glyph_info *, const glyph_info *);
void chainin_raw_print(const char *);
void chainin_raw_print_bold(const char *);
@@ -345,8 +345,8 @@ chainin_update_positionbar(char *posbar)
void
chainin_print_glyph(
winid window,
xchar x,
xchar y,
coordxy x,
coordxy y,
const glyph_info *glyphinfo,
const glyph_info *bkglyphinfo)
{

View File

@@ -37,7 +37,7 @@ void chainout_cliparound(void *,int, int);
#ifdef POSITIONBAR
void chainout_update_positionbar(void *,char *);
#endif
void chainout_print_glyph(void *,winid, xchar, xchar,
void chainout_print_glyph(void *,winid, coordxy, coordxy,
const glyph_info *, const glyph_info *);
void chainout_raw_print(void *,const char *);
void chainout_raw_print_bold(void *,const char *);
@@ -404,8 +404,8 @@ void
chainout_print_glyph(
void *vp,
winid window,
xchar x,
xchar y,
coordxy x,
coordxy y,
const glyph_info *glyphinfo,
const glyph_info *bkglyphinfo)
{

View File

@@ -64,7 +64,7 @@ void trace_cliparound(void *,int, int);
#ifdef POSITIONBAR
void trace_update_positionbar(void *,char *);
#endif
void trace_print_glyph(void *,winid, xchar, xchar,
void trace_print_glyph(void *,winid, coordxy, coordxy,
const glyph_info *, const glyph_info *);
void trace_raw_print(void *,const char *);
void trace_raw_print_bold(void *,const char *);
@@ -645,8 +645,8 @@ void
trace_print_glyph(
void *vp,
winid window,
xchar x,
xchar y,
coordxy x,
coordxy y,
const glyph_info *glyphinfo,
const glyph_info *bkglyphinfo)
{

View File

@@ -771,7 +771,7 @@ print_glyph(window, x, y, glyphinfo, bkglyphinfo)
*/
void
curses_print_glyph(winid wid, xchar x, xchar y,
curses_print_glyph(winid wid, coordxy x, coordxy y,
const glyph_info *glyphinfo, const glyph_info *bkglyphinfo UNUSED)
{
int glyph;

View File

@@ -289,7 +289,7 @@ draw_horizontal(boolean border)
blPAD, blPAD, blPAD, blPAD }
};
const enum statusfields (*fieldorder)[15];
xchar spacing[MAXBLSTATS], valline[MAXBLSTATS];
coordxy spacing[MAXBLSTATS], valline[MAXBLSTATS];
enum statusfields fld, prev_fld;
char *text, *p, cbuf[BUFSZ], ebuf[STATVAL_WIDTH];
#ifdef SCORE_ON_BOTL
@@ -690,7 +690,7 @@ draw_vertical(boolean border)
BL_STR, BL_SCORE, BL_TIME, BL_LEVELDESC, BL_HP,
BL_CONDITION, BL_CAP, BL_HUNGER
};
xchar spacing[MAXBLSTATS];
coordxy spacing[MAXBLSTATS];
int i, fld, cap_and_hunger, time_and_score, cond_count, per_line;
char *text;
#ifdef STATUS_HILITES

View File

@@ -298,8 +298,8 @@ safe_cliparound(int x, int y)
void
safe_print_glyph(
winid window UNUSED,
xchar x UNUSED,
xchar y UNUSED,
coordxy x UNUSED,
coordxy y UNUSED,
const glyph_info *glyphinfo UNUSED,
const glyph_info *bkglyphinfo UNUSED)
{

View File

@@ -141,7 +141,7 @@ VDECLCB(shim_mark_synch,(void), "v")
VDECLCB(shim_wait_synch,(void), "v")
VDECLCB(shim_cliparound,(int x, int y), "vii", A2P x, A2P y)
VDECLCB(shim_update_positionbar,(char *posbar), "vp", P2V posbar)
VDECLCB(shim_print_glyph,(winid w, xchar x, xchar y, const glyph_info *glyphinfo, const glyph_info *bkglyphinfo), "viiipp", A2P w, A2P x, A2P y, P2V glyphinfo, P2V bkglyphinfo)
VDECLCB(shim_print_glyph,(winid w, coordxy x, coordxy y, const glyph_info *glyphinfo, const glyph_info *bkglyphinfo), "viiipp", A2P w, A2P x, A2P y, P2V glyphinfo, P2V bkglyphinfo)
VDECLCB(shim_raw_print,(const char *str), "vs", P2V str)
VDECLCB(shim_raw_print_bold,(const char *str), "vs", P2V str)
DECLCB(int, shim_nhgetch,(void), "i")

View File

@@ -2774,8 +2774,7 @@ tty_destroy_nhwindow(winid window)
}
void
tty_curs(
winid window,
tty_curs(winid window,
register int x, register int y) /* not xchar: perhaps xchar is unsigned
* then curx-x would be unsigned too */
{
@@ -3720,6 +3719,8 @@ tty_update_invent_slot(
cell->refresh = 0;
}
}
tty_curs(window, 1, 0);
ttyDisplay->curx = 1;
calling_from_update_inventory = FALSE;
break;
default:
@@ -4156,7 +4157,7 @@ tty_cliparound(int x, int y)
void
tty_print_glyph(
winid window,
xchar x, xchar y,
coordxy x, coordxy y,
const glyph_info *glyphinfo,
const glyph_info *bkglyphinfo UNUSED)
{

View File

@@ -34,8 +34,8 @@ typedef struct mswin_nhmsg_putstr {
} MSNHMsgPutstr, *PMSNHMsgPutstr;
typedef struct mswin_nhmsg_print_glyph {
xchar x;
xchar y;
coordxy x;
coordxy y;
glyph_info glyphinfo;
glyph_info bkglyphinfo;
} MSNHMsgPrintGlyph, *PMSNHMsgPrintGlyph;

View File

@@ -1315,7 +1315,7 @@ print_glyph(window, x, y, glyphinfo, bkglyphinfo)
*/
void
mswin_print_glyph(winid wid, xchar x, xchar y,
mswin_print_glyph(winid wid, coordxy x, coordxy y,
const glyph_info *glyphinfo, const glyph_info *bkglyphinfo)
{
logDebug("mswin_print_glyph(%d, %d, %d, %d, %d, %lu)\n",

View File

@@ -164,7 +164,7 @@ int mswin_select_menu(winid wid, int how, MENU_ITEM_P **selected);
void mswin_mark_synch(void);
void mswin_wait_synch(void);
void mswin_cliparound(int x, int y);
void mswin_print_glyph(winid wid, xchar x, xchar y,
void mswin_print_glyph(winid wid, coordxy x, coordxy y,
const glyph_info *glyph, const glyph_info *bkglyph);
void mswin_raw_print(const char *str);
void mswin_raw_print_bold(const char *str);