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

@@ -213,7 +213,7 @@ schar
get_table_mapchr(lua_State *L, const char *name)
{
char *ter;
xchar typ;
xint8 typ;
ter = get_table_str(L, name);
typ = check_mapchr(ter);
@@ -228,15 +228,15 @@ schar
get_table_mapchr_opt(lua_State *L, const char *name, schar defval)
{
char *ter;
xchar typ;
xint8 typ;
ter = get_table_str_opt(L, name, emptystr);
if (name && *ter) {
typ = check_mapchr(ter);
typ = (xint8) check_mapchr(ter);
if (typ == INVALID_TYPE)
nhl_error(L, "Erroneous map char");
} else
typ = defval;
typ = (xint8) defval;
if (ter)
free(ter);
return typ;
@@ -292,7 +292,7 @@ nhl_add_table_entry_bool(lua_State *L, const char *name, boolean value)
void
nhl_add_table_entry_region(lua_State *L, const char *name,
xchar x1, xchar y1, xchar x2, xchar y2)
coordxy x1, coordxy y1, coordxy x2, coordxy y2)
{
lua_pushstring(L, name);
lua_newtable(L);
@@ -1345,8 +1345,8 @@ nhl_meta_u_index(lua_State *L)
{ "mh", &(u.mh), ANY_INT },
{ "mhmax", &(u.mhmax), ANY_INT },
{ "mtimedone", &(u.mtimedone), ANY_INT },
{ "dlevel", &(u.uz.dlevel), ANY_SCHAR }, /* actually xchar */
{ "dnum", &(u.uz.dnum), ANY_SCHAR }, /* actually xchar */
{ "dlevel", &(u.uz.dlevel), ANY_SCHAR }, /* actually coordxy */
{ "dnum", &(u.uz.dnum), ANY_SCHAR }, /* actually coordxy */
{ "uluck", &(u.uluck), ANY_SCHAR },
{ "uhp", &(u.uhp), ANY_INT },
{ "uhpmax", &(u.uhpmax), ANY_INT },