]> granicus.if.org Git - nethack/commitdiff
SF patch 536615: travel cache
authorcohrs <cohrs>
Mon, 30 Jun 2003 04:00:14 +0000 (04:00 +0000)
committercohrs <cohrs>
Mon, 30 Jun 2003 04:00:14 +0000 (04:00 +0000)
This is derived from the proposed patch and feedback to it.  This applies
the last-position cache behavior without an option, making the behavior
more like it is for interfaces with a mouse, where holding the mouse still
acts the same way as the travel cache.  The code is not #ifdef'd either.

doc/fixes34.2
include/flag.h
src/cmd.c
src/hack.c
src/options.c

index cc9c78f824d27cc859fd419f2243e38335d7cb9a..32a6b64424f380731e58858250526f0d4c6422cf 100644 (file)
@@ -96,6 +96,7 @@ when jousting a pudding into a polymorh trap, it was possible to end up
 don't allow polymorphed player to web over the stairs
 geographical shopkeeper updates
 stethoscope use should be free the first time it's use per player move
+travel command caches last position to make non-mouse less painful
 
 
 Platform- and/or Interface-Specific Fixes
index 61dbda2bb2a6ce3eb40a7dd132f35bf1fa9f2244..16194aa9060663892a06043bb2bdb262275f7aaf 100644 (file)
@@ -176,7 +176,8 @@ struct instance_flags {
        int      purge_monsters;        /* # of dead monsters still on fmon list */
        int *opt_booldup;       /* for duplication of boolean opts in config file */
        int *opt_compdup;       /* for duplication of compound opts in config file */
-       uchar bouldersym;               /* symbol for boulder display */
+       uchar   bouldersym;     /* symbol for boulder display */
+       coord   travelcc;       /* coordinates for travel_cache */
 #ifdef WIZARD
        boolean  sanity_check;  /* run sanity checks */
        boolean  mon_polycontrol;       /* debug: control monster polymorphs */
index 8f12a8dfc46765c37d5ac36dcdd6d8f271f24e96..8240a57794b82fcc4629e54339c6a76573bfcc8b 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -2413,15 +2413,20 @@ dotravel()
 
        if (!flags.travelcmd) return 0;
        cmd[1]=0;
-       cc.x = u.ux;
-       cc.y = u.uy;
+       cc.x = iflags.travelcc.x;
+       cc.y = iflags.travelcc.y;
+       if (cc.x == -1 && cc.y == -1) {
+           /* No cached destination, start attempt from current position */
+           cc.x = u.ux;
+           cc.y = u.uy;
+       }
        pline("Where do you want to travel to?");
        if (getpos(&cc, TRUE, "the desired destination") < 0) {
                /* user pressed ESC */
                return 0;
        }
-       u.tx = cc.x;
-       u.ty = cc.y;
+       iflags.travelcc.x = u.tx = cc.x;
+       iflags.travelcc.y = u.ty = cc.y;
        cmd[0] = CMD_TRAVEL;
        readchar_queue = cmd;
        return 0;
index 1e8b721bdc58dbca3a52d565bcb4cbd6ca05617c..bea9d0ec955ac34f7babc116777812aee6414a17 100644 (file)
@@ -768,6 +768,7 @@ boolean guess;
                                    nomul(0);
                                    /* reset run so domove run checks work */
                                    flags.run = 8;
+                                   iflags.travelcc.x = iflags.travelcc.y = -1;
                                }
                                return TRUE;
                            }
index ad31a8f97daaa9d4141683666b5ef4874b228376..9aea815c175bdbcb20104a4adce4f1365079f19e 100644 (file)
@@ -516,6 +516,7 @@ initoptions()
        for (i = 0; i < WARNCOUNT; i++)
                warnsyms[i] = def_warnsyms[i].sym;
        iflags.bouldersym = 0;
+       iflags.travelcc.x = iflags.travelcc.y = -1;
        flags.warnlevel = 1;
        flags.warntype = 0L;