]> granicus.if.org Git - nethack/commitdiff
Add new command: #retravel
authorPasi Kallinen <paxed@alt.org>
Wed, 21 Jul 2021 07:55:14 +0000 (10:55 +0300)
committerPasi Kallinen <paxed@alt.org>
Wed, 21 Jul 2021 07:59:08 +0000 (10:59 +0300)
Retravel travels to the previously selected destination.

Also changes the travel-via-mouse to execute the extended command
instead of faking a special key.

doc/Guidebook.mn
doc/fixes37.0
include/decl.h
src/cmd.c

index 8377f28d6d0114fd494f4d9b7ad28b3d0882c80d..d6468d4b8c43be6cdb254742f0d962f4d3aaa07d 100644 (file)
@@ -1432,6 +1432,10 @@ is on.
 .lp "#remove  "
 Remove an accessory (ring, amulet, etc).
 Default key is \(oqR\(cq.
+.lp "#retravel"
+Travel to a previously selected travel destination.
+Default key is \(oqC-_\(cq.
+See also #travel.
 .lp "#ride    "
 Ride (or stop riding) a saddled creature.
 Autocompletes.
@@ -1557,6 +1561,7 @@ When picking a target with cursor and the
 .op autodescribe
 option is on, the top line will show \(lq(no travel path)\(rq if
 your character does not know of a path to that location.
+See also #retravel.
 .lp "#turn    "
 Turn undead away.
 Autocompletes.
index 946edc7da38012e0d4dd012c8d56f3f03d9ac88a..f861e0a347760fd1208054de225be692518acbfe 100644 (file)
@@ -570,6 +570,7 @@ defer encumbrance check during polymorph to new man; newman() -> redist_attr()
        became obsolete if polyman() subsequently restored old attributes
 fix heap-use-after-free when attacking monster with potion
 for "a" vs "an", add ukulele and uke as exceptions for "an u<anything>"
+add new extended command #retravel
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index ab803d0a977ff3d06e577503ed31658072a6aba9..6828ee751fc8804622a6c98fb24ddce27e47344c 100644 (file)
@@ -459,7 +459,6 @@ enum nh_keyfunc {
     NHKF_NOPICKUP,     /* 'm' */
     NHKF_RUN_NOPICKUP, /* 'M' */
     NHKF_DOINV,        /* '0' */
-    NHKF_TRAVEL,       /* via mouse */
     NHKF_CLICKLOOK,
 
     NHKF_REDRAW,
index 2735358fc60b28d13f64b602b827e9244873fa7e..a8f5ee38c20818140ae67b1b7726fca094e360b4 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -16,7 +16,6 @@
 #endif
 #endif
 
-#define CMD_TRAVEL (char) 0x90
 #define CMD_CLICKLOOK (char) 0x8F
 
 #ifdef DUMB /* stuff commented out in extern.h, but needed here */
@@ -105,6 +104,7 @@ static int timed_occupation(void);
 static boolean can_do_extcmd(const struct ext_func_tab *);
 static int doextcmd(void);
 static int dotravel(void);
+static int dotravel_target(void);
 static int doterrain(void);
 static int wiz_wish(void);
 static int wiz_identify(void);
@@ -1998,6 +1998,8 @@ struct ext_func_tab extcmdlist[] = {
               doredraw, IFBURIED | GENERALCMD, NULL },
     { 'R',    "remove", "remove an accessory (ring, amulet, etc)",
               doremring, 0, NULL },
+    { C('_'), "retravel", "travel to previously selected travel location",
+              dotravel_target, 0, NULL },
     { M('R'), "ride", "mount or dismount a saddled steed",
               doride, AUTOCOMPLETE, NULL },
     { M('r'), "rub", "rub a lamp or a stone",
@@ -3048,7 +3050,6 @@ static struct {
     { NHKF_NOPICKUP,         'm', "nopickup" },
     { NHKF_RUN_NOPICKUP,     'M', "run.nopickup" },
     { NHKF_DOINV,            '0', "doinv" },
-    { NHKF_TRAVEL,           CMD_TRAVEL, (char *) 0 }, /* no binding */
     { NHKF_CLICKLOOK,        CMD_CLICKLOOK, (char *) 0 }, /* no binding */
     { NHKF_REDRAW,           C('r'), "redraw" },
     { NHKF_REDRAW2,          C('l'), "redraw.numpad" },
@@ -3547,13 +3548,6 @@ rhack(char *cmd)
             do_look(2, &g.clicklook_cc);
         }
         return;
-    case NHKF_TRAVEL:
-        g.context.travel = 1;
-        g.context.travel1 = 1;
-        g.context.run = 8;
-        g.context.nopick = 1;
-        g.domove_attempting |= DOMOVE_RUSH;
-        break;
     default:
         if (movecmd(*cmd, MV_WALK)) { /* ordinary movement */
             g.context.run = 0; /* only matters here if it was 8 */
@@ -4362,9 +4356,9 @@ click_to_cmd(int x, int y, int mod)
         if (abs(x) <= 1 && abs(y) <= 1) {
             x = sgn(x), y = sgn(y);
         } else {
-            u.tx = u.ux + x;
-            u.ty = u.uy + y;
-            cmd[0] = g.Cmd.spkeys[NHKF_TRAVEL];
+            iflags.travelcc.x = u.tx = u.ux + x;
+            iflags.travelcc.y = u.ty = u.uy + y;
+            cmdq_add_ec(dotravel_target);
             return cmd;
         }
 
@@ -4708,7 +4702,6 @@ readchar_poskey(int *x, int *y, int *mod)
 static int
 dotravel(void)
 {
-    static char cmd[2];
     coord cc;
 
     /*
@@ -4722,7 +4715,6 @@ dotravel(void)
      * there's no reason for the option to disable travel-by-keys.
      */
 
-    cmd[1] = 0;
     cc.x = iflags.travelcc.x;
     cc.y = iflags.travelcc.y;
     if (cc.x == 0 && cc.y == 0) {
@@ -4748,12 +4740,33 @@ dotravel(void)
             return 0;
         }
     }
-    iflags.getloc_travelmode = FALSE;
     iflags.travelcc.x = u.tx = cc.x;
     iflags.travelcc.y = u.ty = cc.y;
-    cmd[0] = g.Cmd.spkeys[NHKF_TRAVEL];
-    readchar_queue = cmd;
-    return 0;
+
+    return dotravel_target();
+}
+
+/* #retravel, travel to iflags.travelcc, which must be set */
+static int
+dotravel_target(void)
+{
+    if (!isok(iflags.travelcc.x, iflags.travelcc.y))
+        return 0;
+
+    iflags.getloc_travelmode = FALSE;
+
+    g.context.travel = 1;
+    g.context.travel1 = 1;
+    g.context.run = 8;
+    g.context.nopick = 1;
+    g.domove_attempting |= DOMOVE_RUSH;
+
+    if (!g.multi)
+        g.multi = max(COLNO, ROWNO);
+    u.last_str_turn = 0;
+    g.context.mv = TRUE;
+
+    return 1;
 }
 
 /*