From ea8afe7e24addd37351a44e37c0215bd548b79e5 Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 5 Nov 2015 00:54:13 -0800 Subject: [PATCH] formatting - last of the trailing continuations Last few && or || followed by end-of-line comments, plus tab replacement and 'return' parentheses. Not as many of those; some of these files had already had that done. Also, tweaked non-cursed scroll of charging read while confused to be a tiny bit more effective. To do: find and fix block comments that immediately follow a line with an end-of-line comment and got misindented to line up with that comment. --- src/read.c | 46 +++++----- src/rumors.c | 39 ++++----- src/shk.c | 233 +++++++++++++++++++++++++++------------------------ src/sounds.c | 18 ++-- src/sp_lev.c | 29 ++++--- src/steal.c | 20 ++--- src/trap.c | 6 +- src/uhitm.c | 112 +++++++++++++------------ src/zap.c | 72 +++++++++------- 9 files changed, 299 insertions(+), 276 deletions(-) diff --git a/src/read.c b/src/read.c index b652db9a1..89c460736 100644 --- a/src/read.c +++ b/src/read.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 read.c $NHDT-Date: 1444352700 2015/10/09 01:05:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.116 $ */ +/* NetHack 3.6 read.c $NHDT-Date: 1446713638 2015/11/05 08:53:58 $ $NHDT-Branch: master $:$NHDT-Revision: 1.119 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -149,10 +149,10 @@ doread() known = FALSE; if (check_capacity((char *) 0)) - return (0); + return 0; scroll = getobj(readable, "read"); if (!scroll) - return (0); + return 0; /* outrumor has its own blindness check */ if (scroll->otyp == FORTUNE_COOKIE) { @@ -162,7 +162,7 @@ doread() if (!Blind) u.uconduct.literate++; useup(scroll); - return (1); + return 1; } else if (scroll->otyp == T_SHIRT || scroll->otyp == ALCHEMY_SMOCK) { char buf[BUFSZ]; if (Blind) { @@ -267,7 +267,7 @@ doread() } else if (scroll->oclass != SCROLL_CLASS && scroll->oclass != SPBOOK_CLASS) { pline(silly_thing_to, "read"); - return (0); + return 0; } else if (Blind && (scroll->otyp != SPE_BOOK_OF_THE_DEAD)) { const char *what = 0; if (scroll->oclass == SPBOOK_CLASS) @@ -276,7 +276,7 @@ doread() what = "formula on the scroll"; if (what) { pline("Being blind, you cannot read the %s.", what); - return (0); + return 0; } } @@ -307,7 +307,7 @@ doread() u.uconduct.literate++; if (scroll->oclass == SPBOOK_CLASS) { - return (study_book(scroll)); + return study_book(scroll); } scroll->in_use = TRUE; /* scroll, not spellbook, now being read */ if (scroll->otyp != SCR_BLANK_PAPER) { @@ -815,13 +815,13 @@ int percent; /* * Forget some things (e.g. after reading a scroll of amnesia). When called, * the following are always forgotten: - * - felt ball & chain - * - traps - * - part (6 out of 7) of the map + * - felt ball & chain + * - traps + * - part (6 out of 7) of the map * * Other things are subject to flags: - * howmuch & ALL_MAP = forget whole map - * howmuch & ALL_SPELLS = forget all spells + * howmuch & ALL_MAP = forget whole map + * howmuch & ALL_SPELLS = forget all spells */ STATIC_OVL void forget(howmuch) @@ -929,8 +929,8 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */ if (objects[otyp].oc_magic) exercise(A_WIS, TRUE); /* just for trying */ - already_known = (sobj->oclass == SPBOOK_CLASS || /* spell */ - objects[otyp].oc_name_known); + already_known = (sobj->oclass == SPBOOK_CLASS /* spell */ + || objects[otyp].oc_name_known); switch (otyp) { #ifdef MAIL @@ -1402,7 +1402,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */ pline("This is an identify scroll."); if (!already_known) (void) learnscrolltyp(SCR_IDENTIFY); - /*FALLTHRU*/ + /*FALLTHRU*/ case SPE_IDENTIFY: cval = 1; if (sblessed || (!scursed && !rn2(5))) { @@ -1427,10 +1427,9 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */ u.uen = 0; } else { You_feel("charged up!"); - if (u.uen < u.uenmax) - u.uen = u.uenmax; - else - u.uen = (u.uenmax += d(5, 4)); + u.uen += d(sblessed ? 6 : 4, 4); + if (u.uen > u.uenmax) + u.uenmax = u.uen; } context.botl = 1; break; @@ -2024,8 +2023,8 @@ do_class_genocide() || quest_info(MS_GUARDIAN) == i) /* non-leader/nemesis/guardian role-specific monster */ - && (i != PM_NINJA || /* nuisance */ - Role_if(PM_SAMURAI))) { + && (i != PM_NINJA /* nuisance */ + || Role_if(PM_SAMURAI))) { boolean named, uniq; named = type_is_pname(&mons[i]) ? TRUE : FALSE; @@ -2215,7 +2214,7 @@ int how; void punish(sobj) -register struct obj *sobj; +struct obj *sobj; { struct obj *reuse_ball = (sobj && sobj->otyp == HEAVY_IRON_BALL) ? sobj : (struct obj *) 0; @@ -2257,9 +2256,10 @@ register struct obj *sobj; } } +/* remove the ball and chain */ void unpunish() -{ /* remove the ball and chain */ +{ struct obj *savechain = uchain; obj_extract_self(uchain); diff --git a/src/rumors.c b/src/rumors.c index b6452991c..ebf5a532e 100644 --- a/src/rumors.c +++ b/src/rumors.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 rumors.c $NHDT-Date: 1432512762 2015/05/25 00:12:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.26 $ */ +/* NetHack 3.6 rumors.c $NHDT-Date: 1446713640 2015/11/05 08:54:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.27 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -6,7 +6,7 @@ #include "lev.h" #include "dlb.h" -/* [note: this comment is fairly old, but still accurate for 3.1] +/* [note: this comment is fairly old, but still accurate for 3.1] * Rumors have been entirely rewritten to speed up the access. This is * essential when working from floppies. Using fseek() the way that's done * here means rumors following longer rumors are output more often than those @@ -15,7 +15,7 @@ * this also happens with real fortune cookies. -dgk */ -/* 3.5 +/* 3.5 * The rumors file consists of a "do not edit" line, then a line containing * three sets of three counts (first two in decimal, third in hexadecimal). * The first set has the number of true rumors, the count in bytes for all @@ -27,7 +27,7 @@ * plus the size of the false rumors matches the offset for end-of-file. */ -/* 3.1 [now obsolete for rumors but still accurate for oracles] +/* 3.1 [now obsolete for rumors but still accurate for oracles] * The rumors file consists of a "do not edit" line, a hexadecimal number * giving the number of bytes of useful/true rumors, followed by those * true rumors (one per line), followed by the useless/false/misleading/cute @@ -115,9 +115,9 @@ boolean exclude_cookie; } } /* - * input: 1 0 -1 - * rn2 \ +1 2=T 1=T 0=F - * adj./ +0 1=T 0=F -1=F + * input: 1 0 -1 + * rn2 \ +1 2=T 1=T 0=F + * adj./ +0 1=T 0=F -1=F */ switch (adjtruth = truth + rn2(2)) { case 2: /*(might let a bogus input arg sneak thru)*/ @@ -425,8 +425,9 @@ boolean delphi; int oracle_idx; char xbuf[BUFSZ]; - if (oracle_flg < 0 || /* couldn't open ORACLEFILE */ - (oracle_flg > 0 && oracle_cnt == 0)) /* oracles already exhausted */ + /* early return if we couldn't open ORACLEFILE on previous attempt, + or if all the oracularities are already exhausted */ + if (oracle_flg < 0 || (oracle_flg > 0 && oracle_cnt == 0)) return; oracles = dlb_fopen(ORACLEFILE, "r"); @@ -439,8 +440,8 @@ boolean delphi; if (oracle_cnt == 0) return; } - /* oracle_loc[0] is the special oracle; */ - /* oracle_loc[1..oracle_cnt-1] are normal ones */ + /* oracle_loc[0] is the special oracle; + oracle_loc[1..oracle_cnt-1] are normal ones */ if (oracle_cnt <= 1 && !special) return; /*(shouldn't happen)*/ oracle_idx = special ? 0 : rnd((int) oracle_cnt - 1); @@ -450,11 +451,10 @@ boolean delphi; tmpwin = create_nhwindow(NHW_TEXT); if (delphi) - putstr( - tmpwin, 0, - special - ? "The Oracle scornfully takes all your money and says:" - : "The Oracle meditates for a moment and then intones:"); + putstr(tmpwin, 0, + special + ? "The Oracle scornfully takes all your money and says:" + : "The Oracle meditates for a moment and then intones:"); else putstr(tmpwin, 0, "The message reads:"); putstr(tmpwin, 0, ""); @@ -475,7 +475,7 @@ boolean delphi; int doconsult(oracl) -register struct monst *oracl; +struct monst *oracl; { long umoney; int u_pay, minor_cost = 50, major_cost = 500 + 50 * u.ulevel; @@ -510,8 +510,8 @@ register struct monst *oracl; u_pay = minor_cost; break; case 'n': - if (umoney <= (long) minor_cost || /* don't even ask */ - (oracle_cnt == 1 || oracle_flg < 0)) + if (umoney <= (long) minor_cost /* don't even ask */ + || (oracle_cnt == 1 || oracle_flg < 0)) return 0; Sprintf(qbuf, "\"Then dost thou desire a major one?\" (%d %s)", major_cost, currency((long) major_cost)); @@ -531,6 +531,7 @@ register struct monst *oracl; u.uevent.minor_oracle = TRUE; } else { boolean cheapskate = u_pay < major_cost; + outoracle(cheapskate, TRUE); if (!cheapskate && !u.uevent.major_oracle) add_xpts = u_pay / (u.uevent.minor_oracle ? 25 : 10); diff --git a/src/shk.c b/src/shk.c index 64e17e411..a6ed7f076 100644 --- a/src/shk.c +++ b/src/shk.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 shk.c $NHDT-Date: 1445906862 2015/10/27 00:47:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.114 $ */ +/* NetHack 3.6 shk.c $NHDT-Date: 1446713640 2015/11/05 08:54:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.115 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -32,8 +32,8 @@ STATIC_DCL void FDECL(append_honorific, (char *)); STATIC_DCL void FDECL(setpaid, (struct monst *)); STATIC_DCL long FDECL(addupbill, (struct monst *)); STATIC_DCL void FDECL(pacify_shk, (struct monst *)); -STATIC_DCL struct bill_x *FDECL(onbill, - (struct obj *, struct monst *, BOOLEAN_P)); +STATIC_DCL struct bill_x *FDECL(onbill, (struct obj *, struct monst *, + BOOLEAN_P)); STATIC_DCL struct monst *FDECL(next_shkp, (struct monst *, BOOLEAN_P)); STATIC_DCL long FDECL(shop_debt, (struct eshk *)); STATIC_DCL char *FDECL(shk_owns, (char *, struct obj *)); @@ -44,13 +44,13 @@ STATIC_DCL void FDECL(pay, (long, struct monst *)); STATIC_DCL long FDECL(get_cost, (struct obj *, struct monst *)); STATIC_DCL long FDECL(set_cost, (struct obj *, struct monst *)); STATIC_DCL const char *FDECL(shk_embellish, (struct obj *, long)); -STATIC_DCL long FDECL(cost_per_charge, - (struct monst *, struct obj *, BOOLEAN_P)); +STATIC_DCL long FDECL(cost_per_charge, (struct monst *, struct obj *, + BOOLEAN_P)); STATIC_DCL long FDECL(cheapest_item, (struct monst *)); STATIC_DCL int FDECL(dopayobj, (struct monst *, struct bill_x *, struct obj **, int, BOOLEAN_P)); -STATIC_DCL long FDECL(stolen_container, - (struct obj *, struct monst *, long, BOOLEAN_P)); +STATIC_DCL long FDECL(stolen_container, (struct obj *, struct monst *, + long, BOOLEAN_P)); STATIC_DCL long FDECL(getprice, (struct obj *, BOOLEAN_P)); STATIC_DCL void FDECL(shk_names_obj, (struct monst *, struct obj *, const char *, long, const char *)); @@ -62,36 +62,36 @@ STATIC_DCL void FDECL(rile_shk, (struct monst *)); STATIC_DCL void FDECL(rouse_shk, (struct monst *, BOOLEAN_P)); STATIC_DCL void FDECL(remove_damage, (struct monst *, BOOLEAN_P)); STATIC_DCL void FDECL(sub_one_frombill, (struct obj *, struct monst *)); -STATIC_DCL void FDECL(add_one_tobill, - (struct obj *, BOOLEAN_P, struct monst *)); -STATIC_DCL void FDECL(dropped_container, - (struct obj *, struct monst *, BOOLEAN_P)); +STATIC_DCL void FDECL(add_one_tobill, (struct obj *, BOOLEAN_P, + struct monst *)); +STATIC_DCL void FDECL(dropped_container, (struct obj *, struct monst *, + BOOLEAN_P)); STATIC_DCL void FDECL(add_to_billobjs, (struct obj *)); -STATIC_DCL void FDECL(bill_box_content, - (struct obj *, BOOLEAN_P, BOOLEAN_P, struct monst *)); +STATIC_DCL void FDECL(bill_box_content, (struct obj *, BOOLEAN_P, BOOLEAN_P, + struct monst *)); STATIC_DCL boolean FDECL(rob_shop, (struct monst *)); STATIC_DCL void FDECL(deserted_shop, (char *)); -STATIC_DCL boolean -FDECL(special_stock, (struct obj *, struct monst *, BOOLEAN_P)); +STATIC_DCL boolean FDECL(special_stock, (struct obj *, struct monst *, + BOOLEAN_P)); STATIC_DCL const char *FDECL(cad, (BOOLEAN_P)); /* invariants: obj->unpaid iff onbill(obj) [unless bp->useup] - obj->quan <= bp->bquan + obj->quan <= bp->bquan */ /* - Transfer money from inventory to monster when paying - shopkeepers, priests, oracle, succubus, & other demons. - Simple with only gold coins. - This routine will handle money changing when multiple - coin types is implemented, only appropriate - monsters will pay change. (Peaceful shopkeepers, priests - & the oracle try to maintain goodwill while selling - their wares or services. Angry monsters and all demons - will keep anything they get their hands on. - Returns the amount actually paid, so we can know - if the monster kept the change. + * Transfer money from inventory to monster when paying + * shopkeepers, priests, oracle, succubus, and other demons. + * Simple with only gold coins. + * This routine will handle money changing when multiple + * coin types is implemented, only appropriate + * monsters will pay change. (Peaceful shopkeepers, priests + * and the oracle try to maintain goodwill while selling + * their wares or services. Angry monsters and all demons + * will keep anything they get their hands on. + * Returns the amount actually paid, so we can know + * if the monster kept the change. */ long money2mon(mon, amount) @@ -120,9 +120,9 @@ long amount; } /* - Transfer money from monster to inventory. - Used when the shopkeeper pay for items, and when - the priest gives you money for an ale. + * Transfer money from monster to inventory. + * Used when the shopkeeper pay for items, and when + * the priest gives you money for an ale. */ void money2u(mon, amount) @@ -178,7 +178,9 @@ register boolean withbill; return shkp; } -void shkgone(mtmp) /* called in mon.c */ +/* called in mon.c */ +void +shkgone(mtmp) struct monst *mtmp; { struct eshk *eshk = ESHK(mtmp); @@ -660,8 +662,8 @@ same_price(obj1, obj2) struct obj *obj1, *obj2; { register struct monst *shkp1, *shkp2; - register struct bill_x *bp1 = 0, *bp2 = 0; - register boolean are_mergable = FALSE; + struct bill_x *bp1 = 0, *bp2 = 0; + boolean are_mergable = FALSE; /* look up the first object by finding shk whose bill it's on */ for (shkp1 = next_shkp(fmon, TRUE); shkp1; @@ -857,9 +859,9 @@ register struct obj *obj, *merge; shkp = shop_keeper(*u.ushops); /* * Note: `shkp = shop_keeper(*u.ushops)' used to be - * unconditional. But obfree() is used all over - * the place, so making its behavior be dependent - * upon player location doesn't make much sense. + * unconditional. But obfree() is used all over + * the place, so making its behavior be dependent + * upon player location doesn't make much sense. */ if ((bp = onbill(obj, shkp, FALSE)) != 0) { @@ -882,6 +884,7 @@ register struct obj *obj, *merge; { /* DRS/NS 2.2.6 messes up -- Peter Kendell */ int indx = ESHK(shkp)->billct; + *bp = ESHK(shkp)->bill_p[indx]; } #else @@ -1161,8 +1164,9 @@ dopay() multi = 0; - /* find how many shk's there are, how many are in */ - /* sight, and are you in a shop room with one. */ + /* Find how many shk's there are, how many are in + * sight, and are you in a shop room with one. + */ nxtm = resident = 0; for (shkp = next_shkp(fmon, FALSE); shkp; shkp = next_shkp(shkp->nmon, FALSE)) { @@ -1190,8 +1194,9 @@ dopay() return 0; } - /* the usual case. allow paying at a distance when */ - /* inside a tended shop. should we change that? */ + /* The usual case. Allow paying at a distance when + * inside a tended shop. Should we change that? + */ if (sk == 1 && resident) { shkp = resident; goto proceed; @@ -1469,11 +1474,12 @@ proceed: return 1; } -/* return 2 if used-up portion paid */ -/* 1 if paid successfully */ -/* 0 if not enough money */ -/* -1 if skip this object */ -/* -2 if no money/credit left */ +/* return 2 if used-up portion paid + * 1 if paid successfully + * 0 if not enough money + * -1 if skip this object + * -2 if no money/credit left + */ STATIC_OVL int dopayobj(shkp, bp, obj_p, which, itemize) register struct monst *shkp; @@ -1642,8 +1648,10 @@ int croaked; /* -1: escaped dungeon; 0: quit; 1: died */ } /* give highest priority shopkeeper first crack */ - firstshk = resident ? resident : creditor ? creditor : hostile ? hostile - : localshk; + firstshk = resident ? resident + : creditor ? creditor + : hostile ? hostile + : localshk; if (firstshk) { numsk++; taken = inherits(firstshk, numsk, croaked); @@ -1681,8 +1689,8 @@ int croaked; char takes[BUFSZ]; shkp->minvis = 0; - /* the simplifying principle is that first-come */ - /* already took everything you had. */ + /* The simplifying principle is that first-come + already took everything you had. */ if (numsk > 1) { if (cansee(shkp->mx, shkp->my) && croaked) { takes[0] = '\0'; @@ -1801,7 +1809,8 @@ finish_paybill() int ox = repo.location.x, oy = repo.location.y; #if 0 /* don't bother */ - if (ox == 0 && oy == 0) impossible("finish_paybill: no location"); + if (ox == 0 && oy == 0) + impossible("finish_paybill: no location"); #endif /* normally done by savebones(), but that's too late in this case */ unleash_all(); @@ -1868,7 +1877,7 @@ unsigned id; } /* Returns the price of an arbitrary item in the shop. - * Returns 0 if the item doesn't belong to a shopkeeper. */ + Returns 0 if the item doesn't belong to a shopkeeper. */ long get_cost_of_shop_item(obj) register struct obj *obj; @@ -2035,7 +2044,7 @@ boolean unpaid_only; price = contained_cost(otmp, shkp, price, usell, unpaid_only); } - return (price); + return price; } long @@ -2109,9 +2118,9 @@ boolean quietly; verbalize("No thanks, I'd hang onto that if I were you."); if (obj->spe < 7) verbalize( - "You'll need %d%s candle%s to go along with it.", - (7 - obj->spe), (obj->spe > 0) ? " more" : "", - plur(7 - obj->spe)); + "You'll need %d%s candle%s to go along with it.", + (7 - obj->spe), (obj->spe > 0) ? " more" : "", + plur(7 - obj->spe)); /* [what if hero is already carrying enough candles? should Izchak explain how to attach them instead] */ } else { @@ -2561,6 +2570,7 @@ register struct monst *shkp; { /* DRS/NS 2.2.6 messes up -- Peter Kendell */ int indx = ESHK(shkp)->billct; + *bp = ESHK(shkp)->bill_p[indx]; } #else @@ -3454,16 +3464,16 @@ boolean catchup; /* restoring a level */ levl[x][y].doormask = D_CLOSED; /* arbitrary */ newsym(x, y); } else { - /* don't set doormask - it is (hopefully) the same as it was */ - /* if not, perhaps save it with the damage array... */ + /* don't set doormask - it is (hopefully) the same as it was + if not, perhaps save it with the damage array... */ if (IS_WALL(tmp_dam->typ) && cansee(x, y)) { /* Player sees actual repair process, so they KNOW it's a wall */ levl[x][y].seenv = SVALL; newsym(x, y); } - /* Mark this wall as "repaired". There currently is no code */ - /* to do anything about repaired walls, so don't do it. */ + /* Mark this wall as "repaired". There currently is no code + to do anything about repaired walls, so don't do it. */ } for (i = 0; i < 9; i++) if (litter[i] & NEED_UPDATE) @@ -3588,8 +3598,7 @@ register struct monst *shkp; return z; } -/* called after shopkeeper moves, in case the move causes re-entry into shop - */ +/* called after shopkeeper moves, in case themove causes re-entry into shop */ void after_shk_move(shkp) struct monst *shkp; @@ -3654,21 +3663,22 @@ register int fall; You_feel("like a common thief."); adjalign(-sgn(u.ualign.type)); } - } else if (!um_dist(shkp->mx, shkp->my, 5) && !shkp->msleeping - && shkp->mcanmove + } else if (!um_dist(shkp->mx, shkp->my, 5) + && !shkp->msleeping && shkp->mcanmove && (ESHK(shkp)->billct || ESHK(shkp)->debit)) { register struct obj *obj, *obj2; + if (nolimbs(shkp->data)) { grabs = "knocks off"; #if 0 - /* This is what should happen, but for balance - * reasons, it isn't currently. - */ - if (lang == 2) - pline("%s curses %s inability to grab your backpack!", - shkname(shkp), mhim(shkp)); - rile_shk(shkp); - return; + /* This is what should happen, but for balance + * reasons, it isn't currently. + */ + if (lang == 2) + pline("%s curses %s inability to grab your backpack!", + shkname(shkp), mhim(shkp)); + rile_shk(shkp); + return; #endif } if (distu(shkp->mx, shkp->my) > 2) { @@ -3740,8 +3750,8 @@ boolean cant_mollify; register boolean uinshp = (*u.ushops != '\0'); char qbuf[80]; register xchar x, y; - boolean dugwall = !strcmp(dmgstr, "dig into") || /* wand */ - !strcmp(dmgstr, "damage"); /* pick-axe */ + boolean dugwall = (!strcmp(dmgstr, "dig into") /* wand */ + || !strcmp(dmgstr, "damage")); /* pick-axe */ boolean animal, pursue; struct damage *tmp_dam, *appear_here = 0; /* any number >= (80*80)+(24*24) would do, actually */ @@ -4060,43 +4070,45 @@ struct monst *shkp; } eshk = ESHK(shkp); - if (ANGRY(shkp)) - pline("%s mentions how much %s dislikes %s customers.", shkname(shkp), - mhe(shkp), eshk->robbed ? "non-paying" : "rude"); - else if (eshk->following) { + if (ANGRY(shkp)) { + pline("%s mentions how much %s dislikes %s customers.", + shkname(shkp), mhe(shkp), eshk->robbed ? "non-paying" : "rude"); + } else if (eshk->following) { if (strncmp(eshk->customer, plname, PL_NSIZ)) { - verbalize("%s %s! I was looking for %s.", Hello(shkp), plname, - eshk->customer); + verbalize("%s %s! I was looking for %s.", + Hello(shkp), plname, eshk->customer); eshk->following = 0; } else { - verbalize("%s %s! Didn't you forget to pay?", Hello(shkp), - plname); + verbalize("%s %s! Didn't you forget to pay?", + Hello(shkp), plname); } } else if (eshk->billct) { register long total = addupbill(shkp) + eshk->debit; - pline("%s says that your bill comes to %ld %s.", shkname(shkp), total, - currency(total)); - } else if (eshk->debit) - pline("%s reminds you that you owe %s %ld %s.", shkname(shkp), - mhim(shkp), eshk->debit, currency(eshk->debit)); - else if (eshk->credit) + + pline("%s says that your bill comes to %ld %s.", + shkname(shkp), total, currency(total)); + } else if (eshk->debit) { + pline("%s reminds you that you owe %s %ld %s.", + shkname(shkp), mhim(shkp), eshk->debit, currency(eshk->debit)); + } else if (eshk->credit) { pline("%s encourages you to use your %ld %s of credit.", shkname(shkp), eshk->credit, currency(eshk->credit)); - else if (eshk->robbed) + } else if (eshk->robbed) { pline("%s complains about a recent robbery.", shkname(shkp)); - else if ((shkmoney = money_cnt(shkp->minvent)) < 50) + } else if ((shkmoney = money_cnt(shkp->minvent)) < 50) { pline("%s complains that business is bad.", shkname(shkp)); - else if (shkmoney > 4000) + } else if (shkmoney > 4000) { pline("%s says that business is good.", shkname(shkp)); - else if (is_izchak(shkp, FALSE)) + } else if (is_izchak(shkp, FALSE)) { pline(Izchak_speaks[rn2(SIZE(Izchak_speaks))], shkname(shkp)); - else + } else { pline("%s talks about the problem of shoplifters.", shkname(shkp)); + } } STATIC_OVL void kops_gone(silent) -register boolean silent; +boolean silent; { register int cnt = 0; register struct monst *mtmp, *mtmp2; @@ -4110,8 +4122,8 @@ register boolean silent; } } if (cnt && !silent) - pline_The("Kop%s (disappointed) vanish%s into thin air.", plur(cnt), - cnt == 1 ? "es" : ""); + pline_The("Kop%s (disappointed) vanish%s into thin air.", + plur(cnt), (cnt == 1) ? "es" : ""); } STATIC_OVL long @@ -4126,9 +4138,9 @@ boolean altusage; /* some items have an "alternate" use with different cost */ return 0L; /* insurance */ tmp = get_cost(otmp, shkp); - /* The idea is to make the exhaustive use of */ - /* an unpaid item more expensive than buying */ - /* it outright. */ + /* The idea is to make the exhaustive use of an unpaid item + * more expensive than buying it outright. + */ if (otmp->otyp == MAGIC_LAMP) { /* 1 */ /* normal use (ie, as light source) of a magic lamp never degrades its value, but not charging anything would make @@ -4140,22 +4152,21 @@ boolean altusage; /* some items have an "alternate" use with different cost */ else tmp += tmp / 3L; /* djinni is being released */ } else if (otmp->otyp == MAGIC_MARKER) { /* 70 - 100 */ - /* no way to determine in advance */ - /* how many charges will be wasted. */ - /* so, arbitrarily, one half of the */ - /* price per use. */ + /* No way to determine in advance how many charges will be + * wasted. So, arbitrarily, one half of the price per use. + */ tmp /= 2L; - } else if (otmp->otyp == BAG_OF_TRICKS || /* 1 - 20 */ - otmp->otyp == HORN_OF_PLENTY) { + } else if (otmp->otyp == BAG_OF_TRICKS /* 1 - 20 */ + || otmp->otyp == HORN_OF_PLENTY) { /* altusage: emptying of all the contents at once */ if (!altusage) tmp /= 5L; - } else if (otmp->otyp == CRYSTAL_BALL || /* 1 - 5 */ - otmp->otyp == OIL_LAMP || /* 1 - 10 */ - otmp->otyp == BRASS_LANTERN + } else if (otmp->otyp == CRYSTAL_BALL /* 1 - 5 */ + || otmp->otyp == OIL_LAMP /* 1 - 10 */ + || otmp->otyp == BRASS_LANTERN || (otmp->otyp >= MAGIC_FLUTE - && otmp->otyp <= DRUM_OF_EARTHQUAKE) || /* 5 - 9 */ - otmp->oclass == WAND_CLASS) { /* 3 - 11 */ + && otmp->otyp <= DRUM_OF_EARTHQUAKE) /* 5 - 9 */ + || otmp->oclass == WAND_CLASS) { /* 3 - 11 */ if (otmp->spe > 1) tmp /= 4L; } else if (otmp->oclass == SPBOOK_CLASS) { @@ -4300,8 +4311,8 @@ register xchar x, y; return FALSE; } -/* used in domove to block diagonal shop-entry */ -/* u.ux, u.uy should always be a door */ +/* used in domove to block diagonal shop-entry; + u.ux, u.uy should always be a door */ boolean block_entry(x, y) register xchar x, y; diff --git a/src/sounds.c b/src/sounds.c index 5c0107f50..f08fe9d20 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1,5 +1,5 @@ -/* NetHack 3.6 sounds.c $NHDT-Date: 1445906863 2015/10/27 00:47:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.72 $ */ -/* Copyright (c) 1989 Janet Walz, Mike Threepoint */ +/* NetHack 3.6 sounds.c $NHDT-Date: 1446713641 2015/11/05 08:54:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.74 $ */ +/* Copyright (c) 1989 Janet Walz, Mike Threepoint */ /* NetHack may be freely redistributed. See license for details. */ #include "hack.h" @@ -183,8 +183,8 @@ dosounds() continue; if (is_mercenary(mtmp->data) #if 0 /* don't bother excluding these */ - && !strstri(mtmp->data->mname, "watch") - && !strstri(mtmp->data->mname, "guard") + && !strstri(mtmp->data->mname, "watch") + && !strstri(mtmp->data->mname, "guard") #endif && mon_in_room(mtmp, BARRACKS) /* sleeping implies not-yet-disturbed (usually) */ @@ -511,9 +511,9 @@ register struct monst *mtmp; else if (msound == MS_GUARDIAN && ptr != &mons[urole.guardnum]) msound = mons[genus(monsndx(ptr), 1)].msound; /* some normally non-speaking types can/will speak if hero is similar */ - else if (msound == MS_ORC && /* note: MS_ORC is same as MS_GRUNT */ - (same_race(ptr, youmonst.data) || /* current form, */ - same_race(ptr, &mons[Race_switch]))) /* unpoly'd form */ + else if (msound == MS_ORC /* note: MS_ORC is same as MS_GRUNT */ + && (same_race(ptr, youmonst.data) /* current form, */ + || same_race(ptr, &mons[Race_switch]))) /* unpoly'd form */ msound = MS_HUMANOID; /* silliness, with slight chance to interfere with shopping */ else if (Hallucination && mon_is_gecko(mtmp)) @@ -742,8 +742,8 @@ register struct monst *mtmp; if (ptr != &mons[PM_PRISONER]) verbl_msg = "This will teach you not to disturb me!"; #if 0 - else - verbl_msg = "??????????"; + else + verbl_msg = "??????????"; #endif } break; diff --git a/src/sp_lev.c b/src/sp_lev.c index 01b0dd4c8..c19371a2c 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -1,5 +1,5 @@ -/* NetHack 3.6 sp_lev.c $NHDT-Date: 1445906864 2015/10/27 00:47:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.63 $ */ -/* Copyright (c) 1989 by Jean-Christophe Collet */ +/* NetHack 3.6 sp_lev.c $NHDT-Date: 1446713642 2015/11/05 08:54:02 $ $NHDT-Branch: master $:$NHDT-Revision: 1.66 $ */ +/* Copyright (c) 1989 by Jean-Christophe Collet */ /* NetHack may be freely redistributed. See license for details. */ /* @@ -235,7 +235,7 @@ struct splevstack *st; if (st) { int i; - if (st->stackdata && st->depth) + if (st->stackdata && st->depth) { for (i = 0; i < st->depth; i++) { switch (st->stackdata[i]->spovartyp) { default: @@ -250,15 +250,14 @@ struct splevstack *st; case SPOVAR_VARIABLE: case SPOVAR_STRING: case SPOVAR_SEL: - if (st->stackdata[i]->vardata.str) - Free(st->stackdata[i]->vardata.str); + Free(st->stackdata[i]->vardata.str); st->stackdata[i]->vardata.str = NULL; break; } Free(st->stackdata[i]); st->stackdata[i] = NULL; } - + } Free(st->stackdata); st->stackdata = NULL; st->depth = st->depth_alloc = 0; @@ -779,9 +778,9 @@ rndtrap() /* * Coordinates in special level files are handled specially: * - * if x or y is < 0, we generate a random coordinate. - * The "humidity" flag is used to insure that engravings aren't - * created underwater, or eels on dry land. + * if x or y is < 0, we generate a random coordinate. + * The "humidity" flag is used to insure that engravings aren't + * created underwater, or eels on dry land. */ STATIC_DCL boolean FDECL(is_ok_location, (SCHAR_P, SCHAR_P, int)); @@ -1777,7 +1776,7 @@ struct mkroom *croom; * with what mkobj gave us! */ } - /* corpsenm is "empty" if -1, random if -2, otherwise specific */ + /* corpsenm is "empty" if -1, random if -2, otherwise specific */ if (o->corpsenm != NON_PM) { if (o->corpsenm == NON_PM - 1) set_corpsenm(otmp, rndmonnum()); @@ -3859,8 +3858,8 @@ int xc, yc, a, b, filled; selection_setpoint(xc + x, yc - y, ov, 1); selection_setpoint(xc - x, yc + y, ov, 1); } - if (t + b2 * x <= crit1 || /* e(x+1,y-1/2) <= 0 */ - t + a2 * y <= crit3) { /* e(x+1/2,y) <= 0 */ + if (t + b2 * x <= crit1 /* e(x+1,y-1/2) <= 0 */ + || t + a2 * y <= crit3) { /* e(x+1/2,y) <= 0 */ x++; dxt += d2xt; t += dxt; @@ -3879,8 +3878,8 @@ int xc, yc, a, b, filled; } } else { while (y >= 0 && x <= a) { - if (t + b2 * x <= crit1 || /* e(x+1,y-1/2) <= 0 */ - t + a2 * y <= crit3) { /* e(x+1/2,y) <= 0 */ + if (t + b2 * x <= crit1 /* e(x+1,y-1/2) <= 0 */ + || t + a2 * y <= crit3) { /* e(x+1/2,y) <= 0 */ x++; dxt += d2xt; t += dxt; @@ -5856,7 +5855,7 @@ sp_lev *lvl; coder->frame = tmpframe; } while (coder->frame); } - free(coder); + Free(coder); return TRUE; } diff --git a/src/steal.c b/src/steal.c index 15b1cb649..94fcaca2e 100644 --- a/src/steal.c +++ b/src/steal.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 steal.c $NHDT-Date: 1445906866 2015/10/27 00:47:46 $ $NHDT-Branch: master $:$NHDT-Revision: 1.64 $ */ +/* NetHack 3.6 steal.c $NHDT-Date: 1446713643 2015/11/05 08:54:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.65 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -57,12 +57,12 @@ long lmoney; } /* -Find the first (and hopefully only) gold object in a chain. -Used when leprechaun (or you as leprechaun) looks for -someone else's gold. Returns a pointer so the gold may -be seized without further searching. -May search containers too. -Deals in gold only, as leprechauns don't care for lesser coins. + * Find the first (and hopefully only) gold object in a chain. + * Used when leprechaun (or you as leprechaun) looks for + * someone else's gold. Returns a pointer so the gold may + * be seized without further searching. + * May search containers too. + * Deals in gold only, as leprechauns don't care for lesser coins. */ struct obj * findgold(chain) @@ -74,7 +74,7 @@ register struct obj *chain; } /* -Steal gold coins only. Leprechauns don't care for lesser coins. + * Steal gold coins only. Leprechauns don't care for lesser coins. */ void stealgold(mtmp) @@ -121,6 +121,7 @@ register struct monst *mtmp; } } else if (ygold) { const int gold_price = objects[GOLD_PIECE].oc_cost; + tmp = (somegold(money_cnt(invent)) + gold_price - 1) / gold_price; tmp = min(tmp, ygold->quan); if (tmp < ygold->quan) @@ -484,8 +485,7 @@ register struct obj *otmp; /* don't want hidden light source inside the monster; assumes that engulfers won't have external inventories; whirly monsters cause the light to be extinguished rather than letting it shine thru */ - if (otmp->lamplit && /* hack to avoid function calls for most objs */ - obj_sheds_light(otmp) && attacktype(mtmp->data, AT_ENGL)) { + if (obj_sheds_light(otmp) && attacktype(mtmp->data, AT_ENGL)) { /* this is probably a burning object that you dropped or threw */ if (u.uswallow && mtmp == u.ustuck && !Blind) pline("%s out.", Tobjnam(otmp, "go")); diff --git a/src/trap.c b/src/trap.c index e8ad26c1e..ebc1eede1 100644 --- a/src/trap.c +++ b/src/trap.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 trap.c $NHDT-Date: 1446604119 2015/11/04 02:28:39 $ $NHDT-Branch: master $:$NHDT-Revision: 1.243 $ */ +/* NetHack 3.6 trap.c $NHDT-Date: 1446713644 2015/11/05 08:54:04 $ $NHDT-Branch: master $:$NHDT-Revision: 1.244 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2436,9 +2436,9 @@ register struct monst *mtmp; /* fall though */ default: if (mptr->mlet == S_GIANT + /* exclude baby dragons and relatively short worms */ || (mptr->mlet == S_DRAGON && extra_nasty(mptr)) - || /* excl. babies */ - (mtmp->wormno && count_wsegs(mtmp) > 5)) { + || (mtmp->wormno && count_wsegs(mtmp) > 5)) { tear_web = TRUE; } else if (in_sight) { pline("%s is caught in %s spider web.", Monnam(mtmp), diff --git a/src/uhitm.c b/src/uhitm.c index 28a897855..b40bc96ed 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 uhitm.c $NHDT-Date: 1446078766 2015/10/29 00:32:46 $ $NHDT-Branch: master $:$NHDT-Revision: 1.149 $ */ +/* NetHack 3.6 uhitm.c $NHDT-Date: 1446713645 2015/11/05 08:54:05 $ $NHDT-Branch: master $:$NHDT-Revision: 1.150 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -12,8 +12,8 @@ STATIC_DCL boolean FDECL(hitum, (struct monst *, struct attack *)); STATIC_DCL boolean FDECL(hmon_hitmon, (struct monst *, struct obj *, int)); STATIC_DCL int FDECL(joust, (struct monst *, struct obj *)); STATIC_DCL void NDECL(demonpet); -STATIC_DCL boolean -FDECL(m_slips_free, (struct monst * mtmp, struct attack *mattk)); +STATIC_DCL boolean FDECL(m_slips_free, (struct monst * mtmp, + struct attack *mattk)); STATIC_DCL int FDECL(explum, (struct monst *, struct attack *)); STATIC_DCL void FDECL(start_engulf, (struct monst *)); STATIC_DCL void NDECL(end_engulf); @@ -305,8 +305,8 @@ int *attk_count, *role_roll_penalty; return tmp; } -/* try to attack; return FALSE if monster evaded */ -/* u.dx and u.dy must be set */ +/* try to attack; return False if monster evaded; + u.dx and u.dy must be set */ boolean attack(mtmp) register struct monst *mtmp; @@ -405,8 +405,8 @@ register struct monst *mtmp; /* Is the "it died" check actually correct? */ if (mdat->mlet == S_LEPRECHAUN && !mtmp->mfrozen && !mtmp->msleeping && !mtmp->mconf && mtmp->mcansee && !rn2(7) - && (m_move(mtmp, 0) == 2 || /* it died */ - mtmp->mx != u.ux + u.dx + && (m_move(mtmp, 0) == 2 /* it died */ + || mtmp->mx != u.ux + u.dx || mtmp->my != u.uy + u.dy)) /* it moved */ return FALSE; @@ -517,8 +517,9 @@ struct attack *uattk; return malive; } -boolean /* general "damage monster" routine */ - hmon(mon, obj, thrown) /* return TRUE if mon still alive */ +/* general "damage monster" routine; return True if mon still alive */ +boolean +hmon(mon, obj, thrown) struct monst *mon; struct obj *obj; int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */ @@ -876,6 +877,7 @@ int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */ } else { char *whom = mon_nam(mon); char *what = The(xname(obj)); + if (!thrown && obj->quan > 1L) what = An(singular(obj, xname)); /* note: s_suffix returns a modifiable buffer */ @@ -979,15 +981,13 @@ int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */ if (ispoisoned) { int nopoison = (10 - (obj->owt / 10)); + if (nopoison < 2) nopoison = 2; - if - Role_if(PM_SAMURAI) - { - You("dishonorably use a poisoned weapon!"); - adjalign(-sgn(u.ualign.type)); - } - else if ((u.ualign.type == A_LAWFUL) && (u.ualign.record > -10)) { + if (Role_if(PM_SAMURAI)) { + You("dishonorably use a poisoned weapon!"); + adjalign(-sgn(u.ualign.type)); + } else if (u.ualign.type == A_LAWFUL && u.ualign.record > -10) { You_feel("like an evil coward for using a poisoned weapon."); adjalign(-1); } @@ -1010,8 +1010,8 @@ int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */ tmp = 0; if (mdat == &mons[PM_SHADE]) { if (!hittxt) { - const char *what = - unconventional[0] ? unconventional : "attack"; + const char *what = *unconventional ? unconventional : "attack"; + Your("%s %s harmlessly through %s.", what, vtense(what, "pass"), mon_nam(mon)); hittxt = TRUE; @@ -1089,8 +1089,9 @@ int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */ } } - if (!hittxt && /*( thrown => obj exists )*/ - (!destroyed || (thrown && m_shot.n > 1 && m_shot.o == obj->otyp))) { + if (!hittxt /*( thrown => obj exists )*/ + && (!destroyed + || (thrown && m_shot.n > 1 && m_shot.o == obj->otyp))) { if (thrown) hit(mshot_xname(obj), mon, exclam(tmp)); else if (!flags.verbose) @@ -1174,7 +1175,8 @@ struct obj *obj; * 2) are dealt with properly by other routines * when it comes to shades. */ - if (obj->otyp == BOULDER || obj->otyp == HEAVY_IRON_BALL + if (obj->otyp == BOULDER + || obj->otyp == HEAVY_IRON_BALL || obj->otyp == IRON_CHAIN /* dmgval handles those first three */ || obj->otyp == MIRROR /* silver in the reflective surface */ || obj->otyp == CLOVE_OF_GARLIC /* causes shades to flee */ @@ -1227,9 +1229,10 @@ struct attack *mattk; return FALSE; } -/* used when hitting a monster with a lance while mounted */ -STATIC_OVL int /* 1: joust hit; 0: ordinary hit; -1: joust but break lance */ - joust(mon, obj) +/* used when hitting a monster with a lance while mounted; + 1: joust hit; 0: ordinary hit; -1: joust but break lance */ +STATIC_OVL int +joust(mon, obj) struct monst *mon; /* target */ struct obj *obj; /* weapon */ { @@ -1289,11 +1292,10 @@ struct obj *otmp; || !touch_petrifies(&mons[otmp->corpsenm]) || Stone_resistance) return FALSE; -/* no poly_when_stoned() critter has theft capability */ -#if 0 +#if 0 /* no poly_when_stoned() critter has theft capability */ if (poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM)) { - display_nhwindow(WIN_MESSAGE, FALSE); /* --More-- */ - return TRUE; + display_nhwindow(WIN_MESSAGE, FALSE); /* --More-- */ + return TRUE; } #endif @@ -1411,10 +1413,12 @@ register struct attack *mattk; mdef->mstun = 1; goto physical; case AD_LEGS: - /* if (u.ucancelled) { */ - /* tmp = 0; */ - /* break; */ - /* } */ +#if 0 + if (u.ucancelled) { + tmp = 0; + break; + } +#endif goto physical; case AD_WERE: /* no special effect on monsters */ case AD_HEAL: /* likewise */ @@ -2062,7 +2066,9 @@ boolean wouldhavehit; wakeup(mdef); } -STATIC_OVL boolean hmonas(mon) /* attack monster as a monster. */ +/* attack monster as a monster. */ +STATIC_OVL boolean +hmonas(mon) register struct monst *mon; { struct attack *mattk, alt_attk; @@ -2078,11 +2084,9 @@ register struct monst *mon; use_weapon: /* Certain monsters don't use weapons when encountered as enemies, * but players who polymorph into them have hands or claws and - * thus - * should be able to use weapons. This shouldn't prohibit the use - * of most special abilities, either. - * If a monster has multiple claw attacks, only one can use - * weapon. + * thus should be able to use weapons. This shouldn't prohibit + * the use of most special abilities, either. + * If monster has multiple claw attacks, only one can use weapon. */ weapon_used = TRUE; /* Potential problem: if the monster gets multiple weapon attacks, @@ -2113,11 +2117,11 @@ register struct monst *mon; case AT_CLAW: if (uwep && !cantwield(youmonst.data) && !weapon_used) goto use_weapon; - /*FALLTHRU*/ + /*FALLTHRU*/ case AT_TUCH: if (uwep && youmonst.data->mlet == S_LICH && !weapon_used) goto use_weapon; - /*FALLTHRU*/ + /*FALLTHRU*/ case AT_KICK: case AT_BITE: case AT_STNG: @@ -2259,8 +2263,8 @@ register struct monst *mon; return (boolean) (nsum != 0); } -/* Special (passive) attacks on you by monsters done here. */ - +/* Special (passive) attacks on you by monsters done here. + */ int passive(mon, mhit, malive, aatyp, wep_was_destroyed) register struct monst *mon; @@ -2286,8 +2290,8 @@ boolean wep_was_destroyed; else tmp = 0; - /* These affect you even if they just died */ - + /* These affect you even if they just died. + */ switch (ptr->mattk[i].adtyp) { case AD_FIRE: if (mhit && !mon->mcan) { @@ -2300,7 +2304,6 @@ boolean wep_was_destroyed; passive_obj(mon, (struct obj *) 0, &(ptr->mattk[i])); } break; - case AD_ACID: if (mhit && rn2(2)) { if (Blind || !flags.verbose) @@ -2333,8 +2336,9 @@ boolean wep_was_destroyed; if (aatyp == AT_MAGC) protector = W_ARMG; - if (protector == 0L || /* no protection */ - (protector == W_ARMG && !uarmg && !uwep && !wep_was_destroyed) + if (protector == 0L /* no protection */ + || (protector == W_ARMG && !uarmg + && !uwep && !wep_was_destroyed) || (protector == W_ARMF && !uarmf) || (protector == W_ARMH && !uarmh) || (protector == (W_ARMC | W_ARMG) && (!uarmc || !uarmg))) { @@ -2398,8 +2402,8 @@ boolean wep_was_destroyed; break; } - /* These only affect you if they still live */ - + /* These only affect you if they still live. + */ if (malive && !mon->mcan && rn2(3)) { switch (ptr->mattk[i].adtyp) { case AD_PLYS: @@ -2409,16 +2413,16 @@ boolean wep_was_destroyed; } if (mon->mcansee) { if (ureflects("%s gaze is reflected by your %s.", - s_suffix(Monnam(mon)))) + s_suffix(Monnam(mon)))) { ; - else if (Free_action) + } else if (Free_action) { You("momentarily stiffen under %s gaze!", s_suffix(mon_nam(mon))); - else if (Hallucination && rn2(4)) + } else if (Hallucination && rn2(4)) { pline("%s looks %s%s.", Monnam(mon), !rn2(2) ? "" : "rather ", !rn2(2) ? "numb" : "stupified"); - else { + } else { You("are frozen by %s gaze!", s_suffix(mon_nam(mon))); nomul((ACURR(A_WIS) > 12 || rn2(4)) ? -tmp : -127); multi_reason = "frozen by a monster's gaze"; @@ -2502,7 +2506,7 @@ register struct monst *mon; register struct obj *obj; /* null means pick uwep, uswapwep or uarmg */ struct attack *mattk; /* null means we find one internally */ { - register struct permonst *ptr = mon->data; + struct permonst *ptr = mon->data; register int i; /* if caller hasn't specified an object, use uwep, uswapwep or uarmg */ diff --git a/src/zap.c b/src/zap.c index c8db7a310..f05ec6cb8 100644 --- a/src/zap.c +++ b/src/zap.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 zap.c $NHDT-Date: 1446078771 2015/10/29 00:32:51 $ $NHDT-Branch: master $:$NHDT-Revision: 1.230 $ */ +/* NetHack 3.6 zap.c $NHDT-Date: 1446713647 2015/11/05 08:54:07 $ $NHDT-Branch: master $:$NHDT-Revision: 1.231 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -948,9 +948,9 @@ register struct obj *obj; || otyp == POT_SICKNESS || (otyp == POT_WATER && (obj->blessed || obj->cursed))) { if (obj->spe != ((obj->oclass == WAND_CLASS) ? -1 : 0) - && otyp != WAN_CANCELLATION && /* can't cancel cancellation */ - otyp != MAGIC_LAMP && /* cancelling doesn't remove djinni */ - otyp != CANDELABRUM_OF_INVOCATION) { + && otyp != WAN_CANCELLATION /* can't cancel cancellation */ + && otyp != MAGIC_LAMP /* cancelling doesn't remove djinni */ + && otyp != CANDELABRUM_OF_INVOCATION) { costly_alteration(obj, COST_CANCEL); obj->spe = (obj->oclass == WAND_CLASS) ? -1 : 0; } @@ -1338,6 +1338,7 @@ int id; /* Actually more things use corpsenm but they polymorph differently */ #define USES_CORPSENM(typ) \ ((typ) == CORPSE || (typ) == STATUE || (typ) == FIGURINE) + if (USES_CORPSENM(obj->otyp) && USES_CORPSENM(id)) set_corpsenm(otmp, obj->corpsenm); #undef USES_CORPSENM @@ -2653,7 +2654,7 @@ struct obj *obj; /* wand or spell */ case WAN_STRIKING: case SPE_FORCE_BOLT: striking = TRUE; - /*FALLTHRU*/ + /*FALLTHRU*/ case WAN_LOCKING: case SPE_WIZARD_LOCK: /* down at open bridge or up or down at open portcullis */ @@ -3785,13 +3786,15 @@ const char *fltxt; xkilled(mon, 2); } -/* type == 0 to 9 : you shooting a wand */ -/* type == 10 to 19 : you casting a spell */ -/* type == 20 to 29 : you breathing as a monster */ -/* type == -10 to -19 : monster casting spell */ -/* type == -20 to -29 : monster breathing at you */ -/* type == -30 to -39 : monster shooting a wand */ -/* called with dx = dy = 0 with vertical bolts */ +/* + * type == 0 to 9 : you shooting a wand + * type == 10 to 19 : you casting a spell + * type == 20 to 29 : you breathing as a monster + * type == -10 to -19 : monster casting spell + * type == -20 to -29 : monster breathing at you + * type == -30 to -39 : monster shooting a wand + * called with dx = dy = 0 with vertical bolts + */ void buzz(type, nd, sx, sy, dx, dy) register int type, nd; @@ -3804,7 +3807,7 @@ register int dx, dy; struct monst *mon; coord save_bhitpos; boolean shopdamage = FALSE; - register const char *fltxt; + const char *fltxt; struct obj *otmp; int spell_type; @@ -4048,9 +4051,9 @@ const char *msg; if (!msg) msg = "The ice crackles and melts."; - if (lev->typ == DRAWBRIDGE_UP) + if (lev->typ == DRAWBRIDGE_UP) { lev->drawbridgemask &= ~DB_ICE; /* revert to DB_MOAT */ - else { /* lev->typ == ICE */ + } else { /* lev->typ == ICE */ #ifdef STUPID if (lev->icedpool == ICED_POOL) lev->typ = POOL; @@ -4135,8 +4138,8 @@ long timeout UNUSED; melt_ice(x, y, "Some ice melts away."); } -/* Burn floor scrolls, evaporate pools, etc... in a single square. Used - * both for normal bolts of fire, cold, etc... and for fireballs. +/* Burn floor scrolls, evaporate pools, etc... in a single square. + * Used both for normal bolts of fire, cold, etc... and for fireballs. * Sets shopdamage to TRUE if a shop door is destroyed, and returns the * amount by which range is reduced (the latter is just ignored by fireballs) */ @@ -4169,6 +4172,7 @@ short exploding_wand_typ; melt_ice(x, y, (char *) 0); } else if (is_pool(x, y)) { const char *msgtxt = "You hear hissing gas."; + if (lev->typ != POOL) { /* MOAT or DRAWBRIDGE_UP */ if (see_it) msgtxt = "Some water evaporates."; @@ -4323,8 +4327,8 @@ short exploding_wand_typ; (except on rogue level) */ newsym(x, y); if (see_it) - pline("%s %s reveals a secret door.", yourzap ? "Your" : "The", - zapverb); + pline("%s %s reveals a secret door.", + yourzap ? "Your" : "The", zapverb); else if (Is_rogue_level(&u.uz)) draft_message(FALSE); /* "You feel a draft." (open doorway) */ } @@ -4333,6 +4337,7 @@ short exploding_wand_typ; if (closed_door(x, y)) { int new_doormask = -1; const char *see_txt = 0, *sense_txt = 0, *hear_txt = 0; + rangemod = -1000; switch (abstype) { case ZT_FIRE: @@ -4523,9 +4528,9 @@ destroy_item(osym, dmgtyp) register int osym, dmgtyp; { register struct obj *obj, *obj2; - register int dmg, xresist, skip; - register long i, cnt, quan; - register int dindx; + int dmg, xresist, skip; + long i, cnt, quan; + int dindx; const char *mult; boolean physical_damage; @@ -4957,17 +4962,20 @@ retry: u.uconduct.wishes++; if (otmp != &zeroobj) { + const char + *verb = ((Is_airlevel(&u.uz) || u.uinwater) ? "slip" : "drop"), + *oops_msg = (u.uswallow + ? "Oops! %s out of your reach!" + : (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) + || levl[u.ux][u.uy].typ < IRONBARS + || levl[u.ux][u.uy].typ >= ICE) + ? "Oops! %s away from you!" + : "Oops! %s to the floor!"); + /* The(aobjnam()) is safe since otmp is unidentified -dlc */ - (void) hold_another_object( - otmp, u.uswallow ? "Oops! %s out of your reach!" - : (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) - || levl[u.ux][u.uy].typ < IRONBARS - || levl[u.ux][u.uy].typ >= ICE) - ? "Oops! %s away from you!" - : "Oops! %s to the floor!", - The(aobjnam(otmp, - Is_airlevel(&u.uz) || u.uinwater ? "slip" : "drop")), - (const char *) 0); + (void) hold_another_object(otmp, oops_msg, + The(aobjnam(otmp, verb)), + (const char *) 0); u.ublesscnt += rn1(100, 50); /* the gods take notice */ } }