some coordxy follow-up
Return a couple of variables that actually held a direction back to int from coordxy. bhit() takes int params instead of coordxy. boomhit() takes int params instead of coordxy. xytod() renamed to xytodir(), and takes int params (promotion will handle coordxy params). dtoxy(coord *, int) renamed to dirtocoord(coord *, int).
This commit is contained in:
@@ -449,8 +449,8 @@ extern int enter_explore_mode(void);
|
||||
extern boolean bind_mousebtn(int, const char *);
|
||||
extern boolean bind_key(uchar, const char *);
|
||||
extern void dokeylist(void);
|
||||
extern int xytod(coordxy, coordxy);
|
||||
extern void dtoxy(coord *, int);
|
||||
extern int xytodir(int, int);
|
||||
extern void dirtocoord(coord *, int);
|
||||
extern int movecmd(char, int);
|
||||
extern int dxdy_moveok(void);
|
||||
extern int getdir(const char *);
|
||||
@@ -3957,11 +3957,11 @@ extern int spell_damage_bonus(int);
|
||||
extern const char *exclam(int force) NONNULL;
|
||||
extern void hit(const char *, struct monst *, const char *) NONNULLPTRS;
|
||||
extern void miss(const char *, struct monst *) NONNULLPTRS;
|
||||
extern struct monst *bhit(coordxy, coordxy, int, enum bhit_call_types,
|
||||
extern struct monst *bhit(int, int, int, enum bhit_call_types,
|
||||
int(*)(struct monst *, struct obj *),
|
||||
int(*)(struct obj *, struct obj *),
|
||||
struct obj **) NONNULLARG7;
|
||||
extern struct monst *boomhit(struct obj *, coordxy, coordxy) NONNULLARG1;
|
||||
extern struct monst *boomhit(struct obj *, int, int) NONNULLARG1;
|
||||
extern int zhitm(struct monst *, int, int, struct obj **) NONNULLPTRS;
|
||||
extern int burn_floor_objects(coordxy, coordxy, boolean, boolean);
|
||||
extern void ubuzz(int, int);
|
||||
|
||||
16
src/cmd.c
16
src/cmd.c
@@ -3615,7 +3615,7 @@ rhack(int key)
|
||||
|
||||
/* convert an x,y pair into a direction code */
|
||||
int
|
||||
xytod(coordxy x, coordxy y)
|
||||
xytodir(int x, int y)
|
||||
{
|
||||
int dd;
|
||||
|
||||
@@ -3627,7 +3627,7 @@ xytod(coordxy x, coordxy y)
|
||||
|
||||
/* convert a direction code into an x,y pair */
|
||||
void
|
||||
dtoxy(coord *cc, int dd)
|
||||
dirtocoord(coord *cc, int dd)
|
||||
{
|
||||
if (dd > DIR_ERR && dd < N_DIRS_Z) {
|
||||
cc->x = xdir[dd];
|
||||
@@ -3733,7 +3733,7 @@ getdir(const char *s)
|
||||
if (cmdq) {
|
||||
if (cmdq->typ == CMDQ_DIR) {
|
||||
if (!cmdq->dirz) {
|
||||
dirsym = gc.Cmd.dirchars[xytod(cmdq->dirx, cmdq->diry)];
|
||||
dirsym = gc.Cmd.dirchars[xytodir(cmdq->dirx, cmdq->diry)];
|
||||
} else {
|
||||
dirsym = gc.Cmd.dirchars[(cmdq->dirz > 0) ? DIR_DOWN
|
||||
: DIR_UP];
|
||||
@@ -4501,7 +4501,7 @@ act_on_act(
|
||||
cmdq_add_dir(CQ_CANNED, dx, dy, 0);
|
||||
break;
|
||||
case MCMD_MOVE_DIR:
|
||||
dir = xytod(dx, dy);
|
||||
dir = xytodir(dx, dy);
|
||||
cmdq_add_ec(CQ_CANNED, move_funcs[dir][MV_WALK]);
|
||||
break;
|
||||
case MCMD_RIDE:
|
||||
@@ -4523,7 +4523,7 @@ act_on_act(
|
||||
}
|
||||
break;
|
||||
case MCMD_ATTACK_NEXT2U:
|
||||
dir = xytod(dx, dy);
|
||||
dir = xytodir(dx, dy);
|
||||
cmdq_add_ec(CQ_CANNED, move_funcs[dir][MV_WALK]);
|
||||
break;
|
||||
case MCMD_TALK:
|
||||
@@ -4633,7 +4633,7 @@ there_cmd_menu(coordxy x, coordxy y, int mod)
|
||||
if (!K) {
|
||||
/* no menu options, try to move */
|
||||
if (next2u(x, y) && test_move(u.ux, u.uy, dx, dy, TEST_MOVE)) {
|
||||
int dir = xytod(dx, dy);
|
||||
int dir = xytodir(dx, dy);
|
||||
|
||||
cmdq_add_ec(CQ_CANNED, move_funcs[dir][MV_WALK]);
|
||||
} else if (flags.travelcmd) {
|
||||
@@ -4727,7 +4727,7 @@ domouseaction(void)
|
||||
|
||||
/* directional commands */
|
||||
|
||||
dir = xytod(x, y);
|
||||
dir = xytodir(x, y);
|
||||
if (!m_at(u.ux + x, u.uy + y)
|
||||
&& !test_move(u.ux, u.uy, x, y, TEST_MOVE)) {
|
||||
if (IS_DOOR(levl[u.ux + x][u.uy + y].typ)) {
|
||||
@@ -4766,7 +4766,7 @@ domouseaction(void)
|
||||
cmdq_add_ec(CQ_CANNED, donull);
|
||||
return ECMD_OK;
|
||||
}
|
||||
dir = xytod(x, y);
|
||||
dir = xytodir(x, y);
|
||||
}
|
||||
|
||||
/* move, attack, etc. */
|
||||
|
||||
@@ -1256,7 +1256,7 @@ use_pick_axe2(struct obj *obj)
|
||||
&& (trap_with_u = t_at(u.ux, u.uy))
|
||||
&& is_pit(trap->ttyp)
|
||||
&& !conjoined_pits(trap, trap_with_u, FALSE)) {
|
||||
int idx = xytod(u.dx, u.dy);
|
||||
int idx = xytodir(u.dx, u.dy);
|
||||
|
||||
if (idx != DIR_ERR) {
|
||||
int adjidx = DIR_180(idx);
|
||||
@@ -1617,7 +1617,7 @@ zap_dig(void)
|
||||
if (u.utrap && u.utraptype == TT_PIT
|
||||
&& (trap_with_u = t_at(u.ux, u.uy))) {
|
||||
pitdig = TRUE;
|
||||
diridx = xytod(u.dx, u.dy);
|
||||
diridx = xytodir(u.dx, u.dy);
|
||||
}
|
||||
digdepth = rn1(18, 8);
|
||||
tmp_at(DISP_BEAM, cmap_to_glyph(S_digbeam));
|
||||
|
||||
@@ -1325,14 +1325,14 @@ dog_move(
|
||||
if (goodpos(cc.x, cc.y, mtmp, 0))
|
||||
goto dognext;
|
||||
|
||||
i = xytod(nx, ny);
|
||||
i = xytodir(nx, ny);
|
||||
for (j = DIR_LEFT(i); j < DIR_RIGHT(i); j++) {
|
||||
dtoxy(&cc, j);
|
||||
dirtocoord(&cc, j);
|
||||
if (goodpos(cc.x, cc.y, mtmp, 0))
|
||||
goto dognext;
|
||||
}
|
||||
for (j = DIR_LEFT2(i); j < DIR_RIGHT2(i); j++) {
|
||||
dtoxy(&cc, j);
|
||||
dirtocoord(&cc, j);
|
||||
if (goodpos(cc.x, cc.y, mtmp, 0))
|
||||
goto dognext;
|
||||
}
|
||||
|
||||
@@ -561,7 +561,7 @@ dxdy_to_dist_descr(coordxy dx, coordxy dy, boolean fulldir)
|
||||
|
||||
if (!dx && !dy) {
|
||||
Sprintf(buf, "here");
|
||||
} else if ((dst = xytod(dx, dy)) != -1) {
|
||||
} else if ((dst = xytodir(dx, dy)) != -1) {
|
||||
/* explicit direction; 'one step' is implicit */
|
||||
Sprintf(buf, "%s", directionname(dst));
|
||||
} else {
|
||||
|
||||
@@ -1046,7 +1046,7 @@ test_move(
|
||||
else
|
||||
Sprintf(buf, "impossible [background glyph=%d]",
|
||||
glyph);
|
||||
pline_dir(xytod(dx, dy), "It's %s.", buf);
|
||||
pline_dir(xytodir(dx, dy), "It's %s.", buf);
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
@@ -1197,7 +1197,7 @@ test_move(
|
||||
if (mode != TEST_TRAV && svc.context.run >= 2
|
||||
&& !(Blind || Hallucination) && !could_move_onto_boulder(x, y)) {
|
||||
if (mode == DO_MOVE && flags.mention_walls)
|
||||
pline_dir(xytod(dx,dy), "A boulder blocks your path.");
|
||||
pline_dir(xytodir(dx,dy), "A boulder blocks your path.");
|
||||
return FALSE;
|
||||
}
|
||||
if (mode == DO_MOVE) {
|
||||
@@ -2582,7 +2582,7 @@ move_out_of_bounds(coordxy x, coordxy y)
|
||||
dy = 0;
|
||||
}
|
||||
You("have already gone as far %s as possible.",
|
||||
directionname(xytod(dx, dy)));
|
||||
directionname(xytodir(dx, dy)));
|
||||
}
|
||||
nomul(0);
|
||||
svc.context.move = 0;
|
||||
|
||||
@@ -1348,14 +1348,14 @@ hero_behind_chokepoint(struct monst *mtmp)
|
||||
coordxy x = mtmp->mux + dx;
|
||||
coordxy y = mtmp->muy + dy;
|
||||
|
||||
int dir = xytod(dx, dy);
|
||||
int dir = xytodir(dx, dy);
|
||||
int dir_l = DIR_CLAMP(DIR_LEFT2(dir));
|
||||
int dir_r = DIR_CLAMP(DIR_RIGHT2(dir));
|
||||
|
||||
coord c1, c2;
|
||||
|
||||
dtoxy(&c1, dir_l);
|
||||
dtoxy(&c2, dir_r);
|
||||
dirtocoord(&c1, dir_l);
|
||||
dirtocoord(&c2, dir_r);
|
||||
c1.x += x, c2.x += x;
|
||||
c1.y += y, c2.y += y;
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ putmesg(const char *line)
|
||||
void
|
||||
set_msg_dir(int dir)
|
||||
{
|
||||
dtoxy(&a11y.msg_loc, dir);
|
||||
dirtocoord(&a11y.msg_loc, dir);
|
||||
a11y.msg_loc.x += u.ux;
|
||||
a11y.msg_loc.y += u.uy;
|
||||
}
|
||||
|
||||
@@ -471,7 +471,7 @@ landing_spot(
|
||||
|
||||
(void) memset((genericptr_t) try, 0, sizeof try);
|
||||
n = 0;
|
||||
j = xytod(u.dx, u.dy);
|
||||
j = xytodir(u.dx, u.dy);
|
||||
if (reason == DISMOUNT_KNOCKED && j != DIR_ERR) {
|
||||
/* we'll check preferred location first; if viable it'll be picked */
|
||||
best_j = j;
|
||||
@@ -479,10 +479,10 @@ landing_spot(
|
||||
/* the two next best locations are checked second and third */
|
||||
i = rn2(2);
|
||||
clockwise_j = DIR_RIGHT(j); /* (j + 1) % 8 */
|
||||
dtoxy(&cc, clockwise_j);
|
||||
dirtocoord(&cc, clockwise_j);
|
||||
try[1 + i].x = cc.x, try[1 + i].y = cc.y; /* [1] or [2] */
|
||||
counterclk_j = DIR_LEFT(j); /* (j + 8 - 1) % 8 */
|
||||
dtoxy(&cc, counterclk_j);
|
||||
dirtocoord(&cc, counterclk_j);
|
||||
try[2 - i].x = cc.x, try[2 - i].y = cc.y; /* [2] or [1] */
|
||||
n = 3;
|
||||
debugpline3("knock from saddle: best %s, next %s or %s",
|
||||
@@ -500,7 +500,7 @@ landing_spot(
|
||||
so odd j values are diagonal directions here */
|
||||
if (reason == DISMOUNT_POLY && NODIAG(u.umonnum) && (j % 1) != 0)
|
||||
continue;
|
||||
dtoxy(&cc, j);
|
||||
dirtocoord(&cc, j);
|
||||
try[n++] = cc;
|
||||
}
|
||||
|
||||
|
||||
@@ -6473,7 +6473,7 @@ conjoined_pits(
|
||||
return FALSE;
|
||||
dx = sgn(trap2->tx - trap1->tx);
|
||||
dy = sgn(trap2->ty - trap1->ty);
|
||||
diridx = xytod(dx, dy);
|
||||
diridx = xytodir(dx, dy);
|
||||
if (diridx != DIR_ERR) {
|
||||
adjidx = DIR_180(diridx);
|
||||
if ((trap1->conjoined & (1 << diridx))
|
||||
@@ -6514,7 +6514,7 @@ adj_nonconjoined_pit(struct trap *adjtrap)
|
||||
|
||||
if (trap_with_u && adjtrap && u.utrap && u.utraptype == TT_PIT
|
||||
&& is_pit(trap_with_u->ttyp) && is_pit(adjtrap->ttyp)) {
|
||||
if (xytod(u.dx, u.dy) != DIR_ERR)
|
||||
if (xytodir(u.dx, u.dy) != DIR_ERR)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
@@ -663,7 +663,7 @@ hitum_cleave(
|
||||
int count, umort, x = u.ux, y = u.uy;
|
||||
|
||||
/* find the direction toward primary target */
|
||||
i = xytod(u.dx, u.dy);
|
||||
i = xytodir(u.dx, u.dy);
|
||||
if (i == DIR_ERR) {
|
||||
impossible("hitum_cleave: unknown target direction [%d,%d,%d]?",
|
||||
u.dx, u.dy, u.dz);
|
||||
|
||||
@@ -3814,7 +3814,7 @@ zap_map(
|
||||
*/
|
||||
struct monst *
|
||||
bhit(
|
||||
coordxy ddx, coordxy ddy, int range, /* direction and range */
|
||||
int ddx, int ddy, int range, /* direction and range */
|
||||
enum bhit_call_types weapon, /* defined in hack.h */
|
||||
int (*fhitm)(MONST_P, OBJ_P), /* fns called when mon/obj hit */
|
||||
int (*fhito)(OBJ_P, OBJ_P),
|
||||
@@ -4134,7 +4134,7 @@ bhit(
|
||||
* is too obviously silly.
|
||||
*/
|
||||
struct monst *
|
||||
boomhit(struct obj *obj, coordxy dx, coordxy dy)
|
||||
boomhit(struct obj *obj, int dx, int dy)
|
||||
{
|
||||
int i, ct;
|
||||
int boom; /* showsym[] index */
|
||||
@@ -4158,7 +4158,7 @@ boomhit(struct obj *obj, coordxy dx, coordxy dy)
|
||||
gb.bhitpos.x = u.ux;
|
||||
gb.bhitpos.y = u.uy;
|
||||
boom = counterclockwise ? S_boomleft : S_boomright;
|
||||
i = xytod(dx, dy);
|
||||
i = xytodir(dx, dy);
|
||||
tmp_at(DISP_FLASH, cmap_to_glyph(boom));
|
||||
for (ct = 0; ct < 10; ct++) {
|
||||
i = DIR_CLAMP(i);
|
||||
@@ -4947,7 +4947,7 @@ dobuzz(
|
||||
goto buzzmonst;
|
||||
} else if (zap_hit((int) u.uac, 0)) {
|
||||
range -= 2;
|
||||
pline_dir(xytod(-dx, -dy), "%s hits you!",
|
||||
pline_dir(xytodir(-dx, -dy), "%s hits you!",
|
||||
The(flash_str(fltyp, FALSE)));
|
||||
if (Reflecting) {
|
||||
if (!Blind) {
|
||||
|
||||
Reference in New Issue
Block a user