From 055cc1b4d57151686dfb9f55999f652f9a077509 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Tue, 31 Mar 2015 21:40:49 +0300 Subject: [PATCH 1/4] Show legal jumping positions --- doc/fixes35.0 | 1 + src/apply.c | 68 +++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 53 insertions(+), 16 deletions(-) diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 2d3b8c7ad..46b87d58f 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -893,6 +893,7 @@ boomerang makes noise when hitting a sink non-pet rust monsters would eat rust-proofed non-digestibles but ignore those non-digestibles otherwise kicking a grave may topple the gravestone +allow showing legal jumping positions when asked for location to jump to Platform- and/or Interface-Specific Fixes diff --git a/src/apply.c b/src/apply.c index 386365f49..65482c337 100644 --- a/src/apply.c +++ b/src/apply.c @@ -20,6 +20,7 @@ STATIC_DCL void FDECL(use_candelabrum, (struct obj *)); STATIC_DCL void FDECL(use_candle, (struct obj **)); STATIC_DCL void FDECL(use_lamp, (struct obj *)); STATIC_DCL void FDECL(light_cocktail, (struct obj *)); +STATIC_PTR void FDECL(display_jump_positions, (int)); STATIC_DCL void FDECL(use_tinning_kit, (struct obj *)); STATIC_DCL void FDECL(use_figurine, (struct obj **)); STATIC_DCL void FDECL(use_grease, (struct obj *)); @@ -1361,6 +1362,53 @@ dojump() return jump(0); } +boolean +is_valid_jump_pos(x,y, magic, showmsg) +int x,y, magic; +boolean showmsg; +{ + if (!magic && !(HJumping & ~INTRINSIC) && !EJumping && + distu(x, y) != 5) { + /* The Knight jumping restriction still applies when riding a + * horse. After all, what shape is the knight piece in chess? + */ + if (showmsg) pline("Illegal move!"); + return FALSE; + } else if (distu(x, y) > (magic ? 6+magic*3 : 9)) { + if (showmsg) pline("Too far!"); + return FALSE; + } else if (!cansee(x, y)) { + if (showmsg) You("cannot see where to land!"); + return FALSE; + } else if (!isok(x, y)) { + if (showmsg) You("cannot jump there!"); + return FALSE; + } + return TRUE; +} + +int jumping_is_magic; + +void +display_jump_positions(state) +int state; +{ + if (state == 0) { + tmp_at(DISP_BEAM, cmap_to_glyph(S_flashbeam)); + } else if (state == 1) { + int x,y, dx, dy; + for (dx = -4; dx <= 4; dx++) + for (dy = -4; dy <= 4; dy++) { + x = dx + (int)u.ux; + y = dy + (int)u.uy; + if (isok(x,y) && is_valid_jump_pos(x,y, jumping_is_magic, FALSE)) + tmp_at(x,y); + } + } else { + tmp_at(DISP_END, 0); + } +} + int jump(magic) int magic; /* 0=Physical, otherwise skill level */ @@ -1440,24 +1488,12 @@ int magic; /* 0=Physical, otherwise skill level */ pline("Where do you want to jump?"); cc.x = u.ux; cc.y = u.uy; + jumping_is_magic = magic; + getpos_sethilite(display_jump_positions); if (getpos(&cc, TRUE, "the desired position") < 0) return 0; /* user pressed ESC */ - if (!magic && !(HJumping & ~INTRINSIC) && !EJumping && - distu(cc.x, cc.y) != 5) { - /* The Knight jumping restriction still applies when riding a - * horse. After all, what shape is the knight piece in chess? - */ - pline("Illegal move!"); - return 0; - } else if (distu(cc.x, cc.y) > (magic ? 6+magic*3 : 9)) { - pline("Too far!"); - return 0; - } else if (!cansee(cc.x, cc.y)) { - You("cannot see where to land!"); - return 0; - } else if (!isok(cc.x, cc.y)) { - You("cannot jump there!"); - return 0; + if (!is_valid_jump_pos(cc.x, cc.y, magic, TRUE)) { + return 0; } else { coord uc; int range, temp; From 8fb23b4a4113cf275cb560afdbafc1e07b0d04b0 Mon Sep 17 00:00:00 2001 From: nhmall Date: Tue, 31 Mar 2015 19:07:25 -0400 Subject: [PATCH 2/4] non-Unix build was broken today Changes to be committed: modified: src/cmd.c ../src/cmd.c(515) : warning C4013: 'check_user_string' undefined; assuming extern returning int) link error - cmd.o : error LNK2019: unresolved external symbol _check_user_string referenced in function _enter_explore_mode --- src/cmd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cmd.c b/src/cmd.c index b028c57a3..3798a4fb0 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -510,12 +510,14 @@ enter_explore_mode(VOID_ARGS) You("are already in explore mode."); } else { #ifdef SYSCF +# if defined(UNIX) if (!sysopt.explorers || !sysopt.explorers[0] || !check_user_string(sysopt.explorers)) { You("cannot access explore mode."); return 0; } +# endif #endif pline( "Beware! From explore mode there will be no return to normal game."); From 3f885ef58356453f322f77e5e762cf7b39c67061 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 1 Apr 2015 08:29:12 +0300 Subject: [PATCH 3/4] Remove EXPLORERS from winnt sysconf Stupidly added this to the winnt sysconf, when it should've been *nix only. --- sys/winnt/sysconf | 3 --- 1 file changed, 3 deletions(-) diff --git a/sys/winnt/sysconf b/sys/winnt/sysconf index 808546da8..67c0b814d 100644 --- a/sys/winnt/sysconf +++ b/sys/winnt/sysconf @@ -14,9 +14,6 @@ WIZARDS=* # Uses the same syntax as the WIZARDS option above. #SHELLERS= -# Users allowed to use #exploremode. Same syntax as WIZARDS above. -EXPLORERS=* - # Show debugging information originating from these source files. # Use '*' for all, or list source files separated by spaces. # Only available if game has been compiled with DEBUG. From d3205d98d648a890135b8e07119c9302f35a8ca7 Mon Sep 17 00:00:00 2001 From: PatR Date: Wed, 1 Apr 2015 02:47:04 -0700 Subject: [PATCH 4/4] X11 menu hack for ':' Same functionality as was recently implemented for tty. If a character like ':' is an explicit menu selector and the player types it, select that menu entry rather than treating it as a search request. (Same for other menu commands like '>', but offhand I can't think of anything besides container looting's ': - look inside' that uses any non-letter selectors other than '$', which isn't used as a menu meta command.) --- win/X11/winmenu.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/win/X11/winmenu.c b/win/X11/winmenu.c index b28dc3361..6ab51fae9 100644 --- a/win/X11/winmenu.c +++ b/win/X11/winmenu.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 winmenu.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */ +/* NetHack 3.5 winmenu.c $NHDT-Date: 1427881480 2015/04/01 09:44:40 $ $NHDT-Branch: master $:$NHDT-Revision: 1.5 $ */ /* NetHack 3.5 winmenu.c $Date: 2009/05/06 10:55:53 $ $Revision: 1.5 $ */ /* SCCS Id: @(#)winmenu.c 3.5 1996/08/15 */ /* Copyright (c) Dean Luick, 1992 */ @@ -206,6 +206,7 @@ menu_key(w, event, params, num_params) struct xwindow *wp; char ch; int count; + boolean selected_something; wp = find_widget(w); menu_info = wp->menu_information; @@ -218,6 +219,13 @@ menu_key(w, event, params, num_params) } if (menu_info->is_active) { /* waiting for input */ + /* first check for an explicit selector match, so that it won't be + overridden if it happens to duplicate a mapped menu command (':' + to look inside a container vs ':' to select via search string) */ + for (curr = menu_info->curr_menu.base; curr; curr = curr->next) + if (curr->identifier.a_void != 0 && curr->selector == ch) + goto make_selection; + ch = map_menu_cmd(ch); if (ch == '\033') { /* quit */ if (menu_info->counting) { @@ -294,7 +302,8 @@ menu_key(w, event, params, num_params) X11_nhbell(); return; } else { - boolean selected_something = FALSE; + make_selection: + selected_something = FALSE; for (count = 0, curr = menu_info->curr_menu.base; curr; curr = curr->next, count++) if (curr->identifier.a_void != 0 && curr->selector == ch) break;