diff --git a/include/extern.h b/include/extern.h index fe808d110..a3ba6b720 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.5 extern.h $NHDT-Date: 1429675537 2015/04/22 04:05:37 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.471 $ */ +/* 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. */ @@ -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); @@ -606,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)); @@ -752,6 +754,7 @@ E void NDECL(really_close); #endif #ifdef DEBUG E boolean FDECL(debugcore, (const char *, boolean)); +E boolean FDECL(showdebug, (const char *)); #endif E boolean FDECL(read_tribute, (const char *,const char *,int)); @@ -782,6 +785,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); @@ -981,6 +985,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); @@ -1306,6 +1311,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_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)); @@ -1698,6 +1704,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); @@ -1723,6 +1730,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 ### */ @@ -1979,6 +1987,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/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 27255d030..6f909b0f3 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 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -216,7 +216,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); @@ -839,13 +839,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; @@ -946,13 +940,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) { @@ -1230,11 +1218,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."); } @@ -1291,16 +1275,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) diff --git a/src/eat.c b/src/eat.c index 27eb04d72..549765229 100644 --- a/src/eat.c +++ b/src/eat.c @@ -430,6 +430,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) @@ -482,11 +493,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 */ @@ -1269,12 +1276,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/hack.c b/src/hack.c index b943496b0..05f2cced1 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; } 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/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/mon.c b/src/mon.c index 1ecbfd88e..d8e138288 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 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -280,7 +280,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); @@ -2744,6 +2744,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 */ @@ -2783,13 +2797,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/pickup.c b/src/pickup.c index b99df91b3..5e4cf3096 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -2098,6 +2098,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 @@ -2114,13 +2127,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/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*/ diff --git a/src/save.c b/src/save.c index 025c1f0c6..da4e3b09f 100644 --- a/src/save.c +++ b/src/save.c @@ -359,6 +359,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() @@ -386,13 +401,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) { diff --git a/src/sp_lev.c b/src/sp_lev.c index bb3c416f1..fd5ff89d8 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -1498,14 +1498,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, 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)) { diff --git a/src/trap.c b/src/trap.c index aec6256bc..8bad21f84 100644 --- a/src/trap.c +++ b/src/trap.c @@ -4107,14 +4107,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 */ 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];