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:
14
src/worm.c
14
src/worm.c
@@ -11,7 +11,7 @@
|
||||
/* worm segment structure */
|
||||
struct wseg {
|
||||
struct wseg *nseg;
|
||||
xchar wx, wy; /* the segment's position */
|
||||
coordxy wx, wy; /* the segment's position */
|
||||
};
|
||||
|
||||
static void toss_wsegs(struct wseg *, boolean);
|
||||
@@ -368,7 +368,7 @@ wormhitu(struct monst *worm)
|
||||
* that both halves will survive.
|
||||
*/
|
||||
void
|
||||
cutworm(struct monst *worm, xchar x, xchar y,
|
||||
cutworm(struct monst *worm, coordxy x, coordxy y,
|
||||
boolean cuttier) /* hit is by wielded blade or axe or by thrown axe */
|
||||
{
|
||||
struct wseg *curr, *new_tail;
|
||||
@@ -621,7 +621,7 @@ place_wsegs(struct monst *worm, struct monst *oldworm)
|
||||
struct wseg *curr = wtails[worm->wormno];
|
||||
|
||||
while (curr != wheads[worm->wormno]) {
|
||||
xchar x = curr->wx, y = curr->wy;
|
||||
coordxy x = curr->wx, y = curr->wy;
|
||||
struct monst *mtmp = m_at(x, y);
|
||||
|
||||
if (oldworm && mtmp == oldworm)
|
||||
@@ -739,7 +739,7 @@ remove_worm(struct monst *worm)
|
||||
* be, if somehow the head is disjoint from the tail.
|
||||
*/
|
||||
void
|
||||
place_worm_tail_randomly(struct monst *worm, xchar x, xchar y)
|
||||
place_worm_tail_randomly(struct monst *worm, coordxy x, coordxy y)
|
||||
{
|
||||
int wnum = worm->wormno;
|
||||
struct wseg *curr = wtails[wnum];
|
||||
@@ -810,8 +810,8 @@ place_worm_tail_randomly(struct monst *worm, xchar x, xchar y)
|
||||
#endif
|
||||
{
|
||||
place_worm_seg(worm, nx, ny);
|
||||
curr->wx = (xchar) (ox = nx);
|
||||
curr->wy = (xchar) (oy = ny);
|
||||
curr->wx = (coordxy) (ox = nx);
|
||||
curr->wy = (coordxy) (oy = ny);
|
||||
wtails[wnum] = curr;
|
||||
curr = curr->nseg;
|
||||
wtails[wnum]->nseg = new_tail;
|
||||
@@ -985,7 +985,7 @@ wseg_at(struct monst *worm, int x, int y)
|
||||
if (worm && worm->wormno && m_at(x, y) == worm) {
|
||||
struct wseg *curr;
|
||||
int i, n;
|
||||
xchar wx = (xchar) x, wy = (xchar) y;
|
||||
coordxy wx = (coordxy) x, wy = (coordxy) y;
|
||||
|
||||
for (i = 0, curr = wtails[worm->wormno]; curr; curr = curr->nseg) {
|
||||
if (curr->wx == wx && curr->wy == wy)
|
||||
|
||||
Reference in New Issue
Block a user