From 8da4f74dcfb7f005f242848b19eef7d215e2195b Mon Sep 17 00:00:00 2001 From: nhmall Date: Tue, 17 Dec 2024 13:02:05 -0500 Subject: [PATCH] revisit some coordxy casts inherited from time of xchar The ones below marked "left,revisit" might be worthy of code changes explode.c:removed: arg sx,sy passed to breaks() are coordxy and so are the parameters invent.c: removed: discover_artifact() parameter is xint16, so change cast to match mail.c: removed: gv.viz_rmin[] contains coordxy's, and enexto() 2nd param is too mkmaze.c: removed: x, y are coordxy and so are cc->x, cc->y mkroom.c: removed: tx, ty are coordxy and so are parameters to occupied() mplayer.c: left,revisit: x,y declared int, but mk_mplayer() params are coordxy sp_lev.c 2890: left alone: x,y declared int, but is_ok_location() params coordxy sp_lev.c 4114: left alone: cast from lua_Integer sp_lev.c 4123: left alone: cast from lua_Integer sp_lev.c 4650: left alone: cast from lua_Integer returned from lua_tointeger sp_lev.c 4765: left alone: cast from int_Integer returned from lua_tointeger sp_lev.c 4772: left alone: cast from int_Integer returned from get_table_int teleport.c 366: left alone: cast from int returned from rn2() timeout.c 2171: left alone: cast from long vault.c: left,revisit: guardx,guardy declared int, but bestcc fields are coordxy worm.c 791: left,revisit: wseg.wx, wseg.wy are coordxy, so are nx, ny, but not ox, oy; why are ox, oy needed at all? worm.c 955: left alone: wx, wy are coordxy, wseg_at() params are int x, int y zap.c 5061: left alone: cast from long --- src/apply.c | 4 ++-- src/explode.c | 2 +- src/invent.c | 2 +- src/mail.c | 4 ++-- src/mkmaze.c | 8 ++++---- src/mkroom.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/apply.c b/src/apply.c index 7e4c85c1c..f927f7085 100644 --- a/src/apply.c +++ b/src/apply.c @@ -1965,8 +1965,8 @@ display_jump_positions(boolean on_off) tmp_at(DISP_BEAM, cmap_to_glyph(S_goodpos)); for (dx = -4; dx <= 4; dx++) for (dy = -4; dy <= 4; dy++) { - x = dx + (coordxy) u.ux; - y = dy + (coordxy) u.uy; + x = dx + u.ux; + y = dy + u.uy; if (get_valid_jump_position(x, y) && !u_at(x, y)) tmp_at(x, y); } diff --git a/src/explode.c b/src/explode.c index f87c6008d..2aff34776 100644 --- a/src/explode.c +++ b/src/explode.c @@ -807,7 +807,7 @@ scatter(coordxy sx, coordxy sy, /* location of objects to scatter */ } else if ((scflags & MAY_DESTROY) != 0 && (!rn2(10) || (objects[otmp->otyp].oc_material == GLASS || otmp->otyp == EGG))) { - if (breaks(otmp, (coordxy) sx, (coordxy) sy)) + if (breaks(otmp, sx, sy)) used_up = TRUE; } diff --git a/src/invent.c b/src/invent.c index be0dff2cc..11bff7d23 100644 --- a/src/invent.c +++ b/src/invent.c @@ -2537,7 +2537,7 @@ fully_identify_obj(struct obj *otmp) { makeknown(otmp->otyp); if (otmp->oartifact) - discover_artifact((coordxy) otmp->oartifact); + discover_artifact((xint16) otmp->oartifact); otmp->known = otmp->dknown = otmp->bknown = otmp->rknown = 1; set_cknown_lknown(otmp); /* set otmp->{cknown,lknown} if applicable */ if (otmp->otyp == EGG && otmp->corpsenm != NON_PM) diff --git a/src/mail.c b/src/mail.c index c1c62dc78..e6a5c2935 100644 --- a/src/mail.c +++ b/src/mail.c @@ -201,7 +201,7 @@ md_start(coord *startp) startp->y = row; startp->x = gv.viz_rmin[row]; - } else if (enexto(&testcc, (coordxy) gv.viz_rmin[row], row, + } else if (enexto(&testcc, gv.viz_rmin[row], row, (struct permonst *) 0) && !cansee(testcc.x, testcc.y) && couldsee(testcc.x, testcc.y)) { @@ -216,7 +216,7 @@ md_start(coord *startp) startp->y = row; startp->x = gv.viz_rmax[row]; - } else if (enexto(&testcc, (coordxy) gv.viz_rmax[row], row, + } else if (enexto(&testcc, gv.viz_rmax[row], row, (struct permonst *) 0) && !cansee(testcc.x, testcc.y) && couldsee(testcc.x, testcc.y)) { diff --git a/src/mkmaze.c b/src/mkmaze.c index 2aa526ce0..e43b34caf 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -1322,8 +1322,8 @@ mazexy(coord *cc) x = rnd(gx.x_maze_max); y = rnd(gy.y_maze_max); if (levl[x][y].typ == allowedtyp) { - cc->x = (coordxy) x; - cc->y = (coordxy) y; + cc->x = x; + cc->y = y; return; } } while (++cpt < 100); @@ -1331,8 +1331,8 @@ mazexy(coord *cc) for (x = 1; x <= gx.x_maze_max; x++) for (y = 1; y <= gy.y_maze_max; y++) if (levl[x][y].typ == allowedtyp) { - cc->x = (coordxy) x; - cc->y = (coordxy) y; + cc->x = x; + cc->y = y; return; } /* every spot on the area of map allowed for mazes has been rejected */ diff --git a/src/mkroom.c b/src/mkroom.c index 61a913e8f..c9aecb15a 100644 --- a/src/mkroom.c +++ b/src/mkroom.c @@ -293,7 +293,7 @@ fill_zoo(struct mkroom *sroom) (void) somexyspace(sroom, &mm); tx = mm.x; ty = mm.y; - } while (occupied((coordxy) tx, (coordxy) ty) && --i > 0); + } while (occupied(tx, ty) && --i > 0); throne_placed: mk_zoo_thronemon(tx, ty); break;