From c4c6c3d73a3036433b7172192d5efc98bb6f53be Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 13 Jun 2022 11:30:59 -0700 Subject: [PATCH] simplify streamlined act_on_act() More PR #777: there's no need for there_cmd_menu() to pass absolute instead of for a couple of actions. Those actions can reconstruct by adding to . --- src/cmd.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/cmd.c b/src/cmd.c index 3c27ed945..75f312072 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 cmd.c $NHDT-Date: 1655120485 2022/06/13 11:41:25 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.573 $ */ +/* NetHack 3.7 cmd.c $NHDT-Date: 1655145035 2022/06/13 18:30:35 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.574 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -4927,15 +4927,15 @@ there_cmd_menu_common( static void act_on_act( int act, /* action */ - int dx, int dy) /* delta to adjacent spot (except for couple of cases) */ + int dx, int dy) /* delta to adjacent spot (farther for couple of cases) */ { struct obj *otmp; int dir; switch (act) { case MCMD_TRAVEL: - iflags.travelcc.x = u.tx = dx; /* caller passed x via dx */ - iflags.travelcc.y = u.ty = dy; /* and y via dy */ + iflags.travelcc.x = u.tx = u.ux + dx; + iflags.travelcc.y = u.ty = u.uy + dy; cmdq_add_ec(dotravel_target); break; case MCMD_THROW_OBJ: @@ -5065,8 +5065,8 @@ act_on_act( cmdq_add_ec(dolook); break; case MCMD_LOOK_AT: - g.clicklook_cc.x = dx; /* caller passed x via dx */ - g.clicklook_cc.y = dy; /* and y via dy */ + g.clicklook_cc.x = u.ux + dx; + g.clicklook_cc.y = u.uy + dy; cmdq_add_ec(doclicklook); break; case MCMD_UNTRAP_HERE: @@ -5085,8 +5085,6 @@ act_on_act( } } -#define act_needs_xy(act) ((act) == MCMD_TRAVEL || (act) == MCMD_LOOK_AT) - /* offer choice of actions to perform at adjacent location */ static char there_cmd_menu(int x, int y, int mod) @@ -5124,8 +5122,7 @@ there_cmd_menu(int x, int y, int mod) ch = '\0'; } else if (K == 1 && act != MCMD_NOTHING) { destroy_nhwindow(win); - if (act_needs_xy(act)) - dx = x, dy = y; + act_on_act(act, dx, dy); return '\0'; } else { @@ -5138,17 +5135,12 @@ there_cmd_menu(int x, int y, int mod) act = picks->item.a_int; free((genericptr_t) picks); - /* most actions want but a few want absolute */ - if (act_needs_xy(act)) - dx = x, dy = y; act_on_act(act, dx, dy); return '\0'; } return ch; } -#undef act_needs_xy - static char here_cmd_menu(void) { -- 2.50.1