From 0bef94cfded9761a55db7254e9f0f699e44443a7 Mon Sep 17 00:00:00 2001 From: "Derek S. Ray" Date: Tue, 21 Apr 2015 21:47:33 -0400 Subject: [PATCH 01/10] Make coalescence message be smart about status - honor blindness and hallucination - honor ability to see one of the mergees - provide audible feedback if appropriate - merging inside pack gets special-cased so player knows something different/unusual is happening --- include/extern.h | 3 ++- src/do.c | 4 ++-- src/invent.c | 2 +- src/mon.c | 4 ++-- src/pline.c | 31 ++++++++++++++++++++++++++++++- 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/include/extern.h b/include/extern.h index d034850ee..98ee61f01 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.5 extern.h $NHDT-Date: 1428806395 2015/04/12 02:39:55 $ $NHDT-Branch: master $:$NHDT-Revision: 1.455 $ */ +/* NetHack 3.5 extern.h $NHDT-Date: 1429666893 2015/04/22 01:41:33 $ $NHDT-Branch: master $:$NHDT-Revision: 1.467 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1723,6 +1723,7 @@ E const char *FDECL(align_str, (ALIGNTYP_P)); E void FDECL(mstatusline, (struct monst *)); E void NDECL(ustatusline); E void NDECL(self_invis_message); +E void FDECL(pudding_merge_message, (struct obj*, struct obj*)); /* ### polyself.c ### */ diff --git a/src/do.c b/src/do.c index 476cd2451..6d908be19 100644 --- a/src/do.c +++ b/src/do.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 do.c $NHDT-Date: 1426991040 2015/03/22 02:24:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.111 $ */ +/* NetHack 3.5 do.c $NHDT-Date: 1429666911 2015/04/22 01:41:51 $ $NHDT-Branch: master $:$NHDT-Revision: 1.130 $ */ /* NetHack 3.5 do.c $Date: 2014/11/18 03:10:39 $ $Revision: 1.101 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -217,7 +217,7 @@ const char *verb; } else if (obj->globby) { /* Globby things like puddings might stick together */ while (obj && (otmp = obj_nexto_xy(obj->otyp, x, y, obj->o_id)) != (struct obj*)0) { - pline("The %s coalesce.", makeplural(obj_typename(obj->otyp))); + pudding_merge_message(obj, otmp); obj_meld(&obj, &otmp); } return (obj == NULL); diff --git a/src/invent.c b/src/invent.c index c66129cf0..a7c24fc65 100644 --- a/src/invent.c +++ b/src/invent.c @@ -301,7 +301,7 @@ struct obj **potmp, **pobj; * free the other object automatically so we can just * return out from here. */ if (Is_pudding(obj)) { - pline("The %s coalesce.", makeplural(obj_typename(obj->otyp))); + pudding_merge_message(otmp, obj); obj_absorb(potmp, pobj); return(1); } diff --git a/src/mon.c b/src/mon.c index f73d258ec..ead8f1544 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 mon.c $NHDT-Date: 1429584308 2015/04/21 02:45:08 $ $NHDT-Branch: master $:$NHDT-Revision: 1.164 $ */ +/* NetHack 3.5 mon.c $NHDT-Date: 1429666918 2015/04/22 01:41:58 $ $NHDT-Branch: master $:$NHDT-Revision: 1.165 $ */ /* NetHack 3.5 mon.c $Date: 2012/05/16 02:15:10 $ $Revision: 1.126 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -281,7 +281,7 @@ unsigned corpseflags; x, y, TRUE, FALSE); while ((obj && (otmp = obj_nexto(obj)) != (struct obj*)0)) { - pline("The %s coalesce.", makeplural(obj_typename(obj->otyp))); + pudding_merge_message(obj, otmp); obj = obj_meld(&obj, &otmp); } free_mname(mtmp); diff --git a/src/pline.c b/src/pline.c index 3ee998684..f797448c9 100644 --- a/src/pline.c +++ b/src/pline.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 pline.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */ +/* NetHack 3.5 pline.c $NHDT-Date: 1429666920 2015/04/22 01:42:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.37 $ */ /* NetHack 3.5 pline.c $Date: 2013/02/09 01:33:37 $ $Revision: 1.30 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -489,4 +489,33 @@ self_invis_message() "can't see yourself"); } +void +pudding_merge_message(otmp, otmp2) +struct obj* otmp; +struct obj* otmp2; +{ + boolean visible = cansee(otmp->ox, otmp->oy) || cansee(otmp2->ox, otmp2->oy); + boolean onfloor = otmp->where == OBJ_FLOOR || otmp2->where == OBJ_FLOOR; + boolean inpack = carried(otmp) || carried(otmp2); + + /* the player will know something happened inside his own inventory */ + if ((!Blind && visible) || inpack) { + if (Hallucination) { + if (onfloor) { + You_see("parts of the floor melting!"); + } else if (inpack) { + Your("pack reaches out and grabs something!"); + } + /* even though we can see where they should be, + * they'll be out of our view (minvent or container) + * so don't actually show anything */ + } else if (onfloor || inpack) { + pline("The %s coalesce%s.", makeplural(obj_typename(otmp->otyp)), + inpack ? " inside your pack" : ""); + } + } else { + You_hear("a faint sloshing sound."); + } +} + /*pline.c*/ From 2783157f95e37a8b339f5c3e6269a964c08fc5cb Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 22 Apr 2015 08:35:14 +0300 Subject: [PATCH 02/10] Unify "You are rooted" message --- include/extern.h | 1 + src/do.c | 8 +------- src/hack.c | 23 ++++++++++++++++------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/include/extern.h b/include/extern.h index 98ee61f01..fe22f97e4 100644 --- a/include/extern.h +++ b/include/extern.h @@ -782,6 +782,7 @@ E boolean FDECL(bad_rock, (struct permonst *,XCHAR_P,XCHAR_P)); E int FDECL(cant_squeeze_thru, (struct monst *)); E boolean FDECL(invocation_pos, (XCHAR_P,XCHAR_P)); E boolean FDECL(test_move, (int, int, int, int, int)); +E boolean NDECL(u_rooted); E void NDECL(domove); E boolean NDECL(overexertion); E void NDECL(invocation_message); diff --git a/src/do.c b/src/do.c index 6d908be19..ae941c065 100644 --- a/src/do.c +++ b/src/do.c @@ -840,13 +840,7 @@ dodown() (u.ux == sstairs.sx && u.uy == sstairs.sy && !sstairs.up)), ladder_down = (u.ux == xdnladder && u.uy == ydnladder); - if(!youmonst.data->mmove) { - You("are rooted %s.", - Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) ? - "in place" : "to the ground"); - nomul(0); - return 1; - } + if (u_rooted()) return 1; if (stucksteed(TRUE)) { return 0; diff --git a/src/hack.c b/src/hack.c index cde81937f..ea2a0b3c8 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1111,6 +1111,19 @@ struct trap *desttrap; /* nonnull if another trap at */ return FALSE; } +boolean +u_rooted() +{ + if(!youmonst.data->mmove) { + You("are rooted %s.", + Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) ? + "in place" : "to the ground"); + nomul(0); + return TRUE; + } + return FALSE; +} + void domove() { @@ -1414,13 +1427,9 @@ domove() nomul(0); return; } - if(!youmonst.data->mmove) { - You("are rooted %s.", - Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) ? - "in place" : "to the ground"); - nomul(0); - return; - } + + if (u_rooted()) return; + if(u.utrap) { if (!trapmove(x, y, trap)) return; } From 34d5a4c1f94a3ea1ebbbb5daf2006e50198e337d Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 22 Apr 2015 08:45:03 +0300 Subject: [PATCH 03/10] Unify file removed -trickery --- include/extern.h | 1 + src/do.c | 6 +----- src/save.c | 23 ++++++++++++++++------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/include/extern.h b/include/extern.h index fe22f97e4..406ae8c13 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1981,6 +1981,7 @@ E void NDECL(rumor_check); E int NDECL(dosave); E int NDECL(dosave0); +E boolean FDECL(tricked_fileremoved, (int, char *)); #ifdef INSURANCE E void NDECL(savestateinlock); #endif diff --git a/src/do.c b/src/do.c index ae941c065..03edbb6f1 100644 --- a/src/do.c +++ b/src/do.c @@ -1225,11 +1225,7 @@ boolean at_stairs, falling, portal; } else { /* returning to previously visited level; reload it */ fd = open_levelfile(new_ledger, whynot); - if (fd < 0) { - pline1(whynot); - pline("Probably someone removed it."); - Strcpy(killer.name, whynot); - done(TRICKED); + if (tricked_fileremoved(fd, whynot)) { /* we'll reach here if running in wizard mode */ error("Cannot continue this game."); } diff --git a/src/save.c b/src/save.c index ed0047698..fb695d1ed 100644 --- a/src/save.c +++ b/src/save.c @@ -360,6 +360,21 @@ register int fd, mode; bflush(fd); } +boolean +tricked_fileremoved(fd, whynot) +int fd; +char *whynot; +{ + if (fd < 0) { + pline1(whynot); + pline("Probably someone removed it."); + Strcpy(killer.name, whynot); + done(TRICKED); + return TRUE; + } + return FALSE; +} + #ifdef INSURANCE void savestateinlock() @@ -387,13 +402,7 @@ savestateinlock() * readable by an external utility */ fd = open_levelfile(0, whynot); - if (fd < 0) { - pline1(whynot); - pline("Probably someone removed it."); - Strcpy(killer.name, whynot); - done(TRICKED); - return; - } + if (tricked_fileremoved(fd, whynot)) return; (void) read(fd, (genericptr_t) &hpid, sizeof(hpid)); if (hackpid != hpid) { From 3bf2d17e2cd80151257589b3cbdc8fa523e0826f Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 22 Apr 2015 08:53:13 +0300 Subject: [PATCH 04/10] Unify iron ball unwielding --- include/extern.h | 1 + src/ball.c | 29 ++++++++++++++++++----------- src/do.c | 12 ++---------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/extern.h b/include/extern.h index 406ae8c13..05f7aa244 100644 --- a/include/extern.h +++ b/include/extern.h @@ -119,6 +119,7 @@ E void FDECL(uchangealign, (int,int)); /* ### ball.c ### */ +E void FDECL(ballrelease, (boolean)); E void NDECL(ballfall); E void NDECL(placebc); E void NDECL(unplacebc); diff --git a/src/ball.c b/src/ball.c index b3513f7b5..e1fa4b72a 100644 --- a/src/ball.c +++ b/src/ball.c @@ -10,6 +10,23 @@ STATIC_DCL int NDECL(bc_order); STATIC_DCL void NDECL(litter); +void +ballrelease(showmsg) +boolean showmsg; +{ + if (carried(uball)) { + if (showmsg) pline("Startled, you drop the iron ball."); + if (uwep == uball) + setuwep((struct obj *)0); + if (uswapwep == uball) + setuswapwep((struct obj *)0); + if (uquiver == uball) + setuqwep((struct obj *)0);; + if (uwep != uball) + freeinv(uball); + } +} + void ballfall() { @@ -17,17 +34,7 @@ ballfall() gets_hit = (((uball->ox != u.ux) || (uball->oy != u.uy)) && ((uwep == uball)? FALSE : (boolean)rn2(5))); - if (carried(uball)) { - pline("Startled, you drop the iron ball."); - if (uwep == uball) - setuwep((struct obj *)0); - if (uswapwep == uball) - setuswapwep((struct obj *)0); - if (uquiver == uball) - setuqwep((struct obj *)0);; - if (uwep != uball) - freeinv(uball); - } + ballrelease(TRUE); if(gets_hit){ int dmg = rn1(7,25); pline_The("iron ball falls on your %s.", diff --git a/src/do.c b/src/do.c index 03edbb6f1..e3fe47c79 100644 --- a/src/do.c +++ b/src/do.c @@ -1282,16 +1282,8 @@ boolean at_stairs, falling, portal; Punished || Fumbling) { You("fall down the %s.", at_ladder ? "ladder" : "stairs"); if (Punished) { - drag_down(); - if (carried(uball)) { - if (uwep == uball) - setuwep((struct obj *)0); - if (uswapwep == uball) - setuswapwep((struct obj *)0); - if (uquiver == uball) - setuqwep((struct obj *)0); - freeinv(uball); - } + drag_down(); + ballrelease(FALSE); } /* falling off steed has its own losehp() call */ if (u.usteed) From 171e8284cd8bf18a5ebaf6f2565732bc2af3359e Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 22 Apr 2015 08:58:04 +0300 Subject: [PATCH 05/10] Unify monster gender setting --- include/extern.h | 1 + src/mon.c | 22 +++++++++++++++------- src/sp_lev.c | 10 ++-------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/include/extern.h b/include/extern.h index 05f7aa244..f651976bb 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1308,6 +1308,7 @@ E boolean FDECL(hideunder, (struct monst*)); E void FDECL(hide_monst, (struct monst *)); E void FDECL(mon_animal_list, (BOOLEAN_P)); E int FDECL(select_newcham_form, (struct monst *)); +E void FDECL(mgender_from_permonts, (struct monst *, struct permonst *)); E int FDECL(newcham, (struct monst *,struct permonst *,BOOLEAN_P,BOOLEAN_P)); E int FDECL(can_be_hatched, (int)); E int FDECL(egg_type_from_parent, (int,BOOLEAN_P)); diff --git a/src/mon.c b/src/mon.c index ead8f1544..3a2fc402b 100644 --- a/src/mon.c +++ b/src/mon.c @@ -2745,6 +2745,20 @@ int mndx; return polyok(mdat) ? mdat : 0; } +void +mgender_from_permonst(mtmp, mdat) +struct monst *mtmp; +struct permonst *mdat; +{ + if(is_male(mdat)) { + if(mtmp->female) mtmp->female = FALSE; + } else if (is_female(mdat)) { + if(!mtmp->female) mtmp->female = TRUE; + } else if (!is_neuter(mdat)) { + if(!rn2(10)) mtmp->female = !mtmp->female; + } +} + /* make a chameleon take on another shape, or a polymorph target (possibly self-infliced) become a different monster; returns 1 if it actually changes form */ @@ -2784,13 +2798,7 @@ boolean msg; /* "The oldmon turns into a newmon!" */ } else if (mvitals[monsndx(mdat)].mvflags & G_GENOD) return(0); /* passed in mdat is genocided */ - if(is_male(mdat)) { - if(mtmp->female) mtmp->female = FALSE; - } else if (is_female(mdat)) { - if(!mtmp->female) mtmp->female = TRUE; - } else if (!is_neuter(mdat)) { - if(!rn2(10)) mtmp->female = !mtmp->female; - } + mgender_from_permonst(mtmp, mdat); if (In_endgame(&u.uz) && is_mplayer(olddata) && has_mname(mtmp)) { /* mplayers start out as "Foo the Bar", but some of the diff --git a/src/sp_lev.c b/src/sp_lev.c index 3acac5032..b7faf4a68 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -1499,14 +1499,8 @@ struct mkroom *croom; if ((mndx != NON_PM) && (&mons[mndx] != mtmp->data)) { struct permonst *mdat = &mons[mndx]; struct permonst *olddata = mtmp->data; - /* this code duplicated from newcham() */ - if(is_male(mdat)) { - if(mtmp->female) mtmp->female = FALSE; - } else if (is_female(mdat)) { - if(!mtmp->female) mtmp->female = TRUE; - } else if (!is_neuter(mdat)) { - if(!rn2(10)) mtmp->female = !mtmp->female; - } + + mgender_from_permonst(mtmp, mdat); set_mon_data(mtmp, mdat, 0); if (emits_light(olddata) != emits_light(mtmp->data)) { /* used to give light, now doesn't, or vice versa, From 6d4aa312e6251e97a182a4f99fe85cc2cda5243b Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 22 Apr 2015 09:02:38 +0300 Subject: [PATCH 06/10] Unify hero free hand check and msg --- include/extern.h | 1 + src/pickup.c | 23 ++++++++++++++++------- src/steed.c | 9 +-------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/include/extern.h b/include/extern.h index f651976bb..d5d6bbb47 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1701,6 +1701,7 @@ E struct obj *FDECL(pick_obj, (struct obj *)); E int NDECL(encumber_msg); E int NDECL(doloot); E boolean FDECL(container_gone, (int (*)(OBJ_P))); +E boolean NDECL(u_handsy); E int FDECL(use_container, (struct obj **,int)); E int FDECL(loot_mon, (struct monst *,int *,boolean *)); E int NDECL(dotip); diff --git a/src/pickup.c b/src/pickup.c index fe6a991a5..3866c2287 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -2099,6 +2099,19 @@ explain_container_prompt() } } +boolean +u_handsy() +{ + if (nohands(youmonst.data)) { + You("have no hands!"); /* not `body_part(HAND)' */ + return FALSE; + } else if (!freehand()) { + You("have no free %s.", body_part(HAND)); + return FALSE; + } + return TRUE; +} + static const char stashable[] = { ALLOW_COUNT, COIN_CLASS, ALL_CLASSES, 0 }; int @@ -2115,13 +2128,9 @@ int held; int used = 0; emptymsg[0] = '\0'; - if (nohands(youmonst.data)) { - You("have no hands!"); /* not `body_part(HAND)' */ - return 0; - } else if (!freehand()) { - You("have no free %s.", body_part(HAND)); - return 0; - } + + if (!u_handsy()) return 0; + if (obj->olocked) { pline("%s locked.", Tobjnam(obj, "are")); if (held) You("must put it down to unlock."); diff --git a/src/steed.c b/src/steed.c index a18b418b9..8bfe3fe0e 100644 --- a/src/steed.c +++ b/src/steed.c @@ -46,14 +46,7 @@ use_saddle(otmp) const char *s; - /* Can you use it? */ - if (nohands(youmonst.data)) { - You("have no hands!"); /* not `body_part(HAND)' */ - return 0; - } else if (!freehand()) { - You("have no free %s.", body_part(HAND)); - return 0; - } + if (!u_handsy()) return 0; /* Select an animal */ if (u.uswallow || Underwater || !getdir((char *)0)) { From 75e7d837e618b530146edaf83bd32c4aa53fc92b Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 22 Apr 2015 09:16:49 +0300 Subject: [PATCH 07/10] Unify food-related conducts when eating a monster --- include/extern.h | 1 + src/eat.c | 24 +++++++++++++----------- src/uhitm.c | 10 ++-------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/include/extern.h b/include/extern.h index d5d6bbb47..b5648f0bf 100644 --- a/include/extern.h +++ b/include/extern.h @@ -607,6 +607,7 @@ E void NDECL(vomit); E int FDECL(eaten_stat, (int,struct obj *)); E void FDECL(food_disappears, (struct obj *)); E void FDECL(food_substitution, (struct obj *,struct obj *)); +E void FDECL(eating_conducts, (struct permonst *)); E int FDECL(eat_brains, (struct monst *,struct monst *,BOOLEAN_P,int *)); E void NDECL(fix_petrification); E void FDECL(consume_oeaten, (struct obj *,int)); diff --git a/src/eat.c b/src/eat.c index 2226a7b37..5e12876f5 100644 --- a/src/eat.c +++ b/src/eat.c @@ -431,6 +431,17 @@ boolean message; context.victual.fullwarn = context.victual.eating = context.victual.doreset = FALSE; } +void +eating_conducts(pd) +struct permonst *pd; +{ + u.uconduct.food++; + if (!vegan(pd)) + u.uconduct.unvegan++; + if (!vegetarian(pd)) + violated_vegetarian(); +} + /* handle side-effects of mind flayer's tentacle attack */ int eat_brains(magr, mdef, visflag, dmg_p) @@ -483,11 +494,7 @@ int *dmg_p; /* for dishing out extra damage in lieu of Int loss */ /* * player mind flayer is eating something's brain */ - u.uconduct.food++; - if (!vegan(pd)) - u.uconduct.unvegan++; - if (!vegetarian(pd)) - violated_vegetarian(); + eating_conducts(pd); if (mindless(pd)) { /* (cannibalism not possible here) */ pline("%s doesn't notice.", Monnam(mdef)); /* all done; no extra harm inflicted upon target */ @@ -1270,12 +1277,7 @@ const char *mesg; You("consume %s %s.", tintxts[r].txt, mons[mnum].mname); - /* KMH, conduct */ - u.uconduct.food++; - if (!vegan(&mons[mnum])) - u.uconduct.unvegan++; - if (!vegetarian(&mons[mnum])) - violated_vegetarian(); + eating_conducts(&mons[mnum]); tin->dknown = tin->known = 1; cprefx(mnum); diff --git a/src/uhitm.c b/src/uhitm.c index 50c0523f6..19361c261 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -1809,14 +1809,8 @@ register struct attack *mattk; (mattk->adtyp == AD_DGST && (is_rider(pd) || (pd == &mons[PM_MEDUSA] && !Stone_resistance))); - if ((mattk->adtyp == AD_DGST && !Slow_digestion) || fatal_gulp) { - /* KMH, conduct */ - u.uconduct.food++; - if (!vegan(pd)) - u.uconduct.unvegan++; - if (!vegetarian(pd)) - violated_vegetarian(); - } + if ((mattk->adtyp == AD_DGST && !Slow_digestion) || fatal_gulp) + eating_conducts(pd); if (fatal_gulp && !is_rider(pd)) { /* petrification */ char kbuf[BUFSZ]; From bd69677933012af28b2057e6fd9c83deceff573f Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 22 Apr 2015 09:23:54 +0300 Subject: [PATCH 08/10] Unify stumbling on door mimic --- include/extern.h | 1 + src/lock.c | 26 +++++++++++++++++--------- src/trap.c | 9 +-------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/include/extern.h b/include/extern.h index b5648f0bf..1cb0d673d 100644 --- a/include/extern.h +++ b/include/extern.h @@ -984,6 +984,7 @@ E int NDECL(doforce); E boolean FDECL(boxlock, (struct obj *,struct obj *)); E boolean FDECL(doorlock, (struct obj *,int,int)); E int NDECL(doopen); +E boolean FDECL(stumble_on_door_mimic, (int,int)); E int FDECL(doopen_indir, (int,int)); E int NDECL(doclose); diff --git a/src/lock.c b/src/lock.c index 26abde26a..ed629e93c 100644 --- a/src/lock.c +++ b/src/lock.c @@ -526,6 +526,22 @@ doopen() /* try to open a door */ return doopen_indir(0, 0); } +boolean +stumble_on_door_mimic(x,y) +int x,y; +{ + struct monst *mtmp; + if ((mtmp = m_at(x,y)) && + mtmp->m_ap_type == M_AP_FURNITURE && + (mtmp->mappearance == S_hcdoor || + mtmp->mappearance == S_vcdoor) && + !Protection_from_shape_changers) { + stumble_onto_mimic(mtmp); + return TRUE; + } + return FALSE; +} + int doopen_indir(x, y) /* try to open a door in direction u.dx/u.dy */ int x, y; @@ -554,15 +570,7 @@ int x, y; if((cc.x == u.ux) && (cc.y == u.uy)) return(0); - if ((mtmp = m_at(cc.x,cc.y)) && - mtmp->m_ap_type == M_AP_FURNITURE && - (mtmp->mappearance == S_hcdoor || - mtmp->mappearance == S_vcdoor) && - !Protection_from_shape_changers) { - - stumble_onto_mimic(mtmp); - return(1); - } + if (stumble_on_door_mimic(cc.x, cc.y)) return 1; /* when choosing a direction is impaired, use a turn regardless of whether a door is successfully targetted */ diff --git a/src/trap.c b/src/trap.c index 037c73255..3efae477d 100644 --- a/src/trap.c +++ b/src/trap.c @@ -4108,14 +4108,7 @@ boolean force; return(0); } - if ((mtmp = m_at(x,y)) && - mtmp->m_ap_type == M_AP_FURNITURE && - (mtmp->mappearance == S_hcdoor || - mtmp->mappearance == S_vcdoor) && - !Protection_from_shape_changers) { - stumble_onto_mimic(mtmp); - return(1); - } + if (stumble_on_door_mimic(x,y)) return 1; } /* deal_with_floor_trap */ /* doors can be manipulated even while levitating/unskilled riding */ From 65dcf2e2cc7ae4ac30f2a198151ed70cf07a74c1 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 22 Apr 2015 11:54:27 +0300 Subject: [PATCH 09/10] Fold another instance of "You are rooted" into u_rooted --- src/do.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/do.c b/src/do.c index e3fe47c79..97c11a8ef 100644 --- a/src/do.c +++ b/src/do.c @@ -941,13 +941,7 @@ dodown() int doup() { - if(!youmonst.data->mmove) { - You("are rooted %s.", - Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) ? - "in place" : "to the ground"); - nomul(0); - return 1; - } + if (u_rooted()) return 1; /* "up" to get out of a pit... */ if (u.utrap && u.utraptype == TT_PIT) { From ed164ad324834251660a0218100071ad4c8dd908 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 22 Apr 2015 13:24:51 +0300 Subject: [PATCH 10/10] Fix typo in func decl --- include/extern.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/extern.h b/include/extern.h index 1cb0d673d..491b84367 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1310,7 +1310,7 @@ E boolean FDECL(hideunder, (struct monst*)); E void FDECL(hide_monst, (struct monst *)); E void FDECL(mon_animal_list, (BOOLEAN_P)); E int FDECL(select_newcham_form, (struct monst *)); -E void FDECL(mgender_from_permonts, (struct monst *, struct permonst *)); +E void FDECL(mgender_from_permonst, (struct monst *, struct permonst *)); E int FDECL(newcham, (struct monst *,struct permonst *,BOOLEAN_P,BOOLEAN_P)); E int FDECL(can_be_hatched, (int)); E int FDECL(egg_type_from_parent, (int,BOOLEAN_P));