From: PatR Date: Thu, 22 Oct 2015 23:35:01 +0000 (-0700) Subject: formatting: src/m*.c - p*.c continuation lines X-Git-Tag: NetHack-3.6.0_RC01~136 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ea8a1beb0a90976bb7017ac8dce60430042ac533;p=nethack formatting: src/m*.c - p*.c continuation lines Somewhere along the line I started removing redundant parentheses from return statements, but only in files that needed continuation fixups so it's not comprehensive. --- diff --git a/src/makemon.c b/src/makemon.c index 65e799d6c..8ef9f788a 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 makemon.c $NHDT-Date: 1433457069 2015/06/04 22:31:09 $ $NHDT-Branch: master $:$NHDT-Revision: 1.92 $ */ +/* NetHack 3.6 makemon.c $NHDT-Date: 1445556868 2015/10/22 23:34:28 $ $NHDT-Branch: master $:$NHDT-Revision: 1.99 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1084,11 +1084,11 @@ register int mmflags; return ((struct monst *) 0); /* no more monsters! */ } fakemon.data = ptr; /* set up for goodpos */ - } while (++tryct <= 50 && + } while (++tryct <= 50 /* in Sokoban, don't accept a giant on first try; after that, boulder carriers are fair game */ - ((tryct == 1 && throws_rocks(ptr) && In_sokoban(&u.uz)) - || !goodpos(x, y, &fakemon, gpflags))); + && ((tryct == 1 && throws_rocks(ptr) && In_sokoban(&u.uz)) + || !goodpos(x, y, &fakemon, gpflags))); mndx = monsndx(ptr); } (void) propagate(mndx, countbirth, FALSE); diff --git a/src/mhitm.c b/src/mhitm.c index 129f58f41..ace40adc4 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mhitm.c $NHDT-Date: 1432512766 2015/05/25 00:12:46 $ $NHDT-Branch: master $:$NHDT-Revision: 1.78 $ */ +/* NetHack 3.6 mhitm.c $NHDT-Date: 1445556871 2015/10/22 23:34:31 $ $NHDT-Branch: master $:$NHDT-Revision: 1.81 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -610,9 +610,9 @@ struct monst *magr, *mdef; if (mdef == &youmonst) dx = u.ux, dy = u.uy; lev = &levl[dx][dy]; - if (IS_ROCK(lev->typ) || closed_door(dx, dy) || IS_TREE(lev->typ) || + if (IS_ROCK(lev->typ) || closed_door(dx, dy) || IS_TREE(lev->typ) /* not passes_bars(); engulfer isn't squeezing through */ - (lev->typ == IRONBARS && !is_whirly(magr->data))) + || (lev->typ == IRONBARS && !is_whirly(magr->data))) return FALSE; return TRUE; diff --git a/src/mhitu.c b/src/mhitu.c index b7b4a44ee..4ace9b0d7 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mhitu.c $NHDT-Date: 1437877180 2015/07/26 02:19:40 $ $NHDT-Branch: master $:$NHDT-Revision: 1.128 $ */ +/* NetHack 3.6 mhitu.c $NHDT-Date: 1445556872 2015/10/22 23:34:32 $ $NHDT-Branch: master $:$NHDT-Revision: 1.129 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -70,26 +70,28 @@ register struct attack *mattk; } } -STATIC_OVL void missmu(mtmp, nearmiss, mattk) /* monster missed you */ -register struct monst *mtmp; -register boolean nearmiss; -register struct attack *mattk; +/* monster missed you */ +STATIC_OVL void +missmu(mtmp, nearmiss, mattk) +struct monst *mtmp; +boolean nearmiss; +struct attack *mattk; { if (!canspotmon(mtmp)) map_invisible(mtmp->mx, mtmp->my); if (could_seduce(mtmp, &youmonst, mattk) && !mtmp->mcan) pline("%s pretends to be friendly.", Monnam(mtmp)); - else { - if (!flags.verbose || !nearmiss) - pline("%s misses.", Monnam(mtmp)); - else - pline("%s just misses!", Monnam(mtmp)); - } + else + pline("%s %smisses!", Monnam(mtmp), + (nearmiss && flags.verbose) ? "just " : ""); + stop_occupation(); } -STATIC_OVL void mswings(mtmp, otemp) /* monster swings obj */ +/* monster swings obj */ +STATIC_OVL void +mswings(mtmp, otemp) struct monst *mtmp; struct obj *otemp; { @@ -132,8 +134,9 @@ u_slow_down() exercise(A_DEX, FALSE); } -STATIC_OVL void wildmiss(mtmp, - mattk) /* monster attacked your displaced image */ +/* monster attacked your displaced image */ +STATIC_OVL void +wildmiss(mtmp, mattk) register struct monst *mtmp; register struct attack *mattk; { @@ -147,8 +150,8 @@ register struct attack *mattk; return; /* maybe it's attacking an image around the corner? */ - compat = (mattk->adtyp == AD_SEDU || mattk->adtyp == AD_SSEX) - && could_seduce(mtmp, &youmonst, (struct attack *) 0); + compat = ((mattk->adtyp == AD_SEDU || mattk->adtyp == AD_SSEX) + && could_seduce(mtmp, &youmonst, (struct attack *) 0)); if (!mtmp->mcansee || (Invis && !perceives(mtmp->data))) { const char *swings = @@ -211,9 +214,8 @@ register struct attack *mattk; void expels(mtmp, mdat, message) -register struct monst *mtmp; -register struct permonst - *mdat; /* if mtmp is polymorphed, mdat != mtmp->data */ +struct monst *mtmp; +struct permonst *mdat; /* if mtmp is polymorphed, mdat != mtmp->data */ boolean message; { if (message) { @@ -309,37 +311,37 @@ register struct monst *mtmp; if (!ranged) nomul(0); if (mtmp->mhp <= 0 || (Underwater && !is_swimmer(mtmp->data))) - return (0); + return 0; /* If swallowed, can only be affected by u.ustuck */ if (u.uswallow) { if (mtmp != u.ustuck) - return (0); + return 0; u.ustuck->mux = u.ux; u.ustuck->muy = u.uy; range2 = 0; foundyou = 1; if (u.uinvulnerable) - return (0); /* stomachs can't hurt you! */ + return 0; /* stomachs can't hurt you! */ } else if (u.usteed) { if (mtmp == u.usteed) /* Your steed won't attack you */ - return (0); + return 0; /* Orcs like to steal and eat horses and the like */ if (!rn2(is_orc(mtmp->data) ? 2 : 4) && distu(mtmp->mx, mtmp->my) <= 2) { /* Attack your steed instead */ i = mattackm(mtmp, u.usteed); if ((i & MM_AGR_DIED)) - return (1); + return 1; /* make sure steed is still alive and within range */ if ((i & MM_DEF_DIED) || !u.usteed || distu(mtmp->mx, mtmp->my) > 2) - return (0); + return 0; /* Let your steed retaliate */ - return (!!(mattackm(u.usteed, mtmp) & MM_DEF_DIED)); + return !!(mattackm(u.usteed, mtmp) & MM_DEF_DIED); } } @@ -357,11 +359,12 @@ register struct monst *mtmp; is eligible for placing hero; we assume that a removed monster remembers its old spot */ remove_monster(mtmp->mx, mtmp->my); - if (!enexto(&cc, u.ux, u.uy, youmonst.data) || + if (!enexto(&cc, u.ux, u.uy, youmonst.data) /* a fish won't voluntarily swap positions when it's in water and hero is over land */ - (mtmp->data->mlet == S_EEL && is_pool(mtmp->mx, mtmp->my) - && !is_pool(u.ux, u.uy))) { + || (mtmp->data->mlet == S_EEL + && is_pool(mtmp->mx, mtmp->my) + && !is_pool(u.ux, u.uy))) { /* couldn't find any spot for hero; this used to kill off attacker, but now we just give a "miss" message and keep both mtmp and hero at their @@ -388,7 +391,7 @@ register struct monst *mtmp; newsym(u.ux, u.uy); if (youmonst.data->mlet != S_PIERCER) - return (0); /* lurkers don't attack */ + return 0; /* lurkers don't attack */ obj = which_armor(mtmp, WORN_HELMET); if (obj && is_metallic(obj)) { @@ -444,7 +447,7 @@ register struct monst *mtmp; } newsym(u.ux, u.uy); } - return (0); + return 0; } /* hero might be a mimic, concealed via #monster */ @@ -464,7 +467,7 @@ register struct monst *mtmp; youmonst.m_ap_type = M_AP_NOTHING; youmonst.mappearance = 0; newsym(u.ux, u.uy); - return (0); + return 0; } /* non-mimic hero might be mimicking an object after eating m corpse */ @@ -573,7 +576,7 @@ register struct monst *mtmp; else You_feel("%s move nearby.", something); } - return (0); + return 0; } /* Unlike defensive stuff, don't let them use item _and_ attack. */ @@ -624,9 +627,8 @@ register struct monst *mtmp; break; case AT_GAZE: /* can affect you either ranged or not */ - /* Medusa gaze already operated through m_respond in - * dochug(); don't gaze more than once per round. - */ + /* Medusa gaze already operated through m_respond in + dochug(); don't gaze more than once per round. */ if (mdat != &mons[PM_MEDUSA]) sum[i] = gazemu(mtmp, mattk); break; @@ -654,9 +656,9 @@ register struct monst *mtmp; if (youseeit) pline("%s lunges forward and recoils!", Monnam(mtmp)); else - You_hear("a %s nearby.", is_whirly(mtmp->data) - ? "rushing noise" - : "splat"); + You_hear("a %s nearby.", + is_whirly(mtmp->data) ? "rushing noise" + : "splat"); } } break; @@ -683,8 +685,7 @@ register struct monst *mtmp; */ if (mtmp->weapon_check == NEED_WEAPON || !MON_WEP(mtmp)) { mtmp->weapon_check = NEED_HTH_WEAPON; - /* mon_wield_item resets weapon_check as - * appropriate */ + /* mon_wield_item resets weapon_check as appropriate */ if (mon_wield_item(mtmp) != 0) break; } @@ -734,7 +735,7 @@ register struct monst *mtmp; break; /* attacker teleported, no more attacks */ /* sum[i] == 0: unsuccessful attack */ } - return (0); + return 0; } STATIC_OVL boolean @@ -797,9 +798,9 @@ struct monst *mon; long wearmask; int armpro, mc = 0; boolean is_you = (mon == &youmonst), - gotprot = is_you ? (EProtection != 0L) : + gotprot = is_you ? (EProtection != 0L) /* high priests have innate protection */ - (mon->data == &mons[PM_HIGH_PRIEST]); + : (mon->data == &mons[PM_HIGH_PRIEST]); for (o = is_you ? invent : mon->minvent; o; o = o->nobj) { /* a_can field is only applicable for armor (which must be worn) */ @@ -1178,7 +1179,7 @@ register struct attack *mattk; kformat = KILLED_BY; } make_stoned(5L, (char *) 0, kformat, kname); - return (1); + return 1; /* done_in_by(mtmp, STONING); */ } } @@ -1632,8 +1633,9 @@ gulp_blnd_check() return FALSE; } +/* monster swallows you, or damage if u.uswallow */ STATIC_OVL int -gulpmu(mtmp, mattk) /* monster swallows you, or damage if u.uswallow */ +gulpmu(mtmp, mattk) register struct monst *mtmp; register struct attack *mattk; { @@ -1651,7 +1653,7 @@ register struct attack *mattk; return 0; if ((t && ((t->ttyp == PIT) || (t->ttyp == SPIKED_PIT))) && sobj_at(BOULDER, u.ux, u.uy)) - return (0); + return 0; if (Punished) unplacebc(); /* ball&chain go away */ @@ -1730,7 +1732,7 @@ register struct attack *mattk; } if (mtmp != u.ustuck) - return (0); + return 0; if (u.uswldtim > 0) u.uswldtim -= 1; @@ -1870,10 +1872,12 @@ register struct attack *mattk; pline("Obviously %s doesn't like your taste.", mon_nam(mtmp)); expels(mtmp, mtmp->data, FALSE); } - return (1); + return 1; } -STATIC_OVL int explmu(mtmp, mattk, ufound) /* monster explodes in your face */ +/* monster explodes in your face */ +STATIC_OVL int +explmu(mtmp, mattk, ufound) register struct monst *mtmp; register struct attack *mattk; boolean ufound; @@ -1881,7 +1885,7 @@ boolean ufound; boolean physical_damage = TRUE, kill_agr = TRUE; if (mtmp->mcan) - return (0); + return 0; if (!ufound) pline("%s explodes at a spot in %s!", @@ -1969,7 +1973,9 @@ boolean ufound; return (mtmp->mhp > 0) ? 0 : 2; } -int gazemu(mtmp, mattk) /* monster gazes at you */ +/* monster gazes at you */ +int +gazemu(mtmp, mattk) register struct monst *mtmp; register struct attack *mattk; { @@ -2175,10 +2181,12 @@ register struct attack *mattk; : (!rn2(2) ? "a bit " : "somewhat "), reactions[react]); } - return (0); + return 0; } -void mdamageu(mtmp, n) /* mtmp hits you for n points damage */ +/* mtmp hits you for n points damage */ +void +mdamageu(mtmp, n) register struct monst *mtmp; register int n; { @@ -2207,7 +2215,7 @@ struct attack *mattk; xchar genagr, gendef; if (is_animal(magr->data)) - return (0); + return 0; if (magr == &youmonst) { pagr = youmonst.data; agrinvis = (Invis != 0); @@ -2527,18 +2535,18 @@ const char *str; Sprintf(hairbuf, "let me run my fingers through your %s", body_part(HAIR)); verbalize("Take off your %s; %s.", str, - (obj == uarm) ? "let's get a little closer" - : (obj == uarmc || obj == uarms) - ? "it's in the way" - : (obj == uarmf) - ? "let me rub your feet" - : (obj == uarmg) - ? "they're too clumsy" - : (obj == uarmu) - ? "let me massage you" - : - /* obj == uarmh */ - hairbuf); + (obj == uarm) + ? "let's get a little closer" + : (obj == uarmc || obj == uarms) + ? "it's in the way" + : (obj == uarmf) + ? "let me rub your feet" + : (obj == uarmg) + ? "they're too clumsy" + : (obj == uarmu) + ? "let me massage you" + /* obj == uarmh */ + : hairbuf); } remove_worn_item(obj, TRUE); } @@ -2597,7 +2605,7 @@ register struct attack *mattk; && (wornitems & protector) != protector))) { if (poly_when_stoned(mtmp->data)) { mon_to_stone(mtmp); - return (1); + return 1; } pline("%s turns to stone!", Monnam(mtmp)); stoned = 1; @@ -2613,7 +2621,7 @@ register struct attack *mattk; (void) drain_item(otmp); /* No message */ } - return (1); + return 1; default: break; } @@ -2739,7 +2747,7 @@ cloneu() mon->mhp = u.mh / 2; u.mh -= mon->mhp; context.botl = 1; - return (mon); + return mon; } /*mhitu.c*/ diff --git a/src/mon.c b/src/mon.c index 56b1ec155..060cd46b7 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mon.c $NHDT-Date: 1445215021 2015/10/19 00:37:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.190 $ */ +/* NetHack 3.6 mon.c $NHDT-Date: 1445556873 2015/10/22 23:34:33 $ $NHDT-Branch: master $:$NHDT-Revision: 1.192 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -443,7 +443,7 @@ register struct monst *mtmp; dryup(mtmp->mx, mtmp->my, FALSE); if (inpool) water_damage_chain(mtmp->minvent, FALSE); - return (0); + return 0; } else if (mtmp->data == &mons[PM_IRON_GOLEM] && inpool && !rn2(5)) { int dam = d(2, 6); @@ -982,9 +982,9 @@ register const char *str; /* Nymphs take everything. Most monsters don't pick up corpses. */ if (!str ? searches_for_item(mtmp, otmp) : !!(index(str, otmp->oclass))) { - if (otmp->otyp == CORPSE && mtmp->data->mlet != S_NYMPH && + if (otmp->otyp == CORPSE && mtmp->data->mlet != S_NYMPH /* let a handful of corpse types thru to can_carry() */ - !touch_petrifies(&mons[otmp->corpsenm]) + && !touch_petrifies(&mons[otmp->corpsenm]) && otmp->corpsenm != PM_LIZARD && !acidic(&mons[otmp->corpsenm])) continue; @@ -1062,7 +1062,7 @@ struct monst *mtmp; } /* for restricting monsters' object-pickup. - * + * * to support the new pet behavior, this now returns the max # of objects * that a given monster could pick up from a pile. frequently this will be * otmp->quan, but special cases for 'only one' now exist so. @@ -1220,11 +1220,11 @@ nexttry: /* eels prefer the water, but if there is no water nearby, || (IS_DOOR(nowtyp) && (levl[x][y].doormask & ~D_BROKEN)) || (IS_DOOR(ntyp) && (levl[nx][ny].doormask & ~D_BROKEN)) || ((IS_DOOR(nowtyp) || IS_DOOR(ntyp)) - && Is_rogue_level(&u.uz)) || + && Is_rogue_level(&u.uz)) /* mustn't pass between adjacent long worm segments, but can attack that way */ - (m_at(x, ny) && m_at(nx, y) && worm_cross(x, y, nx, ny) - && !m_at(nx, ny) && (nx != u.ux || ny != u.uy)))) + || (m_at(x, ny) && m_at(nx, y) && worm_cross(x, y, nx, ny) + && !m_at(nx, ny) && (nx != u.ux || ny != u.uy)))) continue; if ((is_pool(nx, ny) == wantpool || poolok) && (lavaok || !is_lava(nx, ny))) { @@ -1886,7 +1886,7 @@ boolean was_swallowed; /* digestion */ Sprintf(killer.name, "%s explosion", s_suffix(mdat->mname)); killer.format = KILLED_BY_AN; explode(mon->mx, mon->my, -1, tmp, MON_EXPLODE, EXPL_NOXIOUS); - return (FALSE); + return FALSE; } } @@ -2187,9 +2187,9 @@ int dest; /* dest==1, normal; dest==0, don't print message; dest==2, don't otmp = mkobj(RANDOM_CLASS, TRUE); /* don't create large objects from small monsters */ otyp = otmp->otyp; - if (mdat->msize < MZ_HUMAN && otyp != FIGURINE && + if (mdat->msize < MZ_HUMAN && otyp != FIGURINE /* oc_big is also oc_bimanual and oc_bulky */ - (otmp->owt > 30 || objects[otyp].oc_big)) { + && (otmp->owt > 30 || objects[otyp].oc_big)) { delobj(otmp); } else if (!flooreffects(otmp, x, y, (dest & 1) ? "fall" : "")) { place_object(otmp, x, y); @@ -2330,9 +2330,9 @@ struct monst *mtmp; do { if (!enexto(&mm, u.ux, u.uy, ptr)) return; - if (couldsee(mm.x, mm.y) && + if (couldsee(mm.x, mm.y) /* don't move grid bugs diagonally */ - (diagok || mm.x == mtmp->mx || mm.y == mtmp->my)) { + && (diagok || mm.x == mtmp->mx || mm.y == mtmp->my)) { rloc_to(mtmp, mm.x, mm.y); return; } @@ -2535,8 +2535,8 @@ void seemimic(mtmp) register struct monst *mtmp; { - boolean is_blocker_appear = is_door_mappear(mtmp) || - is_obj_mappear(mtmp, BOULDER); + boolean is_blocker_appear = (is_door_mappear(mtmp) + || is_obj_mappear(mtmp, BOULDER)); if (has_mcorpsenm(mtmp)) freemcorpsenm(mtmp); @@ -2870,7 +2870,7 @@ int *mndx_p, monclass; /* basic vampires can't become wolves; any can become fog or bat (we don't enforce upper-case only for rogue level here) */ if (*mndx_p == PM_WOLF) - return (mon->cham != PM_VAMPIRE); + return (boolean) (mon->cham != PM_VAMPIRE); if (*mndx_p == PM_FOG_CLOUD || *mndx_p == PM_VAMPIRE_BAT) return TRUE; @@ -2895,7 +2895,7 @@ int *mndx_p, monclass; *mndx_p = NON_PM; break; } - return (*mndx_p != NON_PM); + return (boolean) (*mndx_p != NON_PM); } int diff --git a/src/mondata.c b/src/mondata.c index cfd557088..fc8619285 100644 --- a/src/mondata.c +++ b/src/mondata.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mondata.c $NHDT-Date: 1437877181 2015/07/26 02:19:41 $ $NHDT-Branch: master $:$NHDT-Revision: 1.55 $ */ +/* NetHack 3.6 mondata.c $NHDT-Date: 1445556874 2015/10/22 23:34:34 $ $NHDT-Branch: master $:$NHDT-Revision: 1.57 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -140,10 +140,10 @@ struct monst *mon; struct obj *o; if (is_you ? (Blind || Unaware) - : (mon->mblinded || !mon->mcansee || !haseyes(ptr) || + : (mon->mblinded || !mon->mcansee || !haseyes(ptr) /* BUG: temporary sleep sets mfrozen, but since paralysis does too, we can't check it */ - mon->msleeping)) + || mon->msleeping)) return TRUE; /* yellow light, Archon; !dust vortex, !cobra, !raven */ if (dmgtype_fromattack(ptr, AD_BLND, AT_EXPL) @@ -264,10 +264,10 @@ struct permonst *ptr; register int i, atyp; long atk_mask = (1L << AT_BREA) | (1L << AT_SPIT) | (1L << AT_GAZE); - /* was: (attacktype(ptr, AT_BREA) || attacktype(ptr, AT_WEAP) || - attacktype(ptr, AT_SPIT) || attacktype(ptr, AT_GAZE) || - attacktype(ptr, AT_MAGC)); - but that's too slow -dlc + /* was: (attacktype(ptr, AT_BREA) || attacktype(ptr, AT_WEAP) + * || attacktype(ptr, AT_SPIT) || attacktype(ptr, AT_GAZE) + * || attacktype(ptr, AT_MAGC)); + * but that's too slow -dlc */ for (i = 0; i < NATTK; i++) { atyp = ptr->mattk[i].aatyp; diff --git a/src/monmove.c b/src/monmove.c index e9e14cd8e..feba6c426 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 monmove.c $NHDT-Date: 1431563244 2015/05/14 00:27:24 $ $NHDT-Branch: master $:$NHDT-Revision: 1.70 $ */ +/* NetHack 3.6 monmove.c $NHDT-Date: 1445556875 2015/10/22 23:34:35 $ $NHDT-Branch: master $:$NHDT-Revision: 1.76 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -32,11 +32,11 @@ register struct monst *mtmp; if (mtmp->mhp <= 0) { mondied(mtmp); if (mtmp->mhp > 0) /* lifesaved */ - return (FALSE); + return FALSE; else - return (TRUE); + return TRUE; } - return (FALSE); + return FALSE; } /* check whether a monster is carrying a locking/unlocking tool */ @@ -101,19 +101,19 @@ register struct monst *mtmp; /* a similar check is in monster_nearby() in hack.c */ /* check whether hero notices monster and stops current activity */ if (occupation && !rd && !Confusion && (!mtmp->mpeaceful || Hallucination) - && /* it's close enough to be a threat */ - distu(mtmp->mx, mtmp->my) <= (BOLT_LIM + 1) * (BOLT_LIM + 1) && + && distu(mtmp->mx, mtmp->my) <= (BOLT_LIM + 1) * (BOLT_LIM + 1) /* and either couldn't see it before, or it was too far away */ - (!already_saw_mon || !couldsee(x, y) - || distu(x, y) > (BOLT_LIM + 1) * (BOLT_LIM + 1)) && + && (!already_saw_mon || !couldsee(x, y) + || distu(x, y) > (BOLT_LIM + 1) * (BOLT_LIM + 1)) /* can see it now, or sense it and would normally see it */ - (canseemon(mtmp) || (sensemon(mtmp) && couldsee(mtmp->mx, mtmp->my))) + && (canseemon(mtmp) + || (sensemon(mtmp) && couldsee(mtmp->mx, mtmp->my))) && mtmp->mcanmove && !noattacks(mtmp->data) && !onscary(u.ux, u.uy, mtmp)) stop_occupation(); - return (rd); + return rd; } boolean @@ -127,16 +127,17 @@ struct monst *mtmp; * Rodney, lawful minions, angels, the Riders */ if (mtmp->iswiz || is_lminion(mtmp) || mtmp->data == &mons[PM_ANGEL] || is_rider(mtmp->data)) - return (FALSE); + return FALSE; /* should this still be true for defiled/molochian altars? */ - if (IS_ALTAR(levl[x][y].typ) && (mtmp->data->mlet == S_VAMPIRE - || is_vampshifter(mtmp))) - return(TRUE); + if (IS_ALTAR(levl[x][y].typ) + && (mtmp->data->mlet == S_VAMPIRE || is_vampshifter(mtmp))) + return TRUE; /* the scare monster scroll doesn't have any of the below * restrictions, being its own source of power */ - if (sobj_at(SCR_SCARE_MONSTER, x, y)) return(TRUE); + if (sobj_at(SCR_SCARE_MONSTER, x, y)) + return TRUE; /* creatures who don't (or can't) fear a written Elbereth: * all the above plus shopkeepers, guards, blind or @@ -147,14 +148,13 @@ struct monst *mtmp; * * Elbereth doesn't work in Gehennom, the Elemental Planes, or the * Astral Plane; the influence of the Valar only reaches so far. */ - return (epresent - && ((u.ux == x && u.uy == y) - || (Displaced && mtmp->mux == x && mtmp->muy == y)) - && !(mtmp->isshk || mtmp->isgd || !mtmp->mcansee - || mtmp->mpeaceful || mtmp->data->mlet == S_HUMAN - || mtmp->data == &mons[PM_MINOTAUR] - || Inhell || In_endgame(&u.uz))); - + return (epresent + && ((u.ux == x && u.uy == y) + || (Displaced && mtmp->mux == x && mtmp->muy == y)) + && !(mtmp->isshk || mtmp->isgd || !mtmp->mcansee + || mtmp->mpeaceful || mtmp->data->mlet == S_HUMAN + || mtmp->data == &mons[PM_MINOTAUR] + || Inhell || In_endgame(&u.uz))); } @@ -202,7 +202,7 @@ register struct monst *mtmp; && (!(mtmp->data->mlet == S_NYMPH || mtmp->data == &mons[PM_JABBERWOCK] #if 0 /* DEFERRED */ - || mtmp->data == &mons[PM_VORPAL_JABBERWOCK] + || mtmp->data == &mons[PM_VORPAL_JABBERWOCK] #endif || mtmp->data->mlet == S_LEPRECHAUN) || !rn2(50)) && (Aggravate_monster @@ -210,9 +210,9 @@ register struct monst *mtmp; || (!rn2(7) && mtmp->m_ap_type != M_AP_FURNITURE && mtmp->m_ap_type != M_AP_OBJECT))) { mtmp->msleeping = 0; - return (1); + return 1; } - return (0); + return 0; } /* ungrab/expel held/swallowed hero */ @@ -362,14 +362,14 @@ register struct monst *mtmp; if (mtmp->mcanmove && (mtmp->mstrategy & STRAT_CLOSE) && !mtmp->msleeping && monnear(mtmp, u.ux, u.uy)) quest_talk(mtmp); /* give the leaders a chance to speak */ - return (0); /* other frozen monsters can't do anything */ + return 0; /* other frozen monsters can't do anything */ } /* there is a chance we will wake it */ if (mtmp->msleeping && !disturb(mtmp)) { if (Hallucination) newsym(mtmp->mx, mtmp->my); - return (0); + return 0; } /* not frozen or sleeping: wipe out texts written in the dust */ @@ -387,14 +387,14 @@ register struct monst *mtmp; if (mtmp->mflee && !rn2(40) && can_teleport(mdat) && !mtmp->iswiz && !level.flags.noteleport) { (void) rloc(mtmp, TRUE); - return (0); + return 0; } if (mdat->msound == MS_SHRIEK && !um_dist(mtmp->mx, mtmp->my, 1)) m_respond(mtmp); if (mdat == &mons[PM_MEDUSA] && couldsee(mtmp->mx, mtmp->my)) m_respond(mtmp); if (mtmp->mhp <= 0) - return (1); /* m_respond gaze can kill medusa */ + return 1; /* m_respond gaze can kill medusa */ /* fleeing monsters might regain courage */ if (mtmp->mflee && !mtmp->mfleetim && mtmp->mhp == mtmp->mhpmax @@ -449,7 +449,7 @@ register struct monst *mtmp; /* since no way is an image going to pay it off */ } } else if (demon_talk(mtmp)) - return (1); /* you paid it off */ + return 1; /* you paid it off */ } /* the watch will look around and see if you are up to no good :-) */ @@ -528,7 +528,7 @@ toofar: && !(mtmp->mtrapped && !nearby && select_rwep(mtmp))) { mtmp->weapon_check = NEED_HTH_WEAPON; if (mon_wield_item(mtmp) != 0) - return (0); + return 0; } } @@ -582,7 +582,7 @@ toofar: case 1: /* monster moved */ /* Maybe it stepped on a trap and fell asleep... */ if (mtmp->msleeping || !mtmp->mcanmove) - return (0); + return 0; /* Monsters can move and then shoot on same turn; our hero can't. Is that fair? */ if (!nearby && (ranged_attk(mdat) || find_offensive(mtmp))) @@ -598,9 +598,9 @@ toofar: if (distu(mtmp->mx, mtmp->my) > 2) unstuck(mtmp); } - return (0); + return 0; case 2: /* monster died */ - return (1); + return 1; } } @@ -609,7 +609,7 @@ toofar: if (!mtmp->mpeaceful || (Conflict && !resist(mtmp, RING_CLASS, 0, 0))) { if (inrange && !noattacks(mdat) && u.uhp > 0 && !scared && tmp != 3) if (mattacku(mtmp)) - return (1); /* monster died (e.g. exploded) */ + return 1; /* monster died (e.g. exploded) */ if (mtmp->wormno) wormhitu(mtmp); @@ -641,9 +641,9 @@ register struct monst *mtmp; { if (sticks(youmonst.data) && mtmp == u.ustuck && !u.uswallow) { pline("%s cannot escape from you!", Monnam(mtmp)); - return (TRUE); + return TRUE; } - return (FALSE); + return FALSE; } /* @@ -723,10 +723,10 @@ register int after; int i = mintrap(mtmp); if (i >= 2) { newsym(mtmp->mx, mtmp->my); - return (2); + return 2; } /* it died */ if (i == 1) - return (0); /* still in trap, so didn't move */ + return 0; /* still in trap, so didn't move */ } ptr = mtmp->data; /* mintrap() can change mtmp->data -dlc */ @@ -762,7 +762,7 @@ register int after; if (mtmp->isshk) { mmoved = shk_move(mtmp); if (mmoved == -2) - return (2); + return 2; if (mmoved >= 0) goto postmov; mmoved = 0; /* follow player outside shop */ @@ -772,7 +772,7 @@ register int after; if (mtmp->isgd) { mmoved = gd_move(mtmp); if (mmoved == -2) - return (2); + return 2; if (mmoved >= 0) goto postmov; mmoved = 0; @@ -791,7 +791,7 @@ register int after; && (intruder != mtmp)) { notonhead = (intruder->mx != tx || intruder->my != ty); if (mattackm(mtmp, intruder) == 2) - return (2); + return 2; mmoved = 1; } else mmoved = 0; @@ -802,7 +802,7 @@ register int after; if (mtmp->ispriest) { mmoved = pri_move(mtmp); if (mmoved == -2) - return (2); + return 2; if (mmoved >= 0) goto postmov; mmoved = 0; @@ -813,7 +813,7 @@ register int after; if (!Deaf && canseemon(mtmp)) verbalize("I'm late!"); mongone(mtmp); - return (2); + return 2; } #endif @@ -829,7 +829,7 @@ register int after; } not_special: if (u.uswallow && !mtmp->mflee && u.ustuck != mtmp) - return (1); + return 1; omx = mtmp->mx; omy = mtmp->my; gx = mtmp->mux; @@ -960,13 +960,11 @@ not_special: && touch_petrifies(&mons[otmp->corpsenm])))) && touch_artifact(otmp, mtmp)) { if (can_carry(mtmp, otmp) > 0 - && (throws_rocks(ptr) - || !sobj_at(BOULDER, xx, yy)) + && (throws_rocks(ptr) || !sobj_at(BOULDER, xx, yy)) && (!is_unicorn(ptr) - || objects[otmp->otyp].oc_material - == GEMSTONE) && + || objects[otmp->otyp].oc_material == GEMSTONE) /* Don't get stuck circling an Elbereth */ - !(onscary(xx, yy, mtmp))) { + && !(onscary(xx, yy, mtmp))) { minr = distmin(omx, omy, xx, yy); oomx = min(COLNO - 1, omx + minr); oomy = min(ROWNO - 1, omy + minr); @@ -1096,7 +1094,7 @@ not_special: register int j; if (mmoved == 1 && (u.ux != nix || u.uy != niy) && itsstuck(mtmp)) - return (3); + return 3; if (mmoved == 1 && can_tunnel && needspick(ptr) && ((IS_ROCK(levl[nix][niy].typ) && may_dig(nix, niy)) @@ -1112,7 +1110,7 @@ not_special: mtmp->weapon_check = NEED_PICK_AXE; } if (mtmp->weapon_check >= NEED_PICK_AXE && mon_wield_item(mtmp)) - return (3); + return 3; } /* If ALLOW_U is set, either it's trying to attack you, or it * thinks it is. In either case, attack this spot in preference to @@ -1134,7 +1132,7 @@ not_special: if (nix == u.ux && niy == u.uy) { mtmp->mux = u.ux; mtmp->muy = u.uy; - return (0); + return 0; } /* The monster may attack another based on 1 of 2 conditions: * 1 - It may be confused. @@ -1191,7 +1189,7 @@ not_special: } else { if (is_unicorn(ptr) && rn2(2) && !tele_restrict(mtmp)) { (void) rloc(mtmp, TRUE); - return (1); + return 1; } if (mtmp->wormno) worm_nomove(mtmp); @@ -1205,7 +1203,7 @@ postmov: if (mintrap(mtmp) >= 2) { if (mtmp->mx) newsym(mtmp->mx, mtmp->my); - return (2); /* it died */ + return 2; /* it died */ } ptr = mtmp->data; @@ -1234,7 +1232,7 @@ postmov: newsym(mtmp->mx, mtmp->my); unblock_point(mtmp->mx, mtmp->my); /* vision */ if (mb_trapped(mtmp)) - return (2); + return 2; } else { if (flags.verbose) { if (observeit) @@ -1255,7 +1253,7 @@ postmov: newsym(mtmp->mx, mtmp->my); unblock_point(mtmp->mx, mtmp->my); /* vision */ if (mb_trapped(mtmp)) - return (2); + return 2; } else { if (flags.verbose) { if (observeit) @@ -1276,7 +1274,7 @@ postmov: newsym(mtmp->mx, mtmp->my); unblock_point(mtmp->mx, mtmp->my); /* vision */ if (mb_trapped(mtmp)) - return (2); + return 2; } else { if (flags.verbose) { if (observeit) @@ -1304,7 +1302,7 @@ postmov: if (canseemon(mtmp)) pline("%s eats through the iron bars.", Monnam(mtmp)); dissolve_bars(mtmp->mx, mtmp->my); - return (3); + return 3; } else if (flags.verbose && canseemon(mtmp)) Norep("%s %s %s the iron bars.", Monnam(mtmp), /* pluralization fakes verb conjugation */ @@ -1314,7 +1312,7 @@ postmov: /* possibly dig */ if (can_tunnel && mdig_tunnel(mtmp)) - return (2); /* mon died (position already updated) */ + return 2; /* mon died (position already updated) */ /* set also in domove(), hack.c */ if (u.uswallow && mtmp == u.ustuck @@ -1398,7 +1396,7 @@ postmov: after_shk_move(mtmp); } } - return (mmoved); + return mmoved; } void @@ -1413,8 +1411,8 @@ boolean closed_door(x, y) register int x, y; { - return ((boolean)(IS_DOOR(levl[x][y].typ) - && (levl[x][y].doormask & (D_LOCKED | D_CLOSED)))); + return (boolean) (IS_DOOR(levl[x][y].typ) + && (levl[x][y].doormask & (D_LOCKED | D_CLOSED))); } boolean @@ -1427,7 +1425,7 @@ register int x, y; if (levtyp == DRAWBRIDGE_UP) levtyp = db_under_typ(levl[x][y].drawbridgemask); - return (boolean)(ACCESSIBLE(levtyp) && !closed_door(x, y)); + return (boolean) (ACCESSIBLE(levtyp) && !closed_door(x, y)); } /* decide where the monster thinks you are standing */ @@ -1468,15 +1466,10 @@ register struct monst *mtmp; if (!disp) goto found_you; - /* without something like the following, invis. and displ. + /* without something like the following, invisibility and displacement are too powerful */ gotu = notseen ? !rn2(3) : Displaced ? !rn2(4) : FALSE; -#if 0 /* this never worked as intended & isn't needed anyway */ - /* If invis but not displaced, staying around gets you 'discovered' */ - gotu |= (!Displaced && u.dx == 0 && u.dy == 0); -#endif - if (!gotu) { register int try_cnt = 0; do { diff --git a/src/monst.c b/src/monst.c index 71de30e3a..9a4185773 100644 --- a/src/monst.c +++ b/src/monst.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 monst.c $NHDT-Date: 1432512763 2015/05/25 00:12:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.51 $ */ +/* NetHack 3.6 monst.c $NHDT-Date: 1445556875 2015/10/22 23:34:35 $ $NHDT-Branch: master $:$NHDT-Revision: 1.53 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -331,13 +331,13 @@ NEARDATA struct permonst mons[] = { M2_HOSTILE | M2_NEUTER, M3_INFRAVISIBLE, HI_ZAP), #if 0 /* not yet implemented */ MON("beholder", S_EYE, - LVL(6, 3, 4, 0, -10), (G_GENO|2), + LVL(6, 3, 4, 0, -10), (G_GENO | 2), A(ATTK(AT_GAZE, AD_SLOW, 0, 0), ATTK(AT_GAZE, AD_SLEE, 2,25), ATTK(AT_GAZE, AD_DISN, 0, 0), ATTK(AT_GAZE, AD_STON, 0, 0), ATTK(AT_GAZE, AD_CNCL, 2, 4), ATTK(AT_BITE, AD_PHYS, 2, 4)), SIZ(10, 10, MS_SILENT, MZ_SMALL), MR_COLD, 0, - M1_FLY|M1_BREATHLESS|M1_NOLIMBS|M1_NOHEAD|M1_MINDLESS, - M2_NOPOLY|M2_HOSTILE|M2_NEUTER, M3_INFRAVISIBLE, CLR_BROWN), + M1_FLY | M1_BREATHLESS | M1_NOLIMBS | M1_NOHEAD | M1_MINDLESS, + M2_NOPOLY | M2_HOSTILE | M2_NEUTER, M3_INFRAVISIBLE, CLR_BROWN), #endif /* * felines @@ -1108,8 +1108,8 @@ NEARDATA struct permonst mons[] = { A(ATTK(AT_BITE, AD_PHYS, 2, 6), NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK), SIZ(1500, 500, MS_ROAR, MZ_HUGE), 0, 0, - M1_FLY|M1_THICK_HIDE|M1_NOHANDS|M1_CARNIVORE, - M2_HOSTILE|M2_STRONG|M2_GREEDY|M2_JEWELS, 0, CLR_CYAN), + M1_FLY | M1_THICK_HIDE | M1_NOHANDS | M1_CARNIVORE, + M2_HOSTILE | M2_STRONG | M2_GREEDY | M2_JEWELS, 0, CLR_CYAN), #endif MON("baby red dragon", S_DRAGON, LVL(12, 9, 2, 10, 0), G_GENO, A(ATTK(AT_BITE, AD_PHYS, 2, 6), NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, @@ -1174,14 +1174,14 @@ NEARDATA struct permonst mons[] = { 0, DRAGON_SILVER), #if 0 /* DEFERRED */ MON("shimmering dragon", S_DRAGON, - LVL(15, 9, -1, 20, 4), (G_GENO|1), + LVL(15, 9, -1, 20, 4), (G_GENO | 1), A(ATTK(AT_BREA, AD_MAGM, 4, 6), ATTK(AT_BITE, AD_PHYS, 3, 8), ATTK(AT_CLAW, AD_PHYS, 1, 4), ATTK(AT_CLAW, AD_PHYS, 1, 4), NO_ATTK, NO_ATTK), SIZ(WT_DRAGON, 1500, MS_ROAR, MZ_GIGANTIC), 0, 0, - M1_FLY|M1_THICK_HIDE|M1_NOHANDS|M1_SEE_INVIS|M1_OVIPAROUS| - M1_CARNIVORE, - M2_HOSTILE|M2_STRONG|M2_NASTY|M2_GREEDY|M2_JEWELS|M2_MAGIC, + M1_FLY | M1_THICK_HIDE | M1_NOHANDS | M1_SEE_INVIS | M1_OVIPAROUS + | M1_CARNIVORE, + M2_HOSTILE | M2_STRONG | M2_NASTY | M2_GREEDY | M2_JEWELS | M2_MAGIC, 0, CLR_CYAN), #endif MON("red dragon", S_DRAGON, LVL(15, 9, -1, 20, -4), (G_GENO | 1), @@ -1465,13 +1465,14 @@ struct permonst _mons2[] = { CLR_ORANGE), #if 0 /* DEFERRED */ MON("vorpal jabberwock", S_JABBERWOCK, - LVL(20, 12, -2, 50, 0), (G_GENO|1), + LVL(20, 12, -2, 50, 0), (G_GENO | 1), A(ATTK(AT_BITE, AD_PHYS, 3, 10), ATTK(AT_BITE, AD_PHYS, 3, 10), ATTK(AT_CLAW, AD_PHYS, 3, 10), ATTK(AT_CLAW, AD_PHYS, 3, 10), NO_ATTK, NO_ATTK), SIZ(1300, 600, MS_BURBLE, MZ_LARGE), 0, 0, - M1_ANIMAL|M1_FLY|M1_CARNIVORE, - M2_HOSTILE|M2_STRONG|M2_NASTY|M2_COLLECT, M3_INFRAVISIBLE, HI_LORD), + M1_ANIMAL | M1_FLY | M1_CARNIVORE, + M2_HOSTILE | M2_STRONG | M2_NASTY | M2_COLLECT, M3_INFRAVISIBLE, + HI_LORD), #endif /* * Kops @@ -1856,13 +1857,14 @@ struct permonst _mons2[] = { M3_INFRAVISIBLE, CLR_BLUE), #if 0 /* DEFERRED */ MON("vampire mage", S_VAMPIRE, - LVL(20, 14, -4, 50, -9), (G_GENO|G_NOCORPSE|1), + LVL(20, 14, -4, 50, -9), (G_GENO | G_NOCORPSE | 1), A(ATTK(AT_CLAW, AD_DRLI, 2, 8), ATTK(AT_BITE, AD_DRLI, 1, 8), ATTK(AT_MAGC, AD_SPEL, 2, 6), NO_ATTK, NO_ATTK, NO_ATTK), - SIZ(WT_HUMAN, 400, MS_VAMPIRE, MZ_HUMAN), MR_SLEEP|MR_POISON, 0, - M1_FLY|M1_BREATHLESS|M1_HUMANOID|M1_POIS|M1_REGEN, - M2_UNDEAD|M2_STALK|M2_HOSTILE|M2_STRONG|M2_NASTY|M2_LORD|M2_MALE| - M2_MAGIC|M2_SHAPESHIFTER, M3_INFRAVISIBLE, HI_ZAP), + SIZ(WT_HUMAN, 400, MS_VAMPIRE, MZ_HUMAN), MR_SLEEP | MR_POISON, 0, + M1_FLY | M1_BREATHLESS | M1_HUMANOID | M1_POIS | M1_REGEN, + M2_UNDEAD | M2_STALK | M2_HOSTILE | M2_STRONG | M2_NASTY | M2_LORD + | M2_MALE | M2_MAGIC | M2_SHAPESHIFTER, + M3_INFRAVISIBLE, HI_ZAP), #endif MON("Vlad the Impaler", S_VAMPIRE, LVL(14, 18, -3, 80, -10), (G_NOGEN | G_NOCORPSE | G_UNIQ), @@ -2849,23 +2851,23 @@ struct permonst _mons2[] = { /* Two for elves - one of each sex. */ MON("Earendil", S_HUMAN, - LVL(20, 12, 0, 50, -20), (G_NOGEN|G_UNIQ), + LVL(20, 12, 0, 50, -20), (G_NOGEN | G_UNIQ), A(ATTK(AT_WEAP, AD_PHYS, 1, 8), NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK), SIZ(WT_ELF, 350, MS_LEADER, MZ_HUMAN), MR_SLEEP, MR_SLEEP, - M1_HUMANOID|M1_SEE_INVIS|M1_OMNIVORE, - M2_NOPOLY|M2_ELF|M2_HUMAN|M2_PNAME|M2_PEACEFUL|M2_STRONG| - M2_MALE|M2_COLLECT|M2_MAGIC, - M3_CLOSE|M3_INFRAVISION|M3_INFRAVISIBLE, HI_LORD), + M1_HUMANOID | M1_SEE_INVIS | M1_OMNIVORE, + M2_NOPOLY | M2_ELF | M2_HUMAN | M2_PNAME | M2_PEACEFUL | M2_STRONG + | M2_MALE | M2_COLLECT | M2_MAGIC, + M3_CLOSE | M3_INFRAVISION | M3_INFRAVISIBLE, HI_LORD), MON("Elwing", S_HUMAN, - LVL(20, 12, 0, 50, -20), (G_NOGEN|G_UNIQ), + LVL(20, 12, 0, 50, -20), (G_NOGEN | G_UNIQ), A(ATTK(AT_WEAP, AD_PHYS, 1, 8), NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK), SIZ(WT_ELF, 350, MS_LEADER, MZ_HUMAN), MR_SLEEP, MR_SLEEP, - M1_HUMANOID|M1_SEE_INVIS|M1_OMNIVORE, - M2_NOPOLY|M2_ELF|M2_HUMAN|M2_PNAME|M2_PEACEFUL|M2_STRONG| - M2_FEMALE|M2_COLLECT|M2_MAGIC, - M3_CLOSE|M3_INFRAVISION|M3_INFRAVISIBLE, HI_LORD), + M1_HUMANOID | M1_SEE_INVIS | M1_OMNIVORE, + M2_NOPOLY | M2_ELF | M2_HUMAN | M2_PNAME | M2_PEACEFUL | M2_STRONG + | M2_FEMALE | M2_COLLECT | M2_MAGIC, + M3_CLOSE | M3_INFRAVISION | M3_INFRAVISIBLE, HI_LORD), #endif MON("Hippocrates", S_HUMAN, LVL(20, 12, 0, 40, 0), (G_NOGEN | G_UNIQ), A(ATTK(AT_WEAP, AD_PHYS, 1, 6), NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, @@ -2998,14 +3000,15 @@ struct permonst _mons2[] = { M3_WANTSARTI | M3_WAITFORU | M3_INFRAVISIBLE, HI_LORD), #if 0 /* OBSOLETE */ MON("Goblin King", S_ORC, - LVL(15, 12, 10, 0, -15), (G_NOGEN|G_UNIQ), + LVL(15, 12, 10, 0, -15), (G_NOGEN | G_UNIQ), A(ATTK(AT_WEAP, AD_PHYS, 2, 6), ATTK(AT_WEAP, AD_PHYS, 2, 6), ATTK(AT_CLAW, AD_SAMU, 1, 6), NO_ATTK, NO_ATTK, NO_ATTK), SIZ(750, 350, MS_NEMESIS, MZ_HUMAN), 0, 0, - M1_HUMANOID|M1_OMNIVORE, - M2_NOPOLY|M2_ORC|M2_HOSTILE|M2_STRONG|M2_STALK|M2_NASTY|M2_MALE| - M2_GREEDY|M2_JEWELS|M2_COLLECT|M2_MAGIC, - M3_WANTSARTI|M3_WAITFORU|M3_INFRAVISION|M3_INFRAVISIBLE, HI_LORD), + M1_HUMANOID | M1_OMNIVORE, + M2_NOPOLY | M2_ORC | M2_HOSTILE | M2_STRONG | M2_STALK | M2_NASTY + | M2_MALE | M2_GREEDY | M2_JEWELS | M2_COLLECT | M2_MAGIC, + M3_WANTSARTI | M3_WAITFORU | M3_INFRAVISION | M3_INFRAVISIBLE, + HI_LORD), #endif MON("Cyclops", S_GIANT, LVL(18, 12, 0, 0, -15), (G_NOGEN | G_UNIQ), A(ATTK(AT_WEAP, AD_PHYS, 4, 8), ATTK(AT_WEAP, AD_PHYS, 4, 8), @@ -3127,9 +3130,9 @@ struct permonst _mons2[] = { A(ATTK(AT_WEAP, AD_PHYS, 2, 4), ATTK(AT_MAGC, AD_CLRC, 0, 0), NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK), SIZ(WT_ELF, 350, MS_GUARDIAN, MZ_HUMAN), MR_SLEEP, MR_SLEEP, - M1_HUMANOID|M1_SEE_INVIS|M1_OMNIVORE, - M2_NOPOLY|M2_ELF|M2_PEACEFUL|M2_COLLECT, - M3_INFRAVISION|M3_INFRAVISIBLE, HI_DOMESTIC), + M1_HUMANOID | M1_SEE_INVIS | M1_OMNIVORE, + M2_NOPOLY | M2_ELF | M2_PEACEFUL | M2_COLLECT, + M3_INFRAVISION | M3_INFRAVISIBLE, HI_DOMESTIC), #endif MON("attendant", S_HUMAN, LVL(5, 12, 10, 10, 3), G_NOGEN, A(ATTK(AT_WEAP, AD_PHYS, 1, 6), NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, diff --git a/src/mthrowu.c b/src/mthrowu.c index b00ae0971..061370908 100644 --- a/src/mthrowu.c +++ b/src/mthrowu.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mthrowu.c $NHDT-Date: 1444258159 2015/10/07 22:49:19 $ $NHDT-Branch: master $:$NHDT-Revision: 1.58 $ */ +/* NetHack 3.6 mthrowu.c $NHDT-Date: 1445556876 2015/10/22 23:34:36 $ $NHDT-Branch: master $:$NHDT-Revision: 1.59 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -579,9 +579,9 @@ struct monst *mtmp; multishot = 1; if (otmp->quan > 1L && /* no point checking if there's only 1 */ /* ammo requires corresponding launcher be wielded */ - (is_ammo(otmp) ? matching_launcher(otmp, mwep) : + (is_ammo(otmp) ? matching_launcher(otmp, mwep) /* otherwise any stackable (non-ammo) weapon */ - otmp->oclass == WEAPON_CLASS) && !mtmp->mconf) { + : otmp->oclass == WEAPON_CLASS) && !mtmp->mconf) { int skill = (int) objects[otmp->otyp].oc_skill; /* Assumes lords are skilled, princes are expert */ @@ -609,7 +609,7 @@ struct monst *mtmp; case PM_NINJA: if (skill == -P_SHURIKEN || skill == -P_DART) multishot++; - /*FALLTHRU*/ + /*FALLTHRU*/ case PM_SAMURAI: if (otmp->otyp == YA && mwep && mwep->otyp == YUMI) multishot++; diff --git a/src/muse.c b/src/muse.c index 326e0ce40..d774303e6 100644 --- a/src/muse.c +++ b/src/muse.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 muse.c $NHDT-Date: 1444260722 2015/10/07 23:32:02 $ $NHDT-Branch: master $:$NHDT-Revision: 1.65 $ */ +/* NetHack 3.6 muse.c $NHDT-Date: 1445556877 2015/10/22 23:34:37 $ $NHDT-Branch: master $:$NHDT-Revision: 1.66 $ */ /* Copyright (C) 1990 by Ken Arromdee */ /* NetHack may be freely redistributed. See license for details. */ @@ -1663,16 +1663,17 @@ struct monst *mtmp; m.has_misc = MUSE_POT_GAIN_LEVEL; } nomore(MUSE_BULLWHIP); - if (obj->otyp == BULLWHIP && !mtmp->mpeaceful && + if (obj->otyp == BULLWHIP && !mtmp->mpeaceful /* the random test prevents whip-wielding monster from attempting disarm every turn */ - uwep && !rn2(5) && obj == MON_WEP(mtmp) && + && uwep && !rn2(5) && obj == MON_WEP(mtmp) /* hero's location must be known and adjacent */ - mtmp->mux == u.ux && mtmp->muy == u.uy - && distu(mtmp->mx, mtmp->my) <= 2 && + && mtmp->mux == u.ux && mtmp->muy == u.uy + && distu(mtmp->mx, mtmp->my) <= 2 /* don't bother if it can't work (this doesn't prevent cursed weapons from being targetted) */ - (canletgo(uwep, "") || (u.twoweap && canletgo(uswapwep, "")))) { + && (canletgo(uwep, "") + || (u.twoweap && canletgo(uswapwep, "")))) { m.misc = obj; m.has_misc = MUSE_BULLWHIP; } diff --git a/src/objnam.c b/src/objnam.c index ff8ba5e4c..2a61d9ac4 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 objnam.c $NHDT-Date: 1445126428 2015/10/18 00:00:28 $ $NHDT-Branch: master $:$NHDT-Revision: 1.148 $ */ +/* NetHack 3.6 objnam.c $NHDT-Date: 1445556878 2015/10/22 23:34:38 $ $NHDT-Branch: master $:$NHDT-Revision: 1.149 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -64,11 +64,11 @@ register const char *pref; if (i > PREFIX) { impossible("PREFIX too short (for %d).", i); - return (s); + return s; } s -= i; (void) strncpy(s, pref, i); /* do not copy trailing 0 */ - return (s); + return s; } /* manage a pool of BUFSZ buffers, so callers don't have to */ @@ -134,7 +134,7 @@ register int otyp; Sprintf(eos(buf), " called %s", un); if (dn) Sprintf(eos(buf), " (%s)", dn); - return (buf); + return buf; default: if (nn) { Strcpy(buf, actualn); @@ -152,7 +152,7 @@ register int otyp; if (un) Sprintf(eos(buf), " called %s", un); } - return (buf); + return buf; } /* here for ring/scroll/potion/wand */ if (nn) { @@ -165,7 +165,7 @@ register int otyp; Sprintf(eos(buf), " called %s", un); if (dn) Sprintf(eos(buf), " (%s)", dn); - return (buf); + return buf; } /* less verbose result than obj_typename(); either the actual name @@ -551,7 +551,7 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */ if (!strncmpi(buf, "the ", 4)) buf += 4; - return (buf); + return buf; } /* similar to simple_typename but minimal_xname operates on a particular @@ -586,9 +586,8 @@ struct obj *obj; /* suppress known except for amulets (needed for fakes and real A-of-Y) */ bareobj.known = (obj->oclass == AMULET_CLASS) ? obj->known - : /* default is "on" for types which don't use it */ - !objects[otyp].oc_uses_known; + : !objects[otyp].oc_uses_known; bareobj.quan = 1L; /* don't want plural */ bareobj.corpsenm = NON_PM; /* suppress statue and figurine details */ /* but suppressing fruit details leads to "bad fruit #0" @@ -635,8 +634,8 @@ register struct obj *obj; else if (obj->otyp == FAKE_AMULET_OF_YENDOR && !known) return TRUE; /* lie */ else - return (boolean)(objects[obj->otyp].oc_unique - && (known || obj->otyp == AMULET_OF_YENDOR)); + return (boolean) (objects[obj->otyp].oc_unique + && (known || obj->otyp == AMULET_OF_YENDOR)); } /* should monster type be prefixed with "the"? (mostly used for corpses) */ @@ -760,19 +759,18 @@ boolean with_price; Strcpy(prefix, "a "); /* "empty" goes at the beginning, but item count goes at the end */ - if (cknown && + if (cknown /* bag of tricks: include "empty" prefix if it's known to be empty but its precise number of charges isn't known (when that is known, suffix of "(n:0)" will be appended, making the prefix be redundant; note that 'known' flag isn't set when emptiness gets discovered because then charging magic would yield known number of new charges) */ - (obj->otyp == BAG_OF_TRICKS + && (obj->otyp == BAG_OF_TRICKS ? (obj->spe == 0 && !obj->known) - : /* not bag of tricks: empty if container which has no contents */ - (Is_container(obj) || obj->otyp == STATUE) - && !Has_contents(obj))) + : (Is_container(obj) || obj->otyp == STATUE) + && !Has_contents(obj))) Strcat(prefix, "empty "); if (bknown && obj->oclass != COIN_CLASS @@ -1025,7 +1023,7 @@ boolean with_price; Sprintf(eos(bp), " (%d aum)", obj->owt); } bp = strprepend(bp, prefix); - return (bp); + return bp; } char * @@ -1052,13 +1050,13 @@ register struct obj *otmp; if (otmp->oclass == COIN_CLASS) return FALSE; /* always fully ID'd */ /* check fundamental ID hallmarks first */ - if (!otmp->known || !otmp->dknown || + if (!otmp->known || !otmp->dknown #ifdef MAIL - (!otmp->bknown && otmp->otyp != SCR_MAIL) || + || (!otmp->bknown && otmp->otyp != SCR_MAIL) #else - !otmp->bknown || + || !otmp->bknown #endif - !objects[otmp->otyp].oc_name_known) + || !objects[otmp->otyp].oc_name_known) return TRUE; if ((!otmp->cknown && (Is_container(otmp) || otmp->otyp == STATUE)) || (!otmp->lknown && Is_box(otmp))) @@ -1067,18 +1065,18 @@ register struct obj *otmp; return TRUE; /* otmp->rknown is the only item of interest if we reach here */ /* - * Note: if a revision ever allows scrolls to become fireproof or - * rings to become shockproof, this checking will need to be revised. - * `rknown' ID only matters if xname() will provide the info about it. - */ + * Note: if a revision ever allows scrolls to become fireproof or + * rings to become shockproof, this checking will need to be revised. + * `rknown' ID only matters if xname() will provide the info about it. + */ if (otmp->rknown || (otmp->oclass != ARMOR_CLASS && otmp->oclass != WEAPON_CLASS - && !is_weptool(otmp) && /* (redundant) */ - otmp->oclass != BALL_CLASS)) /* (useless) */ + && !is_weptool(otmp) /* (redundant) */ + && otmp->oclass != BALL_CLASS)) /* (useless) */ return FALSE; else /* lack of `rknown' only matters for vulnerable objects */ - return (boolean)(is_rustprone(otmp) || is_corrodeable(otmp) - || is_flammable(otmp)); + return (boolean) (is_rustprone(otmp) || is_corrodeable(otmp) + || is_flammable(otmp)); } char * @@ -1469,7 +1467,7 @@ register const char *verb; Strcat(bp, " "); Strcat(bp, otense(otmp, verb)); } - return (bp); + return bp; } /* combine yname and aobjnam eg "your count cxname(otmp)" */ @@ -1502,7 +1500,7 @@ const char *verb; register char *s = yobjnam(obj, verb); *s = highc(*s); - return (s); + return s; } /* like aobjnam, but prepend "The", not count, and use xname */ @@ -1517,7 +1515,7 @@ register const char *verb; Strcat(bp, " "); Strcat(bp, otense(otmp, verb)); } - return (bp); + return bp; } /* capitalized variant of doname() */ @@ -1528,7 +1526,7 @@ register struct obj *obj; register char *s = doname(obj); *s = highc(*s); - return (s); + return s; } /* returns "[your ]xname(obj)" or "Foobar's xname(obj)" or "the xname(obj)" */ @@ -1996,9 +1994,9 @@ const char *oldstr; } /* man/men ("Wiped out all cavemen.") */ - if (len >= 3 && !strcmpi(spot - 2, "man") && + if (len >= 3 && !strcmpi(spot - 2, "man") /* exclude shamans and humans */ - (len < 6 || strcmpi(spot - 5, "shaman")) + && (len < 6 || strcmpi(spot - 5, "shaman")) && (len < 5 || strcmpi(spot - 4, "human"))) { Strcasecpy(spot - 1, "en"); goto bottom; @@ -2060,9 +2058,9 @@ const char *oldstr; /* Ends in z, x, s, ch, sh; add an "es" */ if (index("zxs", lo_c) - || (len >= 2 && lo_c == 'h' && index("cs", lowc(*(spot - 1)))) || + || (len >= 2 && lo_c == 'h' && index("cs", lowc(*(spot - 1)))) /* Kludge to get "tomatoes" and "potatoes" right */ - (len >= 4 && !strcmpi(spot - 2, "ato")) + || (len >= 4 && !strcmpi(spot - 2, "ato")) || (len >= 5 && !strcmpi(spot - 4, "dingo"))) { Strcasecpy(spot + 1, "es"); /* append es */ goto bottom; @@ -3090,7 +3088,7 @@ wiztrap: (trap != MAGIC_PORTAL) ? "" : " to nowhere"); } else pline("Creation of %s failed.", an(tname)); - return (&zeroobj); + return &zeroobj; } /* furniture and terrain */ @@ -3103,13 +3101,13 @@ wiztrap: lev->blessedftn = 1; pline("A %sfountain.", lev->blessedftn ? "magic " : ""); newsym(x, y); - return (&zeroobj); + return &zeroobj; } if (!BSTRCMPI(bp, p - 6, "throne")) { lev->typ = THRONE; pline("A throne."); newsym(x, y); - return (&zeroobj); + return &zeroobj; } if (!BSTRCMPI(bp, p - 4, "sink")) { lev->typ = SINK; @@ -3155,7 +3153,7 @@ wiztrap: lev->altarmask = Align2amask(al); pline("%s altar.", An(align_str(al))); newsym(x, y); - return (&zeroobj); + return &zeroobj; } if (!BSTRCMPI(bp, p - 5, "grave") @@ -3164,7 +3162,7 @@ wiztrap: pline("%s.", IS_GRAVE(lev->typ) ? "A grave" : "Can't place a grave here"); newsym(x, y); - return (&zeroobj); + return &zeroobj; } if (!BSTRCMPI(bp, p - 4, "tree")) { @@ -3223,7 +3221,7 @@ typfnd: default: /* catch any other non-wishable objects (venom) */ if (objects[typ].oc_nowish) - return ((struct obj *) 0); + return (struct obj *) 0; break; } } @@ -3477,7 +3475,7 @@ typfnd: if (very && otmp->otyp == HEAVY_IRON_BALL) otmp->owt += 160; - return (otmp); + return otmp; } int @@ -3487,7 +3485,7 @@ int first, last; int i, x, sum = 0; if (first == last) - return (first); + return first; for (i = first; i <= last; i++) sum += objects[i].oc_prob; if (!sum) /* all zero */ diff --git a/src/options.c b/src/options.c index ba9e62141..a16b0d220 100644 --- a/src/options.c +++ b/src/options.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 options.c $NHDT-Date: 1435002680 2015/06/22 19:51:20 $ $NHDT-Branch: master $:$NHDT-Revision: 1.222 $ */ +/* NetHack 3.6 options.c $NHDT-Date: 1445556879 2015/10/22 23:34:39 $ $NHDT-Branch: master $:$NHDT-Revision: 1.227 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -556,7 +556,8 @@ boolean val_allowed; int len = (int) strlen(user_string); if (val_allowed) { - const char *p = index(user_string, ':'), *q = index(user_string, '='); + const char *p = index(user_string, ':'), + *q = index(user_string, '='); if (!p || (q && q < p)) p = q; @@ -566,7 +567,8 @@ boolean val_allowed; len = (int) (p - user_string); } - return (len >= min_length) && !strncmpi(opt_name, user_string, len); + return (boolean) (len >= min_length + && !strncmpi(opt_name, user_string, len)); } /* most environment variables will eventually be printed in an error @@ -2896,8 +2898,9 @@ boolean tinitial, tfrom_file; /* WINCAP * - map_mode:[tiles|ascii4x6|ascii6x8|ascii8x8|ascii16x8|ascii7x12|ascii8x12| - ascii16x12|ascii12x16|ascii10x18|fit_to_screen] */ + * map_mode:[tiles|ascii4x6|ascii6x8|ascii8x8|ascii16x8|ascii7x12| + * ascii8x12|ascii16x12|ascii12x16|ascii10x18|fit_to_screen] + */ fullname = "map_mode"; if (match_optname(opts, fullname, sizeof("map_mode") - 1, TRUE)) { if (duplicate) @@ -3727,7 +3730,7 @@ int numtotal; add_menu(tmpwin, NO_GLYPH, &any, action_titles[i].letr, 0, ATR_NONE, tmpbuf, #if 0 /* this ought to work but doesn't... */ - (action_titles[i].letr == 'x') ? MENU_SELECTED : + (action_titles[i].letr == 'x') ? MENU_SELECTED : #endif MENU_UNSELECTED); } @@ -5335,7 +5338,7 @@ struct wc_Opt wc_options[] = { { "ascii_map", WC_ASCII_MAP }, { "font_menu", WC_FONT_MENU }, { "font_message", WC_FONT_MESSAGE }, #if 0 - {"perm_invent",WC_PERM_INVENT}, + {"perm_invent", WC_PERM_INVENT}, #endif { "font_size_map", WC_FONTSIZ_MAP }, { "font_size_menu", WC_FONTSIZ_MENU }, diff --git a/src/pager.c b/src/pager.c index 94ffcd18a..6cc8b3e76 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 pager.c $NHDT-Date: 1436754893 2015/07/13 02:34:53 $ $NHDT-Branch: master $:$NHDT-Revision: 1.79 $ */ +/* NetHack 3.6 pager.c $NHDT-Date: 1445556880 2015/10/22 23:34:40 $ $NHDT-Branch: master $:$NHDT-Revision: 1.82 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1094,17 +1094,19 @@ doidtrap() break; } tt = what_trap(tt); - pline( - "That is %s%s%s.", - an(defsyms[trap_to_defsym(tt)].explanation), - !trap->madeby_u - ? "" - : (tt == WEB) ? " woven" : - /* trap doors & spiked pits can't be made by - player, and should be considered at least - as much "set" as "dug" anyway */ - (tt == HOLE || tt == PIT) ? " dug" : " set", - !trap->madeby_u ? "" : " by you"); + pline("That is %s%s%s.", + an(defsyms[trap_to_defsym(tt)].explanation), + !trap->madeby_u + ? "" + : (tt == WEB) + ? " woven" + /* trap doors & spiked pits can't be made by + player, and should be considered at least + as much "set" as "dug" anyway */ + : (tt == HOLE || tt == PIT) + ? " dug" + : " set", + !trap->madeby_u ? "" : " by you"); return 0; } pline("I can't see a trap there."); diff --git a/src/pickup.c b/src/pickup.c index 839106c43..058ec3a05 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 pickup.c $NHDT-Date: 1437877182 2015/07/26 02:19:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.160 $ */ +/* NetHack 3.6 pickup.c $NHDT-Date: 1445556881 2015/10/22 23:34:41 $ $NHDT-Branch: master $:$NHDT-Revision: 1.162 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -314,7 +314,7 @@ struct obj *obj; { if (obj == uchain) return FALSE; - return (obj->quan >= val_for_n_or_more); + return (boolean) (obj->quan >= val_for_n_or_more); } /* list of valid menu classes for query_objlist() and allow_category callback @@ -357,7 +357,7 @@ STATIC_OVL boolean all_but_uchain(obj) struct obj *obj; { - return (obj != uchain); + return (boolean) (obj != uchain); } /* query_objlist callback: return TRUE */ @@ -423,9 +423,9 @@ STATIC_OVL boolean allow_cat_no_uchain(obj) struct obj *obj; { - if ((obj != uchain) && - (((index(valid_menu_classes,'u') != (char *)0) && obj->unpaid) || - (index(valid_menu_classes, obj->oclass) != (char *)0))) + if (obj != uchain + && ((index(valid_menu_classes,'u') && obj->unpaid) + || index(valid_menu_classes, obj->oclass))) return TRUE; else return FALSE; @@ -483,7 +483,7 @@ int what; /* should be a long */ || (is_pool(u.ux, u.uy) && !Underwater) || is_lava(u.ux, u.uy))) { read_engr_at(u.ux, u.uy); - return (0); + return 0; } /* no pickup if levitating & not on air or water level */ @@ -491,7 +491,7 @@ int what; /* should be a long */ if ((multi && !context.run) || (autopickup && !flags.pickup) || (ttmp && uteetering_at_seen_pit(ttmp))) read_engr_at(u.ux, u.uy); - return (0); + return 0; } /* multi && !context.run means they are in the middle of some other * action, or possibly paralyzed, sleeping, etc.... and they just @@ -499,14 +499,14 @@ int what; /* should be a long */ */ if ((multi && !context.run) || (autopickup && !flags.pickup)) { check_here(FALSE); - return (0); + return 0; } if (notake(youmonst.data)) { if (!autopickup) You("are physically incapable of picking anything up."); else check_here(FALSE); - return (0); + return 0; } /* if there's anything here, stop running */ @@ -598,7 +598,7 @@ int what; /* should be a long */ "pick up", objchain, traverse_how == BY_NEXTHERE, &via_menu)) { if (!via_menu) - return (0); + return 0; n = query_objlist( "Pick up what?", objchain, traverse_how | (selective ? 0 : INVORDER_SORT), @@ -1298,10 +1298,10 @@ boolean telekinesis; carry_count(obj, container, *cnt_p, telekinesis, &old_wt, &new_wt); if (*cnt_p < 1L) { result = -1; /* nothing lifted */ - } else if (obj->oclass != COIN_CLASS && + } else if (obj->oclass != COIN_CLASS /* [exception for gold coins will have to change if silver/copper ones ever get implemented] */ - inv_cnt(FALSE) >= 52 && !merge_choice(invent, obj)) { + && inv_cnt(FALSE) >= 52 && !merge_choice(invent, obj)) { Your("knapsack cannot accommodate any more items."); result = -1; /* nothing lifted */ } else { @@ -1498,7 +1498,7 @@ encumber_msg() } oldcap = newcap; - return (newcap); + return newcap; } /* Is there a container at x,y. Optional: return count of containers at x,y */ @@ -1681,7 +1681,7 @@ lootcont: cobj, doname, ansimpleoname, "a container")); if (c == 'q') - return (timepassed); + return timepassed; if (c == 'n') continue; anyfound = TRUE; @@ -1750,7 +1750,7 @@ lootcont: You("%s %s to loot.", dont_find_anything, underfoot ? "here" : "there"); } - return (timepassed); + return timepassed; } /* called when attempting to #loot while confused */ @@ -1854,15 +1854,14 @@ boolean *prev_loot; if ((c = yn_function(qbuf, ynqchars, 'n')) == 'y') { if (nolimbs(youmonst.data)) { You_cant("do that without limbs."); /* not body_part(HAND) */ - return (0); + return 0; } if (otmp->cursed) { - You("can't. The saddle seems to be stuck to %s.", + You("can't. The saddle seems to be stuck to %s.", x_monnam(mtmp, ARTICLE_THE, (char *) 0, SUPPRESS_SADDLE, FALSE)); - /* the attempt costs you time */ - return (1); + return 1; } obj_extract_self(otmp); if ((unwornmask = otmp->owornmask) != 0L) { @@ -1876,7 +1875,7 @@ boolean *prev_loot; if (prev_loot) *prev_loot = TRUE; } else if (c == 'q') { - return (0); + return 0; } } /* 3.4.0 introduced the ability to pick things up from within swallower's diff --git a/src/potion.c b/src/potion.c index 6bc3e1e78..cf824b25a 100644 --- a/src/potion.c +++ b/src/potion.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 potion.c $NHDT-Date: 1440120657 2015/08/21 01:30:57 $ $NHDT-Branch: master $:$NHDT-Revision: 1.117 $ */ +/* NetHack 3.6 potion.c $NHDT-Date: 1445556882 2015/10/22 23:34:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.119 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -453,18 +453,18 @@ dodrink() return 0; } /* Is there a fountain to drink from here? */ - if (IS_FOUNTAIN(levl[u.ux][u.uy].typ) && + if (IS_FOUNTAIN(levl[u.ux][u.uy].typ) /* not as low as floor level but similar restrictions apply */ - can_reach_floor(FALSE)) { + && can_reach_floor(FALSE)) { if (yn("Drink from the fountain?") == 'y') { drinkfountain(); return 1; } } /* Or a kitchen sink? */ - if (IS_SINK(levl[u.ux][u.uy].typ) && + if (IS_SINK(levl[u.ux][u.uy].typ) /* not as low as floor level but similar restrictions apply */ - can_reach_floor(FALSE)) { + && can_reach_floor(FALSE)) { if (yn("Drink from the sink?") == 'y') { drinksink(); return 1; @@ -481,7 +481,7 @@ dodrink() otmp = getobj(beverages, "drink"); if (!otmp) - return (0); + return 0; /* quan > 1 used to be left to useup(), but we need to force the current potion to be unworn, and don't want to do @@ -506,13 +506,13 @@ dodrink() && !rn2(POTION_OCCUPANT_CHANCE(mvitals[PM_GHOST].born))) { ghost_from_bottle(); useup(otmp); - return (1); + return 1; } else if (!strcmp(potion_descr, "smoky") && !(mvitals[PM_DJINNI].mvflags & G_GONE) && !rn2(POTION_OCCUPANT_CHANCE(mvitals[PM_DJINNI].born))) { djinni_from_bottle(otmp); useup(otmp); - return (1); + return 1; } } return dopotion(otmp); @@ -527,7 +527,7 @@ register struct obj *otmp; otmp->in_use = TRUE; nothing = unkn = 0; if ((retval = peffects(otmp)) >= 0) - return (retval); + return retval; if (nothing) { unkn++; @@ -542,7 +542,7 @@ register struct obj *otmp; docall(otmp); } useup(otmp); - return (1); + return 1; } int @@ -792,13 +792,13 @@ register struct obj *otmp; break; } if (monster_detect(otmp, 0)) - return (1); /* nothing detected */ + return 1; /* nothing detected */ exercise(A_WIS, TRUE); break; case POT_OBJECT_DETECTION: case SPE_DETECT_TREASURE: if (object_detect(otmp, 0)) - return (1); /* nothing detected */ + return 1; /* nothing detected */ exercise(A_WIS, TRUE); break; case POT_SICKNESS: @@ -1063,9 +1063,9 @@ register struct obj *otmp; break; default: impossible("What a funny potion! (%u)", otmp->otyp); - return (0); + return 0; } - return (-1); + return -1; } void @@ -1438,14 +1438,14 @@ boolean your_fault; case POT_POLYMORPH: (void) bhitm(mon, obj); break; - /* - case POT_GAIN_LEVEL: - case POT_LEVITATION: - case POT_FRUIT_JUICE: - case POT_MONSTER_DETECTION: - case POT_OBJECT_DETECTION: - break; - */ + /* + case POT_GAIN_LEVEL: + case POT_LEVITATION: + case POT_FRUIT_JUICE: + case POT_MONSTER_DETECTION: + case POT_OBJECT_DETECTION: + break; + */ } if (angermon) wakeup(mon); @@ -1743,7 +1743,7 @@ dodip() allowall[0] = ALL_CLASSES; allowall[1] = '\0'; if (!(obj = getobj(allowall, "dip"))) - return (0); + return 0; if (inaccessible_equipment(obj, "dip", FALSE)) return 0; @@ -1755,7 +1755,7 @@ dodip() Sprintf(qtoo, "%s the fountain?", qbuf); if (yn(upstart(qtoo)) == 'y') { dipfountain(obj); - return (1); + return 1; } } else if (is_pool(u.ux, u.uy)) { const char *pooltype = waterbody_name(u.ux, u.uy); @@ -1831,7 +1831,7 @@ dodip() } } potion->in_use = FALSE; /* didn't go poof */ - return (1); + return 1; } else if (obj->oclass == POTION_CLASS && obj->otyp != potion->otyp) { long amt = obj->quan; @@ -1893,7 +1893,8 @@ dodip() obj->otyp = otmp->otyp; obfree(otmp, (struct obj *) 0); - } break; + break; + } default: useupall(obj); useup(potion); @@ -1930,7 +1931,7 @@ dodip() otense(obj, "turn"), potion->odiluted ? hcolor(NH_ORANGE) : hcolor(NH_RED)); potion->in_use = FALSE; /* didn't go poof */ - return (1); + return 1; } if (potion->otyp == POT_WATER && obj->otyp == TOWEL) { @@ -2088,11 +2089,11 @@ more_dips: hold_another_object(singlepotion, "You juggle and drop %s!", doname(singlepotion), (const char *) 0); update_inventory(); - return (1); + return 1; } pline("Interesting..."); - return (1); + return 1; poof: if (!objects[potion->otyp].oc_name_known diff --git a/src/pray.c b/src/pray.c index 608aac2c5..aa7893b2f 100644 --- a/src/pray.c +++ b/src/pray.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 pray.c $NHDT-Date: 1432512763 2015/05/25 00:12:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.81 $ */ +/* NetHack 3.6 pray.c $NHDT-Date: 1445556883 2015/10/22 23:34:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.85 $ */ /* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */ /* NetHack may be freely redistributed. See license for details. */ @@ -151,7 +151,7 @@ boolean only_if_injured; /* determines whether maxhp <= 5 matters */ break; /* explvl 30+ */ } /* 5 is a magic number in TROUBLE_HIT handling below */ - return (curhp <= 5 || curhp * divisor <= maxhp); + return (boolean) (curhp <= 5 || curhp * divisor <= maxhp); } STATIC_OVL int @@ -164,25 +164,25 @@ in_trouble() * major troubles */ if (Stoned) - return (TROUBLE_STONED); + return TROUBLE_STONED; if (Slimed) - return (TROUBLE_SLIMED); + return TROUBLE_SLIMED; if (Strangled) - return (TROUBLE_STRANGLED); + return TROUBLE_STRANGLED; if (u.utrap && u.utraptype == TT_LAVA) - return (TROUBLE_LAVA); + return TROUBLE_LAVA; if (Sick) - return (TROUBLE_SICK); + return TROUBLE_SICK; if (u.uhs >= WEAK) - return (TROUBLE_STARVING); + return TROUBLE_STARVING; if (region_danger()) return TROUBLE_REGION; if (critically_low_hp(FALSE)) return TROUBLE_HIT; if (u.ulycn >= LOW_PM) - return (TROUBLE_LYCANTHROPE); + return TROUBLE_LYCANTHROPE; if (near_capacity() >= EXT_ENCUMBER && AMAX(A_STR) - ABASE(A_STR) > 3) - return (TROUBLE_COLLAPSING); + return TROUBLE_COLLAPSING; for (i = -1; i <= 1; i++) for (j = -1; j <= 1; j++) { @@ -194,12 +194,12 @@ in_trouble() count++; } if (count == 8 && !Passes_walls) - return (TROUBLE_STUCK_IN_WALL); + return TROUBLE_STUCK_IN_WALL; if (Cursed_obj(uarmf, LEVITATION_BOOTS) || stuck_ring(uleft, RIN_LEVITATION) || stuck_ring(uright, RIN_LEVITATION)) - return (TROUBLE_CURSED_LEVITATION); + return TROUBLE_CURSED_LEVITATION; if (nohands(youmonst.data) || !freehand()) { /* for bag/box access [cf use_container()]... make sure it's a case that we know how to handle; @@ -211,13 +211,13 @@ in_trouble() return TROUBLE_UNUSEABLE_HANDS; } if (Blindfolded && ublindf->cursed) - return (TROUBLE_CURSED_BLINDFOLD); + return TROUBLE_CURSED_BLINDFOLD; /* * minor troubles */ if (Punished || (u.utrap && u.utraptype == TT_BURIEDBALL)) - return (TROUBLE_PUNISHED); + return TROUBLE_PUNISHED; if (Cursed_obj(uarmg, GAUNTLETS_OF_FUMBLING) || Cursed_obj(uarmf, FUMBLE_BOOTS)) return TROUBLE_FUMBLING; @@ -232,12 +232,12 @@ in_trouble() if (Blinded > 1 && haseyes(youmonst.data) && (!u.uswallow || !attacktype_fordmg(u.ustuck->data, AT_ENGL, AD_BLND))) - return (TROUBLE_BLIND); + return TROUBLE_BLIND; for (i = 0; i < A_MAX; i++) if (ABASE(i) < AMAX(i)) - return (TROUBLE_POISONED); + return TROUBLE_POISONED; if (Wounded_legs && !u.usteed) - return (TROUBLE_WOUNDED_LEGS); + return TROUBLE_WOUNDED_LEGS; if (u.uhs >= HUNGRY) return TROUBLE_HUNGRY; if (HStun & TIMEOUT) @@ -246,7 +246,7 @@ in_trouble() return TROUBLE_CONFUSED; if (HHallucination & TIMEOUT) return TROUBLE_HALLUCINATION; - return (0); + return 0; } /* select an item for TROUBLE_CURSED_ITEMS */ @@ -1184,7 +1184,7 @@ boolean bless_water; ((other || changed > 1L) ? "s" : ""), (changed > 1L ? "" : "s"), (bless_water ? hcolor(NH_LIGHT_BLUE) : hcolor(NH_BLACK))); } - return ((boolean)(changed > 0L)); + return (boolean) (changed > 0L); } STATIC_OVL void @@ -1375,7 +1375,7 @@ dosacrifice() useup(otmp); else useupf(otmp, 1L); - return (1); + return 1; } else if (has_omonst(otmp) && ((mtmp = get_mtraits(otmp, FALSE)) != (struct monst *) 0) && mtmp->mtame) { @@ -1430,13 +1430,13 @@ dosacrifice() gods_upset(A_NONE); else You_feel("%s.", - Hallucination ? "homesick" : - /* headed towards celestial disgrace */ - (altaralign != u.ualign.type) - ? "ashamed" - : - /* on track; give a big hint */ - "an urge to return to the surface"); + Hallucination + ? "homesick" + /* if on track, give a big hint */ + : (altaralign == u.ualign.type) + ? "an urge to return to the surface" + /* else headed towards celestial disgrace */ + : "ashamed"); return 1; } else { /* The final Test. Did you win? */ @@ -1514,7 +1514,7 @@ dosacrifice() if (value == 0) { pline1(nothing_happens); - return (1); + return 1; } if (altaralign != u.ualign.type && highaltar) { @@ -1563,7 +1563,7 @@ dosacrifice() if (!Inhell) angrygods(u.ualign.type); } - return (1); + return 1; } else { consume_offering(otmp); You("sense a conflict between %s and %s.", u_gname(), @@ -1603,7 +1603,7 @@ dosacrifice() && rnd(u.ualign.record) > (7 * ALIGNLIM) / 8) summon_minion(altaralign, TRUE); } - return (1); + return 1; } } @@ -1692,7 +1692,7 @@ dosacrifice() makeknown(otmp->otyp); discover_artifact(otmp->oartifact); } - return (1); + return 1; } } change_luck((value * LUCKMAX) / (MAXVALUE * 2)); @@ -1711,7 +1711,7 @@ dosacrifice() } } } - return (1); + return 1; } /* determine prayer results in advance; also used for enlightenment */ @@ -1801,7 +1801,7 @@ dopray() u.uinvulnerable = TRUE; } - return (1); + return 1; } STATIC_PTR int prayer_done() /* M. Stephenson (1.0.3b) */ @@ -1819,7 +1819,7 @@ STATIC_PTR int prayer_done() /* M. Stephenson (1.0.3b) */ /* no Half_physical_damage adjustment here */ losehp(rnd(20), "residual undead turning effect", KILLED_BY_AN); exercise(A_CON, FALSE); - return (1); + return 1; } if (Inhell) { pline("Since you are in Gehennom, %s won't help you.", @@ -1827,7 +1827,7 @@ STATIC_PTR int prayer_done() /* M. Stephenson (1.0.3b) */ /* haltingly aligned is least likely to anger */ if (u.ualign.record <= 0 || rnl(u.ualign.record)) angrygods(u.ualign.type); - return (0); + return 0; } if (p_type == 0) { @@ -1854,7 +1854,7 @@ STATIC_PTR int prayer_done() /* M. Stephenson (1.0.3b) */ (void) water_prayer(TRUE); pleased(alignment); /* nice */ } - return (1); + return 1; } int @@ -1879,7 +1879,7 @@ doturn() } You("don't know how to turn undead!"); - return (0); + return 0; } u.uconduct.gnostic++; @@ -1889,13 +1889,13 @@ doturn() pline("For some reason, %s seems to ignore you.", u_gname()); aggravate(); exercise(A_WIS, FALSE); - return (0); + return 0; } if (Inhell) { pline("Since you are in Gehennom, %s won't help you.", u_gname()); aggravate(); - return (0); + return 0; } pline("Calling upon %s, you chant an arcane formula.", u_gname()); exercise(A_WIS, TRUE); @@ -1958,20 +1958,20 @@ doturn() nomul(-5); multi_reason = "trying to turn the monsters"; nomovemsg = You_can_move_again; - return (1); + return 1; } const char * a_gname() { - return (a_gname_at(u.ux, u.uy)); + return a_gname_at(u.ux, u.uy); } const char *a_gname_at(x, y) /* returns the name of an altar's deity */ xchar x, y; { if (!IS_ALTAR(levl[x][y].typ)) - return ((char *) 0); + return (char *) 0; return align_gname(a_align(x, y)); } diff --git a/src/priest.c b/src/priest.c index 098186483..b1a81e367 100644 --- a/src/priest.c +++ b/src/priest.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 priest.c $NHDT-Date: 1432512764 2015/05/25 00:12:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.37 $ */ +/* NetHack 3.6 priest.c $NHDT-Date: 1445556883 2015/10/22 23:34:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.40 $ */ /* Copyright (c) Izchak Miller, Steve Linhart, 1989. */ /* NetHack may be freely redistributed. See license for details. */ @@ -56,7 +56,7 @@ register xchar omx, omy, gx, gy; struct obj *ib = (struct obj *) 0; if (omx == gx && omy == gy) - return (0); + return 0; if (mtmp->mconf) { avoid = FALSE; appr = 0; @@ -128,9 +128,9 @@ pick_move: obj_extract_self(ib); (void) mpickobj(mtmp, ib); } - return (1); + return 1; } - return (0); + return 0; } char @@ -141,8 +141,8 @@ register char *array; for (ptr = array; *ptr; ptr++) if (rooms[*ptr - ROOMOFFSET].rtype == TEMPLE) - return (*ptr); - return ('\0'); + return *ptr; + return '\0'; } STATIC_OVL boolean @@ -150,9 +150,9 @@ histemple_at(priest, x, y) register struct monst *priest; register xchar x, y; { - return ((boolean)(priest && priest->ispriest + return (boolean) (priest && priest->ispriest && (EPRI(priest)->shroom == *in_rooms(x, y, TEMPLE)) - && on_level(&(EPRI(priest)->shrlevel), &u.uz))); + && on_level(&(EPRI(priest)->shrlevel), &u.uz)); } boolean @@ -184,7 +184,7 @@ register struct monst *priest; omy = priest->my; if (!histemple_at(priest, omx, omy)) - return (-1); + return -1; temple = EPRI(priest)->shroom; @@ -200,7 +200,7 @@ register struct monst *priest; if (Displaced) Your("displaced image doesn't fool %s!", mon_nam(priest)); (void) mattacku(priest); - return (0); + return 0; } else if (index(u.urooms, temple)) { /* chase player if inside temple & can see him */ if (priest->mcansee && m_canseeu(priest)) { @@ -212,8 +212,7 @@ register struct monst *priest; } else if (Invis) avoid = FALSE; - return ( - move_special(priest, FALSE, TRUE, FALSE, avoid, omx, omy, gx, gy)); + return move_special(priest, FALSE, TRUE, FALSE, avoid, omx, omy, gx, gy); } /* exclusively for mktemple() */ @@ -343,7 +342,7 @@ boolean p_coaligned(priest) struct monst *priest; { - return ((boolean)(u.ualign.type == mon_aligntyp(priest))); + return (boolean) (u.ualign.type == mon_aligntyp(priest)); } STATIC_OVL boolean @@ -359,8 +358,8 @@ struct monst *pri; lev = &levl[epri_p->shrpos.x][epri_p->shrpos.y]; if (!IS_ALTAR(lev->typ) || !(lev->altarmask & AM_SHRINE)) return FALSE; - return (boolean)(epri_p->shralign - == (Amask2align(lev->altarmask & ~AM_SHRINE))); + return (boolean) (epri_p->shralign + == (Amask2align(lev->altarmask & ~AM_SHRINE))); } struct monst * @@ -374,7 +373,7 @@ char roomno; continue; if (mtmp->ispriest && (EPRI(mtmp)->shroom == roomno) && histemple_at(mtmp, mtmp->mx, mtmp->my)) - return (mtmp); + return mtmp; } return (struct monst *) 0; } @@ -609,14 +608,14 @@ register struct monst *priest; verbalize("I bestow upon thee a blessing."); incr_itimeout(&HClairvoyant, rn1(500, 500)); } - } else if (offer < (u.ulevel * 600) && + } else if (offer < (u.ulevel * 600) /* u.ublessed is only active when Protection is enabled via something other than worn gear (theft by gremlin clears the intrinsic but not its former magnitude, making it recoverable) */ - (!(HProtection & INTRINSIC) - || (u.ublessed < 20 - && (u.ublessed < 9 || !rn2(u.ublessed))))) { + && (!(HProtection & INTRINSIC) + || (u.ublessed < 20 + && (u.ublessed < 9 || !rn2(u.ublessed))))) { verbalize("Thy devotion has been rewarded."); if (!(HProtection & INTRINSIC)) { HProtection |= FROMOUTSIDE; @@ -669,7 +668,7 @@ boolean peaceful; set_malign(roamer); /* peaceful may have changed */ /* MORE TO COME */ - return (roamer); + return roamer; } void @@ -709,8 +708,8 @@ xchar x, y; return FALSE; if ((priest = findpriest(roomno)) == 0) return FALSE; - return (boolean)(has_shrine(priest) && p_coaligned(priest) - && priest->mpeaceful); + return (boolean) (has_shrine(priest) && p_coaligned(priest) + && priest->mpeaceful); } void ghod_hitsu(priest) /* when attacking "priest" in his temple */