From a9eb5b2ca8cebc1b7b1c20534e2b1017dbfbaef0 Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 1 Nov 2015 01:17:54 -0800 Subject: [PATCH] yet more formatting Reformat some trailing &&, || operators followed by end-of-line comment, missed by the earlier continuation formating. An #if 0 something { #else something_else { #endif construct in rhack(cmd.c) confused the automated reformatter, resulting in some code from inside a function ending up in column 1. --- src/apply.c | 165 ++++++++++++++++-------------- src/artifact.c | 115 +++++++++++---------- src/bones.c | 45 +++++---- src/cmd.c | 270 ++++++++++++++++++++++++++----------------------- src/detect.c | 253 ++++++++++++++++++++++----------------------- src/dig.c | 58 +++++------ 6 files changed, 470 insertions(+), 436 deletions(-) diff --git a/src/apply.c b/src/apply.c index 2f72a5f00..f1e46b656 100644 --- a/src/apply.c +++ b/src/apply.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 apply.c $NHDT-Date: 1445301113 2015/10/20 00:31:53 $ $NHDT-Branch: master $:$NHDT-Revision: 1.207 $ */ +/* NetHack 3.6 apply.c $NHDT-Date: 1446369459 2015/11/01 09:17:39 $ $NHDT-Branch: master $:$NHDT-Revision: 1.208 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -32,8 +32,8 @@ STATIC_DCL int FDECL(use_pole, (struct obj *)); STATIC_DCL int FDECL(use_cream_pie, (struct obj *)); STATIC_DCL int FDECL(use_grapple, (struct obj *)); STATIC_DCL int FDECL(do_break_wand, (struct obj *)); -STATIC_DCL boolean -FDECL(figurine_location_checks, (struct obj *, coord *, BOOLEAN_P)); +STATIC_DCL boolean FDECL(figurine_location_checks, (struct obj *, + coord *, BOOLEAN_P)); STATIC_DCL void FDECL(add_class, (char *, CHAR_P)); STATIC_DCL void FDECL(setapplyclasses, (char *)); STATIC_DCL boolean FDECL(is_valid_jump_pos, (int, int, int, BOOLEAN_P)); @@ -50,18 +50,18 @@ STATIC_OVL int use_camera(obj) struct obj *obj; { - register struct monst *mtmp; + struct monst *mtmp; if (Underwater) { pline("Using your camera underwater would void the warranty."); - return (0); + return 0; } if (!getdir((char *) 0)) - return (0); + return 0; if (obj->spe <= 0) { pline1(nothing_happens); - return (1); + return 1; } consume_obj_charge(obj, TRUE); @@ -98,6 +98,7 @@ struct obj *obj; return 0; } else if (obj->cursed) { long old; + switch (rn2(3)) { case 2: old = Glib; @@ -492,24 +493,26 @@ struct obj *obj; boolean um_dist(x, y, n) -register xchar x, y, n; +xchar x, y, n; { - return ((boolean)(abs(u.ux - x) > n || abs(u.uy - y) > n)); + return (boolean) (abs(u.ux - x) > n || abs(u.uy - y) > n); } int number_leashed() { - register int i = 0; - register struct obj *obj; + int i = 0; + struct obj *obj; for (obj = invent; obj; obj = obj->nobj) if (obj->otyp == LEASH && obj->leashmon != 0) i++; - return (i); + return i; } -void o_unleash(otmp) /* otmp is about to be destroyed or stolen */ +/* otmp is about to be destroyed or stolen */ +void +o_unleash(otmp) register struct obj *otmp; { register struct monst *mtmp; @@ -520,7 +523,9 @@ register struct obj *otmp; otmp->leashmon = 0; } -void m_unleash(mtmp, feedback) /* mtmp is about to die, or become untame */ +/* mtmp is about to die, or become untame */ +void +m_unleash(mtmp, feedback) register struct monst *mtmp; boolean feedback; { @@ -538,7 +543,9 @@ boolean feedback; mtmp->mleashed = 0; } -void unleash_all() /* player is about to die (for bones) */ +/* player is about to die (for bones) */ +void +unleash_all() { register struct obj *otmp; register struct monst *mtmp; @@ -556,7 +563,7 @@ static boolean leashable(mtmp) struct monst *mtmp; { - return mtmp->mnum != PM_LONG_WORM; + return (boolean) (mtmp->mnum != PM_LONG_WORM); } /* ARGSUSED */ @@ -638,18 +645,20 @@ got_target: return; } -struct obj *get_mleash(mtmp) /* assuming mtmp->mleashed has been checked */ -register struct monst *mtmp; +/* assuming mtmp->mleashed has been checked */ +struct obj * +get_mleash(mtmp) +struct monst *mtmp; { - register struct obj *otmp; + struct obj *otmp; otmp = invent; while (otmp) { if (otmp->otyp == LEASH && otmp->leashmon == (int) mtmp->m_id) - return (otmp); + return otmp; otmp = otmp->nobj; } - return ((struct obj *) 0); + return (struct obj *) 0; } boolean @@ -669,7 +678,7 @@ next_to_u() if (otmp->otyp == LEASH && otmp->leashmon == (int) mtmp->m_id) { if (otmp->cursed) - return (FALSE); + return FALSE; You_feel("%s leash go slack.", (number_leashed() > 1) ? "a" : "the"); mtmp->mleashed = 0; @@ -681,7 +690,7 @@ next_to_u() /* no pack mules for the Amulet */ if (u.usteed && mon_has_amulet(u.usteed)) return FALSE; - return (TRUE); + return TRUE; } void @@ -756,9 +765,11 @@ register xchar x, y; const char * beautiful() { - return (ACURR(A_CHA) > 14) - ? (poly_gender() == 1 ? "beautiful" : "handsome") - : "ugly"; + return ((ACURR(A_CHA) > 14) + ? ((poly_gender() == 1) + ? "beautiful" + : "handsome") + : "ugly"); } #define WEAK 3 /* from eat.c */ @@ -1180,16 +1191,18 @@ struct obj **optr; } } -boolean snuff_candle(otmp) /* call in drop, throw, and put in box, etc. */ -register struct obj *otmp; +/* call in drop, throw, and put in box, etc. */ +boolean +snuff_candle(otmp) +struct obj *otmp; { - register boolean candle = Is_candle(otmp); + boolean candle = Is_candle(otmp); if ((candle || otmp->otyp == CANDELABRUM_OF_INVOCATION) && otmp->lamplit) { char buf[BUFSZ]; xchar x, y; - register boolean many = candle ? otmp->quan > 1L : otmp->spe > 1; + boolean many = candle ? (otmp->quan > 1L) : (otmp->spe > 1); (void) get_obj_location(otmp, &x, &y, 0); if (otmp->where == OBJ_MINVENT ? cansee(x, y) : !Blind) @@ -1197,9 +1210,9 @@ register struct obj *otmp; (candle ? "" : "candelabrum's "), (many ? "s'" : "'s"), (many ? "s are" : " is")); end_burn(otmp, TRUE); - return (TRUE); + return TRUE; } - return (FALSE); + return FALSE; } /* called when lit lamp is hit by water or put into a container or @@ -1555,7 +1568,7 @@ int magic; /* 0=Physical, otherwise skill level */ return 0; } else if (u.usteed && u.utrap) { pline("%s is stuck in a trap.", Monnam(u.usteed)); - return (0); + return 0; } pline("Where do you want to jump?"); @@ -1644,9 +1657,9 @@ struct obj *corpse; STATIC_OVL void use_tinning_kit(obj) -register struct obj *obj; +struct obj *obj; { - register struct obj *corpse, *can; + struct obj *corpse, *can; /* This takes only 1 move. If this is to be changed to take many * moves, we've got to deal with decaying corpses... @@ -2692,12 +2705,11 @@ struct obj *obj; return 1; } -static const char not_enough_room[] = - "There's not enough room here to use that.", - where_to_hit[] = "Where do you want to hit?", - cant_see_spot[] = - "won't hit anything if you can't see that spot.", - cant_reach[] = "can't reach that spot from here."; +static const char + not_enough_room[] = "There's not enough room here to use that.", + where_to_hit[] = "Where do you want to hit?", + cant_see_spot[] = "won't hit anything if you can't see that spot.", + cant_reach[] = "can't reach that spot from here."; /* find pos of monster in range, if only one monster */ boolean @@ -2707,6 +2719,7 @@ int min_range, max_range; { struct monst *mtmp; struct monst *selmon = NULL; + for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) if (mtmp && !DEADMONSTER(mtmp) && !mtmp->mtame && cansee(mtmp->mx, mtmp->my) @@ -2734,6 +2747,7 @@ int state; tmp_at(DISP_BEAM, cmap_to_glyph(S_goodpos)); } 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; @@ -2762,11 +2776,11 @@ struct obj *obj; /* Are you allowed to use the pole? */ if (u.uswallow) { pline(not_enough_room); - return (0); + return 0; } if (obj != uwep) { if (!wield_tool(obj, "swing")) - return (0); + return 0; else res = 1; } @@ -2817,14 +2831,14 @@ struct obj *obj; glyph = glyph_at(cc.x, cc.y); if (distu(cc.x, cc.y) > max_range) { pline("Too far!"); - return (res); + return res; } else if (distu(cc.x, cc.y) < min_range) { pline("Too close!"); - return (res); + return res; } else if (!cansee(cc.x, cc.y) && !glyph_is_monster(glyph) && !glyph_is_invisible(glyph) && !glyph_is_statue(glyph)) { You(cant_see_spot); - return (res); + return res; } else if (!couldsee(cc.x, cc.y)) { /* Eyes of the Overworld */ You(cant_reach); return res; @@ -2842,8 +2856,8 @@ struct obj *obj; check_caitiff(mtmp); notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my); (void) thitmonst(mtmp, uwep); - } else if (glyph_is_statue(glyph) && /* might be hallucinatory */ - sobj_at(STATUE, bhitpos.x, bhitpos.y)) { + } else if (glyph_is_statue(glyph) /* might be hallucinatory */ + && sobj_at(STATUE, bhitpos.x, bhitpos.y)) { struct trap *t = t_at(bhitpos.x, bhitpos.y); if (t && t->ttyp == STATUE_TRAP @@ -2868,7 +2882,7 @@ struct obj *obj; You("miss; there is no one there to hit."); } u_wipe_engr(2); /* same as for melee or throwing */ - return (1); + return 1; } STATIC_OVL int @@ -2906,7 +2920,7 @@ struct obj *obj; costly_alteration(obj, COST_SPLAT); obj_extract_self(obj); delobj(obj); - return (0); + return 0; } STATIC_OVL int @@ -2922,11 +2936,11 @@ struct obj *obj; /* Are you allowed to use the hook? */ if (u.uswallow) { pline(not_enough_room); - return (0); + return 0; } if (obj != uwep) { if (!wield_tool(obj, "cast")) - return (0); + return 0; else res = 1; } @@ -2949,10 +2963,10 @@ struct obj *obj; max_range = 8; if (distu(cc.x, cc.y) > max_range) { pline("Too far!"); - return (res); + return res; } else if (!cansee(cc.x, cc.y)) { You(cant_see_spot); - return (res); + return res; } else if (!couldsee(cc.x, cc.y)) { /* Eyes of the Overworld */ You(cant_reach); return res; @@ -3005,7 +3019,7 @@ struct obj *obj; (void) pickup_object(otmp, 1L, FALSE); /* If pickup fails, leave it alone */ newsym(cc.x, cc.y); - return (1); + return 1; } break; case 2: /* Monster */ @@ -3023,7 +3037,7 @@ struct obj *obj; You("pull in %s!", mon_nam(mtmp)); mtmp->mundetected = 0; rloc_to(mtmp, cc.x, cc.y); - return (1); + return 1; } else if ((!bigmonst(mtmp->data) && !strongmonst(mtmp->data)) || rn2(4)) { flags.confirm = FALSE; @@ -3031,7 +3045,7 @@ struct obj *obj; flags.confirm = save_confirm; check_caitiff(mtmp); (void) thitmonst(mtmp, uwep); - return (1); + return 1; } /* FALL THROUGH */ case 3: /* Surface */ @@ -3042,18 +3056,18 @@ struct obj *obj; hurtle(sgn(cc.x - u.ux), sgn(cc.y - u.uy), 1, FALSE); spoteffects(TRUE); } - return (1); + return 1; default: /* Yourself (oops!) */ if (P_SKILL(typ) <= P_BASIC) { You("hook yourself!"); losehp(Maybe_Half_Phys(rn1(10, 10)), "a grappling hook", KILLED_BY); - return (1); + return 1; } break; } pline1(nothing_happens); - return (1); + return 1; } #define BY_OBJECT ((struct monst *) 0) @@ -3075,7 +3089,8 @@ struct obj *obj; boolean is_fragile = (!strcmp(OBJ_DESCR(objects[obj->otyp]), "balsa")); if (!paranoid_query(ParanoidBreakwand, - safe_qbuf(confirm, "Are you really sure you want to break ", + safe_qbuf(confirm, + "Are you really sure you want to break ", "?", obj, yname, ysimple_name, "the wand"))) return 0; @@ -3180,6 +3195,7 @@ struct obj *obj; if (obj->otyp == WAN_DIGGING) { schar typ; + if (dig_check(BY_OBJECT, FALSE, x, y)) { if (IS_WALL(levl[x][y].typ) || IS_DOOR(levl[x][y].typ)) { /* normally, pits and holes don't anger guards, but they @@ -3196,18 +3212,17 @@ struct obj *obj; typ = fillholetyp(x, y, FALSE); if (typ != ROOM) { levl[x][y].typ = typ; - liquid_flow( - x, y, typ, t_at(x, y), - fillmsg ? (char *) 0 - : "Some holes are quickly filled with %s!"); + liquid_flow(x, y, typ, t_at(x, y), + fillmsg + ? (char *) 0 + : "Some holes are quickly filled with %s!"); fillmsg = TRUE; } else - digactualhole( - x, y, BY_OBJECT, - (rn2(obj->spe) < 3 - || (!Can_dig_down(&u.uz) && !levl[x][y].candig)) - ? PIT - : HOLE); + digactualhole(x, y, BY_OBJECT, (rn2(obj->spe) < 3 + || (!Can_dig_down(&u.uz) + && !levl[x][y].candig)) + ? PIT + : HOLE); } continue; } else if (obj->otyp == WAN_CREATE_MONSTER) { @@ -3335,6 +3350,7 @@ char class_list[]; add_class(class_list, FOOD_CLASS); } +/* the 'a' command */ int doapply() { @@ -3343,7 +3359,7 @@ doapply() char class_list[MAXOCLASSES + 2]; if (check_capacity((char *) 0)) - return (0); + return 0; setapplyclasses(class_list); /* tools[] */ obj = getobj(class_list, "use or apply"); @@ -3363,14 +3379,15 @@ doapply() if (obj == ublindf) { if (!cursed(obj)) Blindf_off(obj); - } else if (!ublindf) + } else if (!ublindf) { Blindf_on(obj); - else + } else { You("are already %s.", ublindf->otyp == TOWEL ? "covered by a towel" : ublindf->otyp == BLINDFOLD ? "wearing a blindfold" : "wearing lenses"); + } break; case CREAM_PIE: res = use_cream_pie(obj); diff --git a/src/artifact.c b/src/artifact.c index 43a4d5658..4e6c22015 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 artifact.c $NHDT-Date: 1445301116 2015/10/20 00:31:56 $ $NHDT-Branch: master $:$NHDT-Revision: 1.95 $ */ +/* NetHack 3.6 artifact.c $NHDT-Date: 1446369462 2015/11/01 09:17:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.96 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -8,9 +8,9 @@ /* * Note: both artilist[] and artiexist[] have a dummy element #0, - * so loops over them should normally start at #1. The primary - * exception is the save & restore code, which doesn't care about - * the contents, just the total size. + * so loops over them should normally start at #1. The primary + * exception is the save & restore code, which doesn't care about + * the contents, just the total size. */ extern boolean notonhead; /* for long worms */ @@ -105,8 +105,8 @@ artiname(artinum) int artinum; { if (artinum <= 0 || artinum > NROFARTIFACTS) - return (""); - return (artilist[artinum].name); + return ""; + return artilist[artinum].name; } /* @@ -239,11 +239,11 @@ short *otyp; boolean exist_artifact(otyp, name) -register int otyp; -register const char *name; +int otyp; +const char *name; { register const struct artifact *a; - register boolean *arex; + boolean *arex; if (otyp && *name) for (a = artilist + 1, arex = artiexist + 1; a->otyp; a++, arex++) @@ -254,9 +254,9 @@ register const char *name; void artifact_exists(otmp, name, mod) -register struct obj *otmp; -register const char *name; -register boolean mod; +struct obj *otmp; +const char *name; +boolean mod; { register const struct artifact *a; @@ -294,7 +294,7 @@ unsigned long abil; { const struct artifact *arti = get_artifact(otmp); - return ((boolean)(arti && (arti->spfx & abil))); + return (boolean) (arti && (arti->spfx & abil) != 0L); } /* used so that callers don't need to known about SPFX_ codes */ @@ -306,7 +306,7 @@ struct obj *obj; if (obj->otyp == LUCKSTONE) return TRUE; - return (obj->oartifact && spec_ability(obj, SPFX_LUCK)); + return (boolean) (obj->oartifact && spec_ability(obj, SPFX_LUCK)); } /* used to check whether a monster is getting reflection from an artifact */ @@ -348,10 +348,11 @@ struct obj *obj; return FALSE; } +/* returns 1 if name is restricted for otmp->otyp */ boolean -restrict_name(otmp, name) /* returns 1 if name is restricted for otmp->otyp */ -register struct obj *otmp; -register const char *name; +restrict_name(otmp, name) +struct obj *otmp; +const char *name; { register const struct artifact *a; const char *aname, *odesc, *other; @@ -394,8 +395,8 @@ register const char *name; if (!strncmpi(aname, "the ", 4)) aname += 4; if (!strcmp(aname, name)) - return ((boolean)((a->spfx & (SPFX_NOGEN | SPFX_RESTR)) != 0 - || otmp->quan > 1L)); + return (boolean) ((a->spfx & (SPFX_NOGEN | SPFX_RESTR)) != 0 + || otmp->quan > 1L); } return FALSE; @@ -403,25 +404,25 @@ register const char *name; STATIC_OVL boolean attacks(adtyp, otmp) -register int adtyp; -register struct obj *otmp; +int adtyp; +struct obj *otmp; { register const struct artifact *weap; if ((weap = get_artifact(otmp)) != 0) - return ((boolean)(weap->attk.adtyp == adtyp)); + return (boolean) (weap->attk.adtyp == adtyp); return FALSE; } boolean defends(adtyp, otmp) -register int adtyp; -register struct obj *otmp; +int adtyp; +struct obj *otmp; { register const struct artifact *weap; if ((weap = get_artifact(otmp)) != 0) - return ((boolean)(weap->defn.adtyp == adtyp)); + return (boolean) (weap->defn.adtyp == adtyp); return FALSE; } @@ -434,7 +435,7 @@ struct obj *otmp; register const struct artifact *weap; if ((weap = get_artifact(otmp)) != 0) - return (boolean)(weap->cary.adtyp == adtyp); + return (boolean) (weap->cary.adtyp == adtyp); return FALSE; } @@ -451,8 +452,8 @@ boolean being_worn; arti = get_artifact(otmp); if (!arti) return FALSE; - return (arti->cspfx & SPFX_PROTECT) != 0 - || (being_worn && (arti->spfx & SPFX_PROTECT) != 0); + return (boolean) ((arti->cspfx & SPFX_PROTECT) != 0 + || (being_worn && (arti->spfx & SPFX_PROTECT) != 0)); } /* @@ -467,8 +468,8 @@ long wp_mask; { long *mask = 0; register const struct artifact *oart = get_artifact(otmp); - uchar dtyp; - long spfx; + register uchar dtyp; + register long spfx; if (!oart) return; @@ -632,8 +633,7 @@ long wp_mask; STATIC_VAR boolean touch_blasted; /* for retouch_object() */ /* - * creature (usually player) tries to touch (pick up or wield) an artifact - * obj. + * creature (usually hero) tries to touch (pick up or wield) an artifact obj. * Returns 0 if the object refuses to be touched. * This routine does not change any object chains. * Ignores such things as gauntlets, assuming the artifact is not @@ -669,8 +669,7 @@ struct monst *mon; && (oart->alignment != mon_aligntyp(mon)); } else { /* an M3_WANTSxxx monster or a fake player */ /* special monsters trying to take the Amulet, invocation tools or - quest item can touch anything except for `spec_applies' artifacts - */ + quest item can touch anything except `spec_applies' artifacts */ badclass = badalign = FALSE; } /* weapons which attack specific categories of monsters are @@ -723,8 +722,9 @@ int dtyp; return FALSE; if (dtyp == AD_PHYS) return FALSE; /* nothing is immune to phys dmg */ - return (weap->attk.adtyp == dtyp || weap->defn.adtyp == dtyp - || weap->cary.adtyp == dtyp); + return (boolean) (weap->attk.adtyp == dtyp + || weap->defn.adtyp == dtyp + || weap->cary.adtyp == dtyp); } STATIC_OVL boolean @@ -799,7 +799,7 @@ struct monst *mtmp; impossible("Weird weapon special attack."); } } - return (0); + return 0; } /* return the M2 flags of monster that an artifact's special attacks apply @@ -808,7 +808,8 @@ long spec_m2(otmp) struct obj *otmp; { - register const struct artifact *artifact = get_artifact(otmp); + const struct artifact *artifact = get_artifact(otmp); + if (artifact) return artifact->mtype; return 0L; @@ -820,7 +821,7 @@ spec_abon(otmp, mon) struct obj *otmp; struct monst *mon; { - register const struct artifact *weap = get_artifact(otmp); + const struct artifact *weap = get_artifact(otmp); /* no need for an extra check for `NO_ATTK' because this will always return 0 for any artifact which has that attribute */ @@ -839,8 +840,8 @@ int tmp; { register const struct artifact *weap = get_artifact(otmp); - if (!weap || (weap->attk.adtyp == AD_PHYS && /* check for `NO_ATTK' */ - weap->attk.damn == 0 && weap->attk.damd == 0)) + if (!weap || (weap->attk.adtyp == AD_PHYS /* check for `NO_ATTK' */ + && weap->attk.damn == 0 && weap->attk.damd == 0)) spec_dbon_applies = FALSE; else if (otmp->oartifact == ART_GRIMTOOTH) /* Grimtooth has SPFX settings to warn against elves but we want its @@ -1292,7 +1293,7 @@ int dieroll; /* needed for Magicbane and vorpal blades */ else if (vis) pline("Somehow, %s misses wildly.", mon_nam(magr)); *dmgptr = 0; - return ((boolean)(youattack || vis)); + return (boolean) (youattack || vis); } if (noncorporeal(mdef->data) || amorphous(mdef->data)) { pline("%s slices through %s %s.", wepdesc, @@ -1345,6 +1346,7 @@ int dieroll; /* needed for Magicbane and vorpal blades */ *dmgptr = 2 * mdef->mhp + FATAL_DAMAGE_MODIFIER; } else { int drain = monhp_per_lvl(mdef); + *dmgptr += drain; mdef->mhpmax -= drain; mdef->m_lev--; @@ -1358,8 +1360,9 @@ int dieroll; /* needed for Magicbane and vorpal blades */ if (Blind) You_feel("an %s drain your %s!", - otmp->oartifact == ART_STORMBRINGER ? "unholy blade" - : "object", + (otmp->oartifact == ART_STORMBRINGER) + ? "unholy blade" + : "object", life); else if (otmp->oartifact == ART_STORMBRINGER) pline_The("%s blade drains your %s!", hcolor(NH_BLACK), life); @@ -1382,6 +1385,7 @@ static NEARDATA const char recharge_type[] = { ALLOW_COUNT, ALL_CLASSES, 0 }; static NEARDATA const char invoke_types[] = { ALL_CLASSES, 0 }; /* #invoke: an "ugly check" filters out most objects */ +/* the #invoke command */ int doinvoke() { @@ -1584,8 +1588,7 @@ register struct obj *obj; } else { long eprop = (u.uprops[oart->inv_prop].extrinsic ^= W_ARTI), iprop = u.uprops[oart->inv_prop].intrinsic; - boolean on = - (eprop & W_ARTI) != 0; /* true if invoked prop just set */ + boolean on = (eprop & W_ARTI) != 0; /* true if prop just set */ if (on && obj->age > monstermoves) { /* the artifact is tired :-) */ @@ -1671,7 +1674,7 @@ boolean artifact_light(obj) struct obj *obj; { - return (get_artifact(obj) && obj->oartifact == ART_SUNSWORD); + return (boolean) (get_artifact(obj) && obj->oartifact == ART_SUNSWORD); } /* KMH -- Talking artifacts are finally implemented */ @@ -1702,7 +1705,7 @@ uchar inv_prop; { const struct artifact *arti = get_artifact(otmp); - return ((boolean)(arti && (arti->inv_prop == inv_prop))); + return (boolean) (arti && (arti->inv_prop == inv_prop)); } /* Return the price sold to the hero of a given artifact or unique item */ @@ -1711,9 +1714,9 @@ arti_cost(otmp) struct obj *otmp; { if (!otmp->oartifact) - return ((long) objects[otmp->otyp].oc_cost); + return (long) objects[otmp->otyp].oc_cost; else if (artilist[(int) otmp->oartifact].cost) - return (artilist[(int) otmp->oartifact].cost); + return artilist[(int) otmp->oartifact].cost; else return (100L * (long) objects[otmp->otyp].oc_cost); } @@ -1775,7 +1778,6 @@ long *abil; /* * Return the first item that is conveying a particular intrinsic. */ - struct obj * what_gives(abil) long *abil; @@ -1784,10 +1786,11 @@ long *abil; uchar dtyp; unsigned long spfx; long wornbits; - long wornmask = - (W_ARM | W_ARMC | W_ARMH | W_ARMS | W_ARMG | W_ARMF | W_ARMU - | W_AMUL | W_RINGL | W_RINGR | W_TOOL | W_ART | W_ARTI); - /* [do W_ART and W_ARTI actually belong here?] */ + long wornmask = (W_ARM | W_ARMC | W_ARMH | W_ARMS + | W_ARMG | W_ARMF | W_ARMU + | W_AMUL | W_RINGL | W_RINGR | W_TOOL + /* [do W_ART and W_ARTI actually belong here?] */ + | W_ART | W_ARTI); if (u.twoweap) wornmask |= W_SWAPWEP; @@ -1797,7 +1800,7 @@ long *abil; for (obj = invent; obj; obj = obj->nobj) { if (obj->oartifact - && ((abil != &EWarn_of_mon) || context.warntype.obj)) { + && (abil != &EWarn_of_mon || context.warntype.obj)) { const struct artifact *art = get_artifact(obj); if (art) { diff --git a/src/bones.c b/src/bones.c index 8312ee04a..b068e751a 100644 --- a/src/bones.c +++ b/src/bones.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 bones.c $NHDT-Date: 1432512767 2015/05/25 00:12:47 $ $NHDT-Branch: master $:$NHDT-Revision: 1.60 $ */ +/* NetHack 3.6 bones.c $NHDT-Date: 1446369463 2015/11/01 09:17:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.65 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985,1993. */ /* NetHack may be freely redistributed. See license for details. */ @@ -25,14 +25,15 @@ d_level *lev; if (ledger_no(&save_dlevel)) assign_level(lev, &save_dlevel); - return (boolean)( - ((sptr = Is_special(lev)) != 0 && !sptr->boneid) - || !dungeons[lev->dnum].boneid - /* no bones on the last or multiway branch levels */ - /* in any dungeon (level 1 isn't multiway). */ - || Is_botlevel(lev) || (Is_branchlev(lev) && lev->dlevel > 1) - /* no bones in the invocation level */ - || (In_hell(lev) && lev->dlevel == dunlevs_in_dungeon(lev) - 1)); + return (boolean) (((sptr = Is_special(lev)) != 0 && !sptr->boneid) + || !dungeons[lev->dnum].boneid + /* no bones on the last or multiway branch levels + in any dungeon (level 1 isn't multiway) */ + || Is_botlevel(lev) + || (Is_branchlev(lev) && lev->dlevel > 1) + /* no bones in the invocation level */ + || (In_hell(lev) + && lev->dlevel == dunlevs_in_dungeon(lev) - 1)); } /* Call this function for each fruit object saved in the bones level: it marks @@ -311,12 +312,12 @@ can_make_bones() return FALSE; } - if (depth(&u.uz) <= 0 || /* bulletproofing for endgame */ - (!rn2(1 + (depth(&u.uz) >> 2)) /* fewer ghosts on low levels */ - && !wizard)) + if (depth(&u.uz) <= 0 /* bulletproofing for endgame */ + || (!rn2(1 + (depth(&u.uz) >> 2)) /* fewer ghosts on low levels */ + && !wizard)) return FALSE; /* don't let multiple restarts generate multiple copies of objects - * in bones files */ + in bones files */ if (discover) return FALSE; return TRUE; @@ -552,19 +553,19 @@ getbones() char c, *bonesid, oldbonesid[10]; if (discover) /* save bones files for real games */ - return (0); + return 0; if (!flags.bones) - return (0); + return 0; /* wizard check added by GAN 02/05/87 */ if (rn2(3) /* only once in three times do we find bones */ && !wizard) - return (0); + return 0; if (no_bones_level(&u.uz)) - return (0); + return 0; fd = open_bonesfile(&u.uz, &bonesid); if (fd < 0) - return (0); + return 0; if (validate(fd, bones) != 0) { if (!wizard) @@ -576,7 +577,7 @@ getbones() if (yn("Get bones?") == 'n') { (void) nhclose(fd); compress_bonesfile(); - return (0); + return 0; } } mread(fd, (genericptr_t) &c, sizeof c); /* length incl. '\0' */ @@ -626,7 +627,7 @@ getbones() if (wizard) { if (yn("Unlink bones?") == 'n') { compress_bonesfile(); - return (ok); + return ok; } } if (!delete_bonesfile(&u.uz)) { @@ -637,9 +638,9 @@ getbones() * -- just generate a new level for those N-1 games. */ /* pline("Cannot unlink bones."); */ - return (0); + return 0; } - return (ok); + return ok; } /*bones.c*/ diff --git a/src/cmd.c b/src/cmd.c index 5bcd57fa5..75c23da02 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 cmd.c $NHDT-Date: 1445301117 2015/10/20 00:31:57 $ $NHDT-Branch: master $:$NHDT-Revision: 1.202 $ */ +/* NetHack 3.6 cmd.c $NHDT-Date: 1446369464 2015/11/01 09:17:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.205 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -209,9 +209,9 @@ timed_occupation(VOID_ARGS) * The exception to this is taking off items, since they can be taken * off in a number of ways in the intervening time, screwing up ordering. * - * Currently: Take off all armor. - * Picking Locks / Forcing Chests. - * Setting traps. + * Currently: Take off all armor. + * Picking Locks / Forcing Chests. + * Setting traps. */ void reset_occupations() @@ -290,7 +290,7 @@ char ch; return; } -/* A ch == 0 resets the saveq. Only save keystrokes when not +/* A ch == 0 resets the saveq. Only save keystrokes when not * replaying a previous command. */ void @@ -329,7 +329,9 @@ doextcmd(VOID_ARGS) /* here after # - now read a full-word command */ return retval; } -int doextlist(VOID_ARGS) /* here after #? - now list all full-word commands */ +/* here after #? - now list all full-word commands */ +int +doextlist(VOID_ARGS) { register const struct ext_func_tab *efp; char buf[BUFSZ]; @@ -353,12 +355,13 @@ int doextlist(VOID_ARGS) /* here after #? - now list all full-word commands */ #ifdef TTY_GRAPHICS #define MAX_EXT_CMD 50 /* Change if we ever have > 50 ext cmds */ - /* - * This is currently used only by the tty port and is - * controlled via runtime option 'extmenu'. - * ``# ?'' is counted towards the limit of the number of commands, - * so we actually support MAX_EXT_CMD-1 "real" extended commands. - */ + +/* + * This is currently used only by the tty port and is + * controlled via runtime option 'extmenu'. + * ``# ?'' is counted towards the limit of the number of commands, + * so we actually support MAX_EXT_CMD-1 "real" extended commands. + */ int extcmd_via_menu() /* here after # - now show pick-list of possible commands */ { @@ -666,8 +669,7 @@ wiz_level_tele(VOID_ARGS) return 0; } -/* #monpolycontrol command - choose new form for shapechangers, polymorphees - */ +/* #monpolycontrol command - choose new form for shapechangers, polymorphees */ STATIC_PTR int wiz_mon_polycontrol(VOID_ARGS) { @@ -875,13 +877,13 @@ wiz_map_levltyp(VOID_ARGS) for (x = 1; x < COLNO; x++) { terrain = levl[x][y].typ; /* assumes there aren't more than 10+26+26 terrain types */ - row[x - 1] = - (char) ((terrain == 0 && !may_dig(x, y)) - ? '*' - : (terrain < 10) - ? '0' + terrain - : (terrain < 36) ? 'a' + terrain - 10 - : 'A' + terrain - 36); + row[x - 1] = (char) ((terrain == 0 && !may_dig(x, y)) + ? '*' + : (terrain < 10) + ? '0' + terrain + : (terrain < 36) + ? 'a' + terrain - 10 + : 'A' + terrain - 36); } if (levl[0][y].typ != 0 || may_dig(0, y)) row[x++] = '!'; @@ -1282,7 +1284,8 @@ walking_on_water() { if (u.uinwater || Levitation || Flying) return FALSE; - return (Wwalking && (is_pool(u.ux, u.uy) || is_lava(u.ux, u.uy))); + return (boolean) (Wwalking + && (is_pool(u.ux, u.uy) || is_lava(u.ux, u.uy))); } /* check whether hero is wearing something that player definitely knows @@ -1377,8 +1380,7 @@ int final; char buf[BUFSZ], tmpbuf[BUFSZ]; /* note that if poly'd, we need to use u.mfemale instead of flags.female - to access hero's saved gender-as-human/elf/&c rather than current one - */ + to access hero's saved gender-as-human/elf/&c rather than current one */ innategend = (Upolyd ? u.mfemale : flags.female) ? 1 : 0; role_titl = (innategend && urole.name.f) ? urole.name.f : urole.name.m; rank_titl = rank_of(u.ulevel, Role_switch, innategend); @@ -1459,9 +1461,9 @@ int final; for tricky phrasing otherwise necessitated by possibility of having helm of opposite alignment mask a permanent alignment conversion */ difgend = (innategend != flags.initgend); - difalgn = - ((u.ualign.type != u.ualignbase[A_CURRENT]) ? 1 : 0) - + ((u.ualignbase[A_CURRENT] != u.ualignbase[A_ORIGINAL]) ? 2 : 0); + difalgn = (((u.ualign.type != u.ualignbase[A_CURRENT]) ? 1 : 0) + + ((u.ualignbase[A_CURRENT] != u.ualignbase[A_ORIGINAL]) + ? 2 : 0)); if (difalgn & 1) { /* have temporary alignment so report permanent one */ Sprintf(buf, "actually %s", align_str(u.ualignbase[A_CURRENT])); you_are(buf, ""); @@ -1607,16 +1609,16 @@ int final; be set; we want to ignore steed in that situation */ && !(final == ENL_GAMEOVERDEAD && !strcmp(killer.name, "riding accident"))); - const char *steedname = - !Riding - ? (char *) 0 - : x_monnam(u.usteed, u.usteed->mtame ? ARTICLE_YOUR : ARTICLE_THE, - (char *) 0, (SUPPRESS_SADDLE | SUPPRESS_HALLUCINATION), - FALSE); + const char *steedname = (!Riding ? (char *) 0 + : x_monnam(u.usteed, + u.usteed->mtame ? ARTICLE_YOUR : ARTICLE_THE, + (char *) 0, + (SUPPRESS_SADDLE | SUPPRESS_HALLUCINATION), + FALSE)); /*\ * Status (many are abbreviated on bottom line; others are or - * should be discernible to the hero hence to the player) + * should be discernible to the hero hence to the player) \*/ putstr(en_win, 0, ""); /* separator after title or characteristics */ putstr(en_win, 0, final ? "Final Status:" : "Current Status:"); @@ -1839,11 +1841,11 @@ int final; /* report being weaponless; distinguish whether gloves are worn */ if (!uwep) { you_are(uarmg ? "empty handed" /* gloves imply hands */ - /* no weapon and no gloves */ - : humanoid(youmonst.data) - ? "bare handed" - /* alternate phrasing for paws or lack of hands */ - : "not wielding anything", + : humanoid(youmonst.data) + /* hands but no weapon and no gloves */ + ? "bare handed" + /* alternate phrasing for paws or lack of hands */ + : "not wielding anything", ""); /* two-weaponing implies a weapon (not other odd stuff) in each hand */ } else if (u.twoweap) { @@ -1883,7 +1885,7 @@ int final; char buf[BUFSZ]; /*\ - * Attributes + * Attributes \*/ putstr(en_win, 0, ""); putstr(en_win, 0, final ? "Final Attributes:" : "Current Attributes:"); @@ -2219,7 +2221,7 @@ int final; if (wizard) Sprintf(eos(buf), " (%d)", u.ugangr); enl_msg(u_gname(), " is", " was", buf, ""); - } else + } else { /* * We need to suppress this when the game is over, because death * can change the value calculated by can_pray(), potentially @@ -2227,20 +2229,24 @@ int final; */ if (!final) { #if 0 - /* "can [not] safely pray" vs "could [not] have safely prayed" */ - Sprintf(buf, "%s%ssafely pray%s", can_pray(FALSE) ? "" : "not ", - final ? "have " : "", final ? "ed" : ""); + /* "can [not] safely pray" vs "could [not] have safely prayed" */ + Sprintf(buf, "%s%ssafely pray%s", can_pray(FALSE) ? "" : "not ", + final ? "have " : "", final ? "ed" : ""); #else - Sprintf(buf, "%ssafely pray", can_pray(FALSE) ? "" : "not "); + Sprintf(buf, "%ssafely pray", can_pray(FALSE) ? "" : "not "); #endif - if (wizard) - Sprintf(eos(buf), " (%d)", u.ublesscnt); - you_can(buf, ""); + if (wizard) + Sprintf(eos(buf), " (%d)", u.ublesscnt); + you_can(buf, ""); + } } + + /* named fruit debugging (doesn't really belong here...) */ if (wizard) { int fcount = 0; struct fruit *f; char buf2[BUFSZ]; + for (f = ffruit; f; f = f->nextf) { Sprintf(buf, "Fruit %d ", ++fcount); Sprintf(buf2, "%s (id %d)", f->fname, f->fid); @@ -2515,9 +2521,9 @@ int final; if (!u.uconduct.gnostic) you_have_been("an atheist"); - if (!u.uconduct.weaphit) + if (!u.uconduct.weaphit) { you_have_never("hit with a wielded weapon"); - else if (wizard) { + } else if (wizard) { Sprintf(buf, "used a wielded weapon %ld time%s", u.uconduct.weaphit, plur(u.uconduct.weaphit)); you_have_X(buf); @@ -2525,9 +2531,9 @@ int final; if (!u.uconduct.killer) you_have_been("a pacifist"); - if (!u.uconduct.literate) + if (!u.uconduct.literate) { you_have_been("illiterate"); - else if (wizard) { + } else if (wizard) { Sprintf(buf, "read items or engraved %ld time%s", u.uconduct.literate, plur(u.uconduct.literate)); you_have_X(buf); @@ -2542,25 +2548,25 @@ int final; you_have_X(buf); } - if (!u.uconduct.polypiles) + if (!u.uconduct.polypiles) { you_have_never("polymorphed an object"); - else if (wizard) { + } else if (wizard) { Sprintf(buf, "polymorphed %ld item%s", u.uconduct.polypiles, plur(u.uconduct.polypiles)); you_have_X(buf); } - if (!u.uconduct.polyselfs) + if (!u.uconduct.polyselfs) { you_have_never("changed form"); - else if (wizard) { + } else if (wizard) { Sprintf(buf, "changed form %ld time%s", u.uconduct.polyselfs, plur(u.uconduct.polyselfs)); you_have_X(buf); } - if (!u.uconduct.wishes) + if (!u.uconduct.wishes) { you_have_X("used no wishes"); - else { + } else { Sprintf(buf, "used %ld wish%s", u.uconduct.wishes, (u.uconduct.wishes > 1L) ? "es" : ""); you_have_X(buf); @@ -2595,8 +2601,7 @@ static const struct func_tab cmdlist[] = { { C('i'), TRUE, wiz_identify }, { C('l'), TRUE, doredraw }, /* if number_pad is set */ { C('n'), TRUE, donamelevel }, /* if number_pad is set */ - { C('o'), TRUE, - dooverview_or_wiz_where }, /* depending on wizard status */ + { C('o'), TRUE, dooverview_or_wiz_where }, /* depends on wizard status */ { C('p'), TRUE, doprev_message }, { C('r'), TRUE, doredraw }, { C('t'), TRUE, dotele }, @@ -2608,7 +2613,7 @@ static const struct func_tab cmdlist[] = { { 'A', FALSE, doddoremarm }, { M('a'), TRUE, doorganize }, { M('A'), TRUE, donamelevel }, /* #annotate */ - /* 'b', 'B' : go sw */ + /* 'b', 'B' : go sw */ { 'c', FALSE, doclose }, { 'C', TRUE, docallcmd }, { M('c'), TRUE, dotalk }, @@ -2620,21 +2625,21 @@ static const struct func_tab cmdlist[] = { { 'E', FALSE, doengrave }, { M('e'), TRUE, enhance_weapon_skill }, { 'f', FALSE, dofire }, - /* 'F' : fight (one time) */ + /* 'F' : fight (one time) */ { M('f'), FALSE, doforce }, - /* 'g', 'G' : multiple go */ - /* 'h', 'H' : go west */ + /* 'g', 'G' : multiple go */ + /* 'h', 'H' : go west */ { 'h', TRUE, dohelp }, /* if number_pad is set */ { 'i', TRUE, ddoinv }, { 'I', TRUE, dotypeinv }, /* Robert Viduya */ { M('i'), TRUE, doinvoke }, - /* 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N' : move commands */ + /* 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N' : move commands */ { 'j', FALSE, dojump }, /* if number_pad is on */ { M('j'), FALSE, dojump }, { 'k', FALSE, dokick }, /* if number_pad is on */ { 'l', FALSE, doloot }, /* if number_pad is on */ { M('l'), FALSE, doloot }, - /* 'n' prefixes a count if number_pad is on */ + /* 'n' prefixes a count if number_pad is on */ { M('m'), TRUE, domonability }, { 'N', TRUE, docallcmd }, /* if number_pad is on */ { M('n'), TRUE, docallcmd }, @@ -2660,7 +2665,7 @@ static const struct func_tab cmdlist[] = { { 'T', FALSE, dotakeoff }, { M('t'), TRUE, doturn }, { M('T'), FALSE, dotip }, /* #tip */ - /* 'u', 'U' : go ne */ + /* 'u', 'U' : go ne */ { 'u', FALSE, dountrap }, /* if number_pad is on */ { M('u'), FALSE, dountrap }, { 'v', TRUE, doversion }, @@ -2671,7 +2676,7 @@ static const struct func_tab cmdlist[] = { { M('w'), FALSE, dowipe }, { 'x', FALSE, doswapweapon }, { 'X', FALSE, dotwoweapon }, - /* 'y', 'Y' : go nw */ + /* 'y', 'Y' : go nw */ { 'z', FALSE, dozap }, { 'Z', TRUE, docast }, { '<', FALSE, doup }, @@ -3112,7 +3117,8 @@ void reset_commands(initial) boolean initial; { - static const char sdir[] = "hykulnjb><", sdir_swap_yz[] = "hzkulnjb><", + static const char sdir[] = "hykulnjb><", + sdir_swap_yz[] = "hzkulnjb><", ndir[] = "47896321><", ndir_phone_layout[] = "41236987><"; static const int ylist[] = { @@ -3390,62 +3396,66 @@ register char *cmd; int res, NDECL((*func)); #if 0 - for (tlist = cmdlist; tlist->f_char; tlist++) { - if ((*cmd & 0xff) != (tlist->f_char & 0xff)) continue; + /* obsolete - scan through the cmdlist array looking for *cmd */ + for (tlist = cmdlist; tlist->f_char; tlist++) { + if ((*cmd & 0xff) != (tlist->f_char & 0xff)) + continue; #else + /* current - use *cmd to directly index cmdlist array */ if ((tlist = Cmd.commands[*cmd & 0xff]) != 0) { #endif - - if (u.uburied && !tlist->can_if_buried) { - You_cant("do that while you are buried!"); - res = 0; - } else { - /* we discard 'const' because some compilers seem to have - trouble with the pointer passed to set_occupation() */ - func = ((struct func_tab *) tlist)->f_funct; - if (tlist->f_text && !occupation && multi) - set_occupation(func, tlist->f_text, multi); - res = (*func)(); /* perform the command */ + if (u.uburied && !tlist->can_if_buried) { + You_cant("do that while you are buried!"); + res = 0; + } else { + /* we discard 'const' because some compilers seem to have + trouble with the pointer passed to set_occupation() */ + func = ((struct func_tab *) tlist)->f_funct; + if (tlist->f_text && !occupation && multi) + set_occupation(func, tlist->f_text, multi); + res = (*func)(); /* perform the command */ + } + if (!res) { + context.move = FALSE; + multi = 0; + } + return; } - if (!res) { - context.move = FALSE; - multi = 0; - } - return; + /* if we reach here, cmd wasn't found in cmdlist[] */ + bad_command = TRUE; } - /* if we reach here, cmd wasn't found in cmdlist[] */ - bad_command = TRUE; -} -if (bad_command) { - char expcmd[10]; - register char c, *cp = expcmd; + if (bad_command) { + char expcmd[10]; + register char c, *cp = expcmd; - while ((c = *cmd++) != '\0' - && (int) (cp - expcmd) < (int) (sizeof expcmd - 3)) { - if (c >= 040 && c < 0177) { - *cp++ = c; - } else if (c & 0200) { - *cp++ = 'M'; - *cp++ = '-'; - *cp++ = c & ~0200; - } else { - *cp++ = '^'; - *cp++ = c ^ 0100; + while ((c = *cmd++) != '\0' + && (int) (cp - expcmd) < (int) (sizeof expcmd - 3)) { + if (c >= 040 && c < 0177) { + *cp++ = c; + } else if (c & 0200) { + *cp++ = 'M'; + *cp++ = '-'; + *cp++ = c & ~0200; + } else { + *cp++ = '^'; + *cp++ = c ^ 0100; + } } + *cp = '\0'; + if (!prefix_seen || !iflags.cmdassist + || !help_dir(0, "Invalid direction key!")) + Norep("Unknown command '%s'.", expcmd); } - *cp = '\0'; - if (!prefix_seen || !iflags.cmdassist - || !help_dir(0, "Invalid direction key!")) - Norep("Unknown command '%s'.", expcmd); -} -/* didn't move */ -context.move = FALSE; -multi = 0; -return; + /* didn't move */ + context.move = FALSE; + multi = 0; + return; } -int xytod(x, y) /* convert an x,y pair into a direction code */ +/* convert an x,y pair into a direction code */ +int +xytod(x, y) schar x, y; { register int dd; @@ -3453,11 +3463,12 @@ schar x, y; for (dd = 0; dd < 8; dd++) if (x == xdir[dd] && y == ydir[dd]) return dd; - return -1; } -void dtoxy(cc, dd) /* convert a direction code into an x,y pair */ +/* convert a direction code into an x,y pair */ +void +dtoxy(cc, dd) coord *cc; register int dd; { @@ -3466,7 +3477,9 @@ register int dd; return; } -int movecmd(sym) /* also sets u.dz, but returns false for <> */ +/* also sets u.dz, but returns false for <> */ +int +movecmd(sym) char sym; { register const char *dp = index(Cmd.dirchars, sym); @@ -3478,10 +3491,10 @@ char sym; u.dy = ydir[dp - Cmd.dirchars]; u.dz = zdir[dp - Cmd.dirchars]; #if 0 /* now handled elsewhere */ - if (u.dx && u.dy && NODIAG(u.umonnum)) { - u.dx = u.dy = 0; - return 0; - } + if (u.dx && u.dy && NODIAG(u.umonnum)) { + u.dx = u.dy = 0; + return 0; + } #endif return !u.dz; } @@ -3495,13 +3508,12 @@ dxdy_moveok() return u.dx || u.dy; } -/* decide whether a character (user input keystroke) requests screen repaint - */ +/* decide whether a character (user input keystroke) requests screen repaint */ boolean redraw_cmd(c) char c; { - return (c == C('r') || (Cmd.num_pad && c == C('l'))); + return (boolean) (c == C('r') || (Cmd.num_pad && c == C('l'))); } /* @@ -3807,9 +3819,9 @@ int x, y, mod; if (mod == CLICK_1) { cmd[0] = Cmd.dirchars[dir]; } else { - cmd[0] = - (Cmd.num_pad ? M(Cmd.dirchars[dir]) - : (Cmd.dirchars[dir] - 'a' + 'A')); /* run command */ + cmd[0] = (Cmd.num_pad + ? M(Cmd.dirchars[dir]) + : (Cmd.dirchars[dir] - 'a' + 'A')); /* run command */ } return cmd; @@ -3906,7 +3918,7 @@ parse() clear_nhwindow(WIN_MESSAGE); if (prezero) in_line[0] = '\033'; - return (in_line); + return in_line; } #ifdef HANGUPHANDLING @@ -4006,7 +4018,7 @@ readchar() readchar_queue = click_to_cmd(x, y, mod); sym = *readchar_queue++; } - return ((char) sym); + return (char) sym; } STATIC_PTR int diff --git a/src/detect.c b/src/detect.c index b1d730cab..41ee1f4d3 100644 --- a/src/detect.c +++ b/src/detect.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 detect.c $NHDT-Date: 1436753510 2015/07/13 02:11:50 $ $NHDT-Branch: master $:$NHDT-Revision: 1.60 $ */ +/* NetHack 3.6 detect.c $NHDT-Date: 1446369464 2015/11/01 09:17:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.61 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -44,8 +44,9 @@ char oclass; return (struct obj *) 0; } -/* Recursively search obj for an object made of specified material and return - * 1st found */ +/* Recursively search obj for an object made of specified material. + * Return first found. + */ struct obj * o_material(obj, material) struct obj *obj; @@ -85,10 +86,10 @@ struct obj *obj; STATIC_OVL boolean check_map_spot(x, y, oclass, material) int x, y; -register char oclass; +char oclass; unsigned material; { - register int glyph; + int glyph; register struct obj *otmp; register struct monst *mtmp; @@ -96,14 +97,12 @@ unsigned material; if (glyph_is_object(glyph)) { /* there's some object shown here */ if (oclass == ALL_CLASSES) { - return ( - (boolean)(!(level.objects[x][y] || /* stale if nothing here */ - ((mtmp = m_at(x, y)) != 0 && (mtmp->minvent))))); + return (boolean) !(level.objects[x][y] /* stale if nothing here */ + || ((mtmp = m_at(x, y)) != 0 && mtmp->minvent)); } else { if (material && objects[glyph_to_obj(glyph)].oc_material == material) { - /* the object shown here is of interest because material - * matches */ + /* object shown here is of interest because material matches */ for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) if (o_material(otmp, GOLD)) return FALSE; @@ -117,8 +116,7 @@ unsigned material; return TRUE; } if (oclass && objects[glyph_to_obj(glyph)].oc_class == oclass) { - /* the object shown here is of interest because its class - * matches */ + /* obj shown here is of interest because its class matches */ for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) if (o_in(otmp, oclass)) return FALSE; @@ -137,18 +135,18 @@ unsigned material; } /* - When doing detection, remove stale data from the map display (corpses - rotted away, objects carried away by monsters, etc) so that it won't - reappear after the detection has completed. Return true if noticeable - change occurs. + * When doing detection, remove stale data from the map display (corpses + * rotted away, objects carried away by monsters, etc) so that it won't + * reappear after the detection has completed. Return true if noticeable + * change occurs. */ STATIC_OVL boolean clear_stale_map(oclass, material) -register char oclass; +char oclass; unsigned material; { register int zx, zy; - register boolean change_made = FALSE; + boolean change_made = FALSE; for (zx = 1; zx < COLNO; zx++) for (zy = 0; zy < ROWNO; zy++) @@ -218,13 +216,13 @@ register struct obj *sobj; Strcpy(buf, "You feel materially poor."); strange_feeling(sobj, buf); } - return (1); + return 1; } /* only under me - no separate display required */ if (stale) docrt(); You("notice some gold between your %s.", makeplural(body_part(FOOT))); - return (0); + return 0; outgoldmap: cls(); @@ -281,11 +279,11 @@ outgoldmap: under_water(2); if (u.uburied) under_ground(2); - return (0); + return 0; } -/* returns 1 if nothing was detected */ -/* returns 0 if something was detected */ +/* returns 1 if nothing was detected */ +/* returns 0 if something was detected */ int food_detect(sobj) register struct obj *sobj; @@ -333,9 +331,9 @@ register struct obj *sobj; ? " then starts to tingle" : ""); if (sobj->blessed && !u.uedibility) { - boolean savebeginner = - flags.beginner; /* prevent non-delivery of */ - flags.beginner = FALSE; /* message */ + boolean savebeginner = flags.beginner; + + flags.beginner = FALSE; /* prevent non-delivery of message */ strange_feeling(sobj, buf); flags.beginner = savebeginner; u.uedibility = 1; @@ -394,14 +392,14 @@ register struct obj *sobj; if (u.uburied) under_ground(2); } - return (0); + return 0; } /* * Used for scrolls, potions, spells, and crystal balls. Returns: * - * 1 - nothing was detected - * 0 - something was detected + * 1 - nothing was detected + * 0 - something was detected */ int object_detect(detector, class) @@ -501,7 +499,7 @@ int class; /* an object class, 0 for all */ iflags.save_uinwater = u.uinwater, iflags.save_uburied = u.uburied; u.uinwater = u.uburied = 0; /* - * Map all buried objects first. + * Map all buried objects first. */ for (obj = level.buriedobjlist; obj; obj = obj->nobj) if (!class || (otmp = o_in(obj, class))) { @@ -726,10 +724,11 @@ int how; /* 1 for misleading map feedback */ return result; } -/* the detections are pulled out so they can */ -/* also be used in the crystal ball routine */ -/* returns 1 if nothing was detected */ -/* returns 0 if something was detected */ +/* the detections are pulled out so they can + * also be used in the crystal ball routine + * returns 1 if nothing was detected + * returns 0 if something was detected + */ int trap_detect(sobj) register struct obj *sobj; @@ -790,11 +789,11 @@ register struct obj *sobj; Sprintf(buf, "Your %s stop itching.", makeplural(body_part(TOE))); strange_feeling(sobj, buf); - return (1); + return 1; } /* traps exist, but only under me - no separate display required */ Your("%s itch.", makeplural(body_part(TOE))); - return (0); + return 0; outtrapmap: cls(); @@ -835,7 +834,7 @@ outtrapmap: under_water(2); if (u.uburied) under_ground(2); - return (0); + return 0; } const char * @@ -1248,12 +1247,14 @@ int findit() /* returns number of things found */ int num = 0; if (u.uswallow) - return (0); + return 0; do_clear_area(u.ux, u.uy, BOLT_LIM, findone, (genericptr_t) &num); - return (num); + return num; } -int openit() /* returns number of things found and opened */ +/* returns number of things found and opened */ +int +openit() { int num = 0; @@ -1265,11 +1266,11 @@ int openit() /* returns number of things found and opened */ pline("%s opens its mouth!", Monnam(u.ustuck)); } expels(u.ustuck, u.ustuck->data, TRUE); - return (-1); + return -1; } do_clear_area(u.ux, u.uy, BOLT_LIM, openone, (genericptr_t) &num); - return (num); + return num; } /* callback hack for overriding vision in do_clear_area() */ @@ -1331,10 +1332,9 @@ register int aflag; /* intrinsic autosearch vs explicit searching */ if (!aflag) pline("What are you looking for? The exit?"); } else { - int fund = - (uwep && uwep->oartifact && spec_ability(uwep, SPFX_SEARCH)) - ? uwep->spe - : 0; + int fund = (uwep && uwep->oartifact + && spec_ability(uwep, SPFX_SEARCH)) ? uwep->spe : 0; + if (ublindf && ublindf->otyp == LENSES && !Blind) fund += 2; /* JDS: lenses help searching */ if (fund > 5) @@ -1343,99 +1343,95 @@ register int aflag; /* intrinsic autosearch vs explicit searching */ for (y = u.uy - 1; y < u.uy + 2; y++) { if (!isok(x, y)) continue; - if (x != u.ux || y != u.uy) { - if (Blind && !aflag) - feel_location(x, y); - if (levl[x][y].typ == SDOOR) { - if (rnl(7 - fund)) - continue; - cvt_sdoor_to_door(&levl[x][y]); /* .typ = DOOR */ - exercise(A_WIS, TRUE); - nomul(0); - feel_location(x, y); /* make sure it shows up */ - You("find a hidden door."); - } else if (levl[x][y].typ == SCORR) { - if (rnl(7 - fund)) - continue; - levl[x][y].typ = CORR; - unblock_point(x, y); /* vision */ - exercise(A_WIS, TRUE); - nomul(0); - feel_location(x, y); /* make sure it shows up */ - You("find a hidden passage."); - } else { - /* Be careful not to find anything in an SCORR or - * SDOOR */ - if ((mtmp = m_at(x, y)) && !aflag) { - if (mtmp->m_ap_type) { - seemimic(mtmp); - find: - exercise(A_WIS, TRUE); - if (!canspotmon(mtmp)) { - if (glyph_is_invisible( - levl[x][y].glyph)) { - /* found invisible monster in a square - * which already has an 'I' in it. - * Logically, this should still take - * time and lead to a return(1), but - * if - * we did that the player would keep - * finding the same monster every - * turn. - */ - continue; - } else { - You_feel("an unseen monster!"); - map_invisible(x, y); - } - } else if (!sensemon(mtmp)) - You("find %s.", mtmp->mtame - ? y_monnam(mtmp) - : a_monnam(mtmp)); - return (1); - } + if (x == u.ux && y == u.uy) + continue; + + if (Blind && !aflag) + feel_location(x, y); + if (levl[x][y].typ == SDOOR) { + if (rnl(7 - fund)) + continue; + cvt_sdoor_to_door(&levl[x][y]); /* .typ = DOOR */ + exercise(A_WIS, TRUE); + nomul(0); + feel_location(x, y); /* make sure it shows up */ + You("find a hidden door."); + } else if (levl[x][y].typ == SCORR) { + if (rnl(7 - fund)) + continue; + levl[x][y].typ = CORR; + unblock_point(x, y); /* vision */ + exercise(A_WIS, TRUE); + nomul(0); + feel_location(x, y); /* make sure it shows up */ + You("find a hidden passage."); + } else { + /* Be careful not to find anything in an SCORR or SDOOR */ + if ((mtmp = m_at(x, y)) != 0 && !aflag) { + if (mtmp->m_ap_type) { + seemimic(mtmp); + find: + exercise(A_WIS, TRUE); if (!canspotmon(mtmp)) { - if (mtmp->mundetected - && (is_hider(mtmp->data) - || mtmp->data->mlet == S_EEL)) - mtmp->mundetected = 0; - newsym(x, y); - goto find; - } + if (glyph_is_invisible(levl[x][y].glyph)) { + /* found invisible monster in a square + * which already has an 'I' in it. + * Logically, this should still take + * time and lead to a return(1), but + * if we did that the player would keep + * finding the same monster every turn. + */ + continue; + } else { + You_feel("an unseen monster!"); + map_invisible(x, y); + } + } else if (!sensemon(mtmp)) + You("find %s.", mtmp->mtame + ? y_monnam(mtmp) + : a_monnam(mtmp)); + return 1; } - - /* see if an invisible monster has moved--if Blind, - * feel_location() already did it - */ - if (!aflag && !mtmp && !Blind - && glyph_is_invisible(levl[x][y].glyph)) { - unmap_object(x, y); + if (!canspotmon(mtmp)) { + if (mtmp->mundetected + && (is_hider(mtmp->data) + || mtmp->data->mlet == S_EEL)) + mtmp->mundetected = 0; newsym(x, y); + goto find; } + } - if ((trap = t_at(x, y)) && !trap->tseen && !rnl(8)) { - nomul(0); + /* see if an invisible monster has moved--if Blind, + * feel_location() already did it + */ + if (!aflag && !mtmp && !Blind + && glyph_is_invisible(levl[x][y].glyph)) { + unmap_object(x, y); + newsym(x, y); + } - if (trap->ttyp == STATUE_TRAP) { - if (activate_statue_trap(trap, x, y, FALSE)) - exercise(A_WIS, TRUE); - return (1); - } else { - find_trap(trap); - } + if ((trap = t_at(x, y)) && !trap->tseen && !rnl(8)) { + nomul(0); + if (trap->ttyp == STATUE_TRAP) { + if (activate_statue_trap(trap, x, y, FALSE)) + exercise(A_WIS, TRUE); + return 1; + } else { + find_trap(trap); } } } } } - return (1); + return 1; } /* the 's' command -- explicit searching */ int dosearch() { - return (dosearch0(0)); + return dosearch0(0); } /* Pre-map the sokoban levels */ @@ -1497,14 +1493,17 @@ int which_subset; /* when not full, whether to suppress objs and/or traps */ for (x = 1; x < COLNO; x++) for (y = 0; y < ROWNO; y++) { seenv = (full || level.flags.hero_memory) - ? levl[x][y].seenv : cansee(x, y) ? SVALL : 0; + ? levl[x][y].seenv : cansee(x, y) ? SVALL : 0; if (full) { levl[x][y].seenv = SVALL; glyph = back_to_glyph(x, y); levl[x][y].seenv = seenv; } else { - levl_glyph = level.flags.hero_memory ? levl[x][y].glyph - : seenv ? back_to_glyph(x, y) : default_glyph; + levl_glyph = level.flags.hero_memory + ? levl[x][y].glyph + : seenv + ? back_to_glyph(x, y) + : default_glyph; /* glyph_at() returns the displayed glyph, which might be a monster. levl[][].glyph contains the remembered glyph, which will never be a monster (unless it is @@ -1556,9 +1555,11 @@ int which_subset; /* when not full, whether to suppress objs and/or traps */ } show_glyph(x, y, glyph); } + /* [TODO: highlight hero's location somehow] */ u.uinwater = iflags.save_uinwater, u.uburied = iflags.save_uburied; - if (save_swallowed) u.uswallow = 1; + if (save_swallowed) + u.uswallow = 1; flush_screen(1); if (full) { Strcpy(buf, "underlying terrain"); diff --git a/src/dig.c b/src/dig.c index e432a4b27..ec102af40 100644 --- a/src/dig.c +++ b/src/dig.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 dig.c $NHDT-Date: 1446191874 2015/10/30 07:57:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.98 $ */ +/* NetHack 3.6 dig.c $NHDT-Date: 1446369465 2015/11/01 09:17:45 $ $NHDT-Branch: master $:$NHDT-Revision: 1.99 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -152,19 +152,19 @@ xchar x, y; if (!ispick && !is_axe(otmp)) return DIGTYP_UNDIGGABLE; - return (ispick && sobj_at(STATUE, x, y) - ? DIGTYP_STATUE - : ispick && sobj_at(BOULDER, x, y) - ? DIGTYP_BOULDER - : closed_door(x, y) - ? DIGTYP_DOOR - : IS_TREE(levl[x][y].typ) - ? (ispick ? DIGTYP_UNDIGGABLE : DIGTYP_TREE) - : ispick && IS_ROCK(levl[x][y].typ) - && (!level.flags.arboreal - || IS_WALL(levl[x][y].typ)) - ? DIGTYP_ROCK - : DIGTYP_UNDIGGABLE); + return ((ispick && sobj_at(STATUE, x, y)) + ? DIGTYP_STATUE + : (ispick && sobj_at(BOULDER, x, y)) + ? DIGTYP_BOULDER + : closed_door(x, y) + ? DIGTYP_DOOR + : IS_TREE(levl[x][y].typ) + ? (ispick ? DIGTYP_UNDIGGABLE : DIGTYP_TREE) + : (ispick && IS_ROCK(levl[x][y].typ) + && (!level.flags.arboreal + || IS_WALL(levl[x][y].typ))) + ? DIGTYP_ROCK + : DIGTYP_UNDIGGABLE); } boolean @@ -1013,7 +1013,6 @@ struct obj *obj; /* MRKR: use_pick_axe() is split in two to allow autodig to bypass */ /* the "In what direction do you want to dig?" query. */ /* use_pick_axe2() uses the existing u.dx, u.dy and u.dz */ - int use_pick_axe2(obj) struct obj *obj; @@ -1596,8 +1595,7 @@ char *msg; return FALSE; if (!isok(cc->x, cc->y)) return FALSE; - if (msg) - *msg = '\0'; + *msg = '\0'; room = &levl[cc->x][cc->y]; ltyp = room->typ; @@ -1626,21 +1624,21 @@ char *msg; /* "set of iron bars" */ Strcpy(msg, "The bars go much deeper than your pit."); #if 0 - } else if (is_lava(cc->x,cc->y)) { - } else if (is_ice(cc->x,cc->y)) { - } else if (is_pool(cc->x,cc->y)) { + } else if (is_lava(cc->x, cc->y)) { + } else if (is_ice(cc->x, cc->y)) { + } else if (is_pool(cc->x, cc->y)) { } else if (IS_GRAVE(ltyp)) { #endif } else if (IS_SINK(ltyp)) { Strcpy(msg, "A tangled mass of plumbing remains below the sink."); return FALSE; - } else if ((cc->x == xupladder && cc->y == yupladder) || /* "ladder up" */ - (cc->x == xdnladder - && cc->y == ydnladder)) { /* "ladder down" */ + } else if ((cc->x == xupladder && cc->y == yupladder) /* ladder up */ + || (cc->x == xdnladder && cc->y == ydnladder)) { /* " down */ Strcpy(msg, "The ladder is unaffected."); return FALSE; } else { const char *supporting = (const char *) 0; + if (IS_FOUNTAIN(ltyp)) supporting = "fountain"; else if (IS_THRONE(ltyp)) @@ -1657,9 +1655,10 @@ char *msg; && !sstairs.up)) /* "staircase down" */ supporting = "stairs"; - else if ((ltyp == DRAWBRIDGE_DOWN) || /* "lowered drawbridge" */ - (ltyp == DBWALL)) /* "raised drawbridge" */ + else if (ltyp == DRAWBRIDGE_DOWN /* "lowered drawbridge" */ + || ltyp == DBWALL) /* "raised drawbridge" */ supporting = "drawbridge"; + if (supporting) { Sprintf(msg, "The %s%ssupporting structures remain intact.", supporting ? s_suffix(supporting) : "", @@ -1717,6 +1716,7 @@ coord *cc; { xchar check_x, check_y; struct obj *otmp, *otmp2; + if (u.utraptype == TT_BURIEDBALL) for (otmp = level.buriedobjlist; otmp; otmp = otmp2) { otmp2 = otmp->nobj; @@ -1793,8 +1793,8 @@ buried_ball_to_freedom() } } -/* move objects from fobj/nexthere lists to buriedobjlist, keeping position */ -/* information */ +/* move objects from fobj/nexthere lists to buriedobjlist, keeping position + information */ struct obj * bury_an_obj(otmp, dealloced) struct obj *otmp; @@ -1895,9 +1895,9 @@ int x, y; for (otmp = level.buriedobjlist; otmp; otmp = otmp2) { otmp2 = otmp->nobj; if (otmp->ox == x && otmp->oy == y) { - if (bball && otmp == bball && u.utraptype == TT_BURIEDBALL) + if (bball && otmp == bball && u.utraptype == TT_BURIEDBALL) { buried_ball_to_punishment(); - else { + } else { obj_extract_self(otmp); if (otmp->timed) (void) stop_timer(ROT_ORGANIC, obj_to_any(otmp));