From: PatR Date: Mon, 9 Oct 2017 22:27:24 +0000 (-0700) Subject: fix #H6203 - jumping over water doesn't X-Git-Tag: NetHack-3.6.1_RC01~294 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b3d35898960eb360e163c5e56601a7ecd5453d5;p=nethack fix #H6203 - jumping over water doesn't Accidentally caused by my grappling hook fix 2 months ago, attempting to jump over water made hero enter that water and drown (or crawl out). hurtle_step() was originally intended to be used for recoil while levitating, but it is used in other situations where not levitating and behavior for the two circumstances should be different. This doesn't fix things properly, just gets jumping working again. --- diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 19c92f722..ab147170d 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -509,6 +509,8 @@ hero poly'd into vampire could drain monster down to 0 HP without killing it, "you observe a fog cloud where a vampire/bat was" if an unseen vampire on the far side of a closed door shifted shape to pass under that door fix mention_walls reporting secret doors as solid stone +jumping over water unintentionally moved hero through that water, causing + drowning if not able to water walk or fly Platform- and/or Interface-Specific Fixes diff --git a/include/extern.h b/include/extern.h index cc2bf44dc..31180fd66 100644 --- a/include/extern.h +++ b/include/extern.h @@ -536,11 +536,11 @@ E int FDECL(thitmonst, (struct monst *, struct obj *)); E int FDECL(hero_breaks, (struct obj *, XCHAR_P, XCHAR_P, BOOLEAN_P)); E int FDECL(breaks, (struct obj *, XCHAR_P, XCHAR_P)); E void FDECL(release_camera_demon, (struct obj *, XCHAR_P, XCHAR_P)); -E void FDECL(breakobj, - (struct obj *, XCHAR_P, XCHAR_P, BOOLEAN_P, BOOLEAN_P)); +E void FDECL(breakobj, (struct obj *, XCHAR_P, XCHAR_P, BOOLEAN_P, BOOLEAN_P)); E boolean FDECL(breaktest, (struct obj *)); E boolean FDECL(walk_path, (coord *, coord *, boolean (*)(genericptr, int, int), genericptr_t)); +E boolean FDECL(hurtle_jump, (genericptr_t, int, int)); E boolean FDECL(hurtle_step, (genericptr_t, int, int)); /* ### drawing.c ### */ diff --git a/include/youprop.h b/include/youprop.h index 79fa70a78..d71ec8b5c 100644 --- a/include/youprop.h +++ b/include/youprop.h @@ -227,7 +227,8 @@ && !BFlying) /* May touch surface; does not override any others */ -#define Wwalking (u.uprops[WWALKING].extrinsic && !Is_waterlevel(&u.uz)) +#define EWwalking u.uprops[WWALKING].extrinsic +#define Wwalking (EWwalking && !Is_waterlevel(&u.uz)) /* Don't get wet, can't go under water; overrides others except levitation */ /* Wwalking is meaningless on water level */ diff --git a/src/apply.c b/src/apply.c index c477a4fb8..ca72cc466 100644 --- a/src/apply.c +++ b/src/apply.c @@ -1769,10 +1769,10 @@ int magic; /* 0=Physical, otherwise skill level */ temp = -temp; if (range < temp) range = temp; - (void) walk_path(&uc, &cc, hurtle_step, (genericptr_t) &range); - /* hurtle_step results in (u.ux, u.uy) == (cc.x, cc.y) and usually - * moves the ball if punished, but does not handle all the effects - * of landing on the final position. + (void) walk_path(&uc, &cc, hurtle_jump, (genericptr_t) &range); + /* hurtle_jump -> hurtle_step results in == + * and usually moves the ball if punished, but does not handle all + * the effects of landing on the final position. */ teleds(cc.x, cc.y, FALSE); sokoban_guilt(); diff --git a/src/dothrow.c b/src/dothrow.c index 6c9aeb315..9918e5e77 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -519,6 +519,25 @@ genericptr_t arg; return FALSE; } +/* hack for hurtle_step() -- it ought to be changed to take an argument + indicating lev/fly-to-dest vs lev/fly-to-dest-minus-one-land-on-dest + vs drag-to-dest; original callers use first mode, jumping wants second, + grappling hook backfire and thrown chained ball need third */ +boolean +hurtle_jump(arg, x, y) +genericptr_t arg; +int x, y; +{ + boolean res; + long save_EWwalking = EWwalking; + + /* prevent jumping over water from being placed in that water */ + EWwalking |= I_SPECIAL; + res = hurtle_step(arg, x, y); + EWwalking = save_EWwalking; + return res; +} + /* * Single step for the hero flying through the air from jumping, flying, * etc. Called from hurtle() and jump() via walk_path(). We expect the