This adds a new command which repeats the last travel you were doing, bound to meta-underscore. I was inspired to create it when I had a pet master lich who kept teleporting into my way. It also contains an implementation of the travel destination cache, and fixes a bug with the standard travel command (a travel to the current location was taking a turn). This patch was built on patchable Nethack, so you have to apply that patch first. It's at http://www.argon.org/~roderick/nethack/#patchable. Bones/save compatibility: This patch doesn't affect saved games or bones files. This patch is available at http://www.argon.org/~roderick/nethack/. Roderick Schertler diff -r -X /home/roderick/.diff-exclude -uN base.patchable/dat/cmdhelp work.retravel/dat/cmdhelp --- base.patchable/dat/cmdhelp 2003-02-23 09:43:15.000000000 -0500 +++ work.retravel/dat/cmdhelp 2003-03-19 09:51:13.000000000 -0500 @@ -99,6 +99,7 @@ + List known spells # Perform an extended command M-? Display extended command help (if the platform allows this) +M-_ Repeat travel to previous destination M-2 Toggle two-weapon combat (unless number_pad is enabled) M-a Adjust inventory letters M-c Talk to someone diff -r -X /home/roderick/.diff-exclude -uN base.patchable/dat/hh work.retravel/dat/hh --- base.patchable/dat/hh 2003-02-23 09:43:16.000000000 -0500 +++ work.retravel/dat/hh 2003-03-19 09:51:13.000000000 -0500 @@ -84,6 +84,7 @@ via the meta modifier instead of the # prefix: M-? Display extended command help (if the platform allows this) +M-_ repeat travel to previous destination M-2 twoweapon toggle two-weapon combat (unless number_pad is enabled) M-a adjust adjust inventory letters M-c chat talk to someone diff -r -X /home/roderick/.diff-exclude -uN base.patchable/doc/Guidebook.mn work.retravel/doc/Guidebook.mn --- base.patchable/doc/Guidebook.mn 2003-02-23 09:43:18.000000000 -0500 +++ work.retravel/doc/Guidebook.mn 2003-03-19 09:51:13.000000000 -0500 @@ -733,6 +733,8 @@ can be used in this fashion. .lp M-? #? (not supported by all platforms) +.lp M-_ +repeat travel to previous destination .lp M-2 #twoweapon (unless the number_pad option is enabled) .lp M-a diff -r -X /home/roderick/.diff-exclude -uN base.patchable/doc/Guidebook.tex work.retravel/doc/Guidebook.tex --- base.patchable/doc/Guidebook.tex 2003-02-23 09:43:18.000000000 -0500 +++ work.retravel/doc/Guidebook.tex 2003-03-19 09:51:13.000000000 -0500 @@ -977,6 +977,9 @@ \item[\tb{M-?}] {\tt\#?} (not supported by all platforms) %.lp +\item[\tb{M-_}] +repeat travel to previous destination +%.lp \item[\tb{M-2}] {\tt\#twoweapon} (unless the {\it number\_pad\/} option is enabled) %.lp diff -r -X /home/roderick/.diff-exclude -uN base.patchable/src/cmd.c work.retravel/src/cmd.c --- base.patchable/src/cmd.c 2003-02-23 09:43:25.000000000 -0500 +++ work.retravel/src/cmd.c 2003-03-19 09:52:15.000000000 -0500 @@ -108,6 +108,7 @@ STATIC_PTR int NDECL(doextcmd); STATIC_PTR int NDECL(domonability); STATIC_PTR int NDECL(dotravel); +STATIC_PTR int NDECL(doretravel); # ifdef WIZARD STATIC_PTR int NDECL(wiz_wish); STATIC_PTR int NDECL(wiz_identify); @@ -1461,6 +1462,7 @@ {SPBOOK_SYM, TRUE, dovspell}, /* Mike Stephenson */ {'#', TRUE, doextcmd}, {'_', TRUE, dotravel}, + {M('_'), TRUE, doretravel}, {0,0,0,0} }; @@ -2384,13 +2386,20 @@ if (!iflags.travelcmd) return 0; cmd[1]=0; - cc.x = u.ux; - cc.y = u.uy; + if (u.tx > 0 && u.ty > 0) { + cc.x = u.tx; + cc.y = u.ty; + } else { + 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; } + if (u.ux == cc.x && u.uy == cc.y) + return 0; u.tx = cc.x; u.ty = cc.y; cmd[0] = CMD_TRAVEL; @@ -2398,6 +2407,23 @@ return 0; } +STATIC_PTR int +doretravel() +{ + /* Repeat last travel command */ + static char cmd[2]; + if (!u.tx || !u.ty) + return dotravel(); + if (u.tx == u.ux && u.ty == u.uy) { + You("are already here."); + return 0; + } + cmd[0] = CMD_TRAVEL; + cmd[1] = 0; + readchar_queue = cmd; + return 0; +} + #ifdef PORT_DEBUG # ifdef WIN32CON extern void NDECL(win32con_debug_keystrokes); diff -r -X /home/roderick/.diff-exclude -uN base.patchable/src/do.c work.retravel/src/do.c --- base.patchable/src/do.c 2003-02-23 09:43:25.000000000 -0500 +++ work.retravel/src/do.c 2003-03-19 09:51:13.000000000 -0500 @@ -1013,6 +1013,7 @@ u.ustuck = 0; /* idem */ u.uinwater = 0; u.uundetected = 0; /* not hidden, even if means are available */ + u.tx = u.ty = 0; keepdogs(FALSE); if (u.uswallow) /* idem */ u.uswldtim = u.uswallow = 0; diff -r -X /home/roderick/.diff-exclude -uN base.patchable/sys/amiga/amimenu.c work.retravel/sys/amiga/amimenu.c --- base.patchable/sys/amiga/amimenu.c 2003-02-23 09:43:32.000000000 -0500 +++ work.retravel/sys/amiga/amimenu.c 2003-03-19 09:51:13.000000000 -0500 @@ -91,5 +91,6 @@ { NM_ITEM, " Your #conduct", 0, 0, 0, (void *)'#'}, /* "#co\n" */ { NM_ITEM, " #ride your steed", 0, 0, 0, (void *)'#'}, /* "#ri\n" */ { NM_ITEM, "M-2 Switch #twoweapon mode on/off", 0, 0, 0, (void *)(128+'2')}, + { NM_ITEM, "M-_ Repeat travel to previous destination", 0, 0, 0, (void *)(128+'_')}, { NM_END, NULL, 0, 0, 0, 0} }; diff -r -X /home/roderick/.diff-exclude -uN base.patchable/util/makedefs.c work.retravel/util/makedefs.c --- base.patchable/util/makedefs.c 2003-03-18 17:05:58.000000000 -0500 +++ work.retravel/util/makedefs.c 2003-03-19 09:51:13.000000000 -0500 @@ -752,6 +752,10 @@ /* * patch list patch point; see $top/README.patchable */ + "patch: retravel 3.4.1-1", + /* + * patch list patch point; see $top/README.patchable + */ /* * patch list patch point; see $top/README.patchable */