Skip to content

Commit 30b557f

Browse files
committed
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
1 parent 751b6e6 commit 30b557f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1016
-996
lines changed

include/context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct engrave_info {
7070
the possible mutations of this */
7171
char *nextc; /* next character(s) in text[] to engrave */
7272
struct obj *stylus; /* object doing the writing */
73-
xchar type; /* type of engraving (DUST, MARK, etc) */
73+
xint8 type; /* type of engraving (DUST, MARK, etc) */
7474
coord pos; /* location the engraving is being placed on */
7575
int actionct; /* nth turn spent engraving */
7676
};
@@ -104,7 +104,7 @@ struct tribute_info {
104104
struct novel_tracking { /* for choosing random passage when reading novel */
105105
unsigned id; /* novel oid from previous passage selection */
106106
int count; /* number of passage indices available in pasg[] */
107-
xchar pasg[30]; /* pasg[0..count-1] are passage indices */
107+
xint8 pasg[30]; /* pasg[0..count-1] are passage indices */
108108
/* tribute file is allowed to have more than 30 passages for a novel;
109109
if it does, reading will first choose a random subset of 30 of them;
110110
reading all 30 or switching to a different novel and then back again

include/coord.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#define COORD_H
88

99
typedef struct nhcoord {
10-
xchar x, y;
10+
coordxy x, y;
1111
} coord;
1212

1313
#endif /* COORD_H */

include/decl.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ struct dgn_topology { /* special dungeon levels for speed */
3232
d_level d_fire_level;
3333
d_level d_air_level;
3434
d_level d_astral_level;
35-
xchar d_tower_dnum;
36-
xchar d_sokoban_dnum;
37-
xchar d_mines_dnum, d_quest_dnum;
35+
xint16 d_tower_dnum;
36+
xint16 d_sokoban_dnum;
37+
xint16 d_mines_dnum, d_quest_dnum;
3838
d_level d_qstart_level, d_qlocate_level, d_nemesis_level;
3939
d_level d_knox_level;
4040
d_level d_mineend_level;
@@ -410,7 +410,7 @@ struct autopickup_exception {
410410
};
411411

412412
struct plinemsg_type {
413-
xchar msgtype; /* one of MSGTYP_foo */
413+
xint16 msgtype; /* one of MSGTYP_foo */
414414
struct nhregex *regex;
415415
char *pattern;
416416
struct plinemsg_type *next;
@@ -545,7 +545,7 @@ struct xlock_s {
545545

546546
struct trapinfo {
547547
struct obj *tobj;
548-
xchar tx, ty;
548+
coordxy tx, ty;
549549
int time_needed;
550550
boolean force_bungle;
551551
};
@@ -564,16 +564,16 @@ enum vanq_order_modes {
564564
};
565565

566566
struct rogueroom {
567-
xchar rlx, rly;
568-
xchar dx, dy;
567+
coordxy rlx, rly;
568+
coordxy dx, dy;
569569
boolean real;
570570
uchar doortable;
571571
int nroom; /* Only meaningful for "real" rooms */
572572
};
573573

574574
typedef struct ls_t {
575575
struct ls_t *next;
576-
xchar x, y; /* source's position */
576+
coordxy x, y; /* source's position */
577577
short range; /* source's current range */
578578
short flags;
579579
short type; /* type of light source */
@@ -582,7 +582,7 @@ typedef struct ls_t {
582582

583583
struct container {
584584
struct container *next;
585-
xchar x, y;
585+
coordxy x, y;
586586
short what;
587587
genericptr_t list;
588588
};
@@ -597,7 +597,7 @@ enum bubble_contains_types {
597597
#define MAX_BMASK 4
598598

599599
struct bubble {
600-
xchar x, y; /* coordinates of the upper left corner */
600+
coordxy x, y; /* coordinates of the upper left corner */
601601
schar dx, dy; /* the general direction of the bubble's movement */
602602
uchar bm[MAX_BMASK + 2]; /* bubble bit mask */
603603
struct bubble *prev, *next; /* need to traverse the list up and down */
@@ -621,7 +621,7 @@ struct h2o_ctx {
621621

622622
struct launchplace {
623623
struct obj *obj;
624-
xchar x, y;
624+
coordxy x, y;
625625
};
626626

627627
struct repo { /* repossession context */
@@ -862,8 +862,8 @@ struct instance_globals {
862862

863863
/* display.c */
864864
gbuf_entry gbuf[ROWNO][COLNO];
865-
xchar gbuf_start[ROWNO];
866-
xchar gbuf_stop[ROWNO];
865+
coordxy gbuf_start[ROWNO];
866+
coordxy gbuf_stop[ROWNO];
867867

868868

869869
/* do.c */
@@ -884,9 +884,9 @@ struct instance_globals {
884884

885885
/* dog.c */
886886
int petname_used; /* user preferred pet name has been used */
887-
xchar gtyp; /* type of dog's current goal */
888-
xchar gx; /* x position of dog's current goal */
889-
xchar gy; /* y position of dog's current goal */
887+
xint16 gtyp; /* type of dog's current goal */
888+
coordxy gx; /* x position of dog's current goal */
889+
coordxy gy; /* y position of dog's current goal */
890890
char dogname[PL_PSIZ];
891891
char catname[PL_PSIZ];
892892
char horsename[PL_PSIZ];
@@ -1000,8 +1000,8 @@ struct instance_globals {
10001000

10011001
/* mklev.c */
10021002
genericptr_t luathemes[MAXDUNGEON];
1003-
xchar vault_x;
1004-
xchar vault_y;
1003+
coordxy vault_x;
1004+
coordxy vault_y;
10051005
boolean made_branch; /* used only during level creation */
10061006

10071007
/* mkmap.c */
@@ -1202,8 +1202,8 @@ struct instance_globals {
12021202
lev_region *lregions;
12031203
int num_lregions;
12041204
struct sp_coder *coder;
1205-
xchar xstart, ystart;
1206-
xchar xsize, ysize;
1205+
coordxy xstart, ystart;
1206+
coordxy xsize, ysize;
12071207
boolean in_mk_themerooms;
12081208
boolean themeroom_failed;
12091209

@@ -1248,9 +1248,9 @@ struct instance_globals {
12481248
Stormbringer's maliciousness. */
12491249

12501250
/* vision.c */
1251-
xchar **viz_array; /* used in cansee() and couldsee() macros */
1252-
xchar *viz_rmin; /* min could see indices */
1253-
xchar *viz_rmax; /* max could see indices */
1251+
coordxy **viz_array; /* used in cansee() and couldsee() macros */
1252+
coordxy *viz_rmin; /* min could see indices */
1253+
coordxy *viz_rmax; /* max could see indices */
12541254
boolean vision_full_recalc;
12551255
int seethru; /* 'bubble' debugging: clouds and water don't block light */
12561256

include/display.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ enum glyph_offsets {
984984
#define MG_BADXY 0x04000 /* bad coordinates were passed */
985985

986986
typedef struct {
987-
xchar gnew; /* perhaps move this bit into the rm structure. */
987+
xint8 gnew; /* perhaps move this bit into the rm structure. */
988988
glyph_info glyphinfo;
989989
} gbuf_entry;
990990

include/dungeon.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#define DUNGEON_H
88

99
typedef struct d_level { /* basic dungeon level element */
10-
xchar dnum; /* dungeon number */
11-
xchar dlevel; /* level number */
10+
xint16 dnum; /* dungeon number */
11+
xint16 dlevel; /* level number */
1212
} d_level;
1313

1414
#if !defined(MAKEDEFS_C) && !defined(MDLIB_C)
@@ -32,7 +32,7 @@ typedef struct s_level { /* special dungeon level element */
3232
} s_level;
3333

3434
typedef struct stairway { /* basic stairway identifier */
35-
xchar sx, sy; /* x / y location of the stair */
35+
coordxy sx, sy; /* x / y location of the stair */
3636
d_level tolev; /* where does it go */
3737
boolean up; /* up or down? */
3838
boolean isladder; /* ladder or stairway? */
@@ -52,10 +52,10 @@ enum level_region_types {
5252
};
5353

5454
typedef struct dest_area { /* non-stairway level change identifier */
55-
xchar lx, ly; /* "lower" left corner (near [0,0]) */
56-
xchar hx, hy; /* "upper" right corner (near [COLNO,ROWNO]) */
57-
xchar nlx, nly; /* outline of invalid area */
58-
xchar nhx, nhy; /* opposite corner of invalid area */
55+
coordxy lx, ly; /* "lower" left corner (near [0,0]) */
56+
coordxy hx, hy; /* "upper" right corner (near [COLNO,ROWNO]) */
57+
coordxy nlx, nly; /* outline of invalid area */
58+
coordxy nhx, nhy; /* opposite corner of invalid area */
5959
} dest_area;
6060

6161
typedef struct dungeon { /* basic dungeon identifier */
@@ -65,9 +65,9 @@ typedef struct dungeon { /* basic dungeon identifier */
6565
char themerms[15]; /* lua file name containing themed rooms */
6666
char boneid; /* character to id dungeon in bones files */
6767
d_flags flags; /* dungeon flags */
68-
xchar entry_lev; /* entry level */
69-
xchar num_dunlevs; /* number of levels in this dungeon */
70-
xchar dunlev_ureached; /* how deep you have been in this dungeon */
68+
xint16 entry_lev; /* entry level */
69+
xint16 num_dunlevs; /* number of levels in this dungeon */
70+
xint16 dunlev_ureached; /* how deep you have been in this dungeon */
7171
int ledger_start, /* the starting depth in "real" terms */
7272
depth_start; /* the starting depth in "logical" terms */
7373
} dungeon;

include/engrave.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
struct engr {
1010
struct engr *nxt_engr;
1111
char *engr_txt;
12-
xchar engr_x, engr_y;
12+
coordxy engr_x, engr_y;
1313
unsigned engr_lth; /* for save & restore; not length of text */
1414
long engr_time; /* moment engraving was (will be) finished */
15-
xchar engr_type;
15+
xint8 engr_type;
1616
#define DUST 1
1717
#define ENGRAVE 2
1818
#define BURN 3

0 commit comments

Comments
 (0)