diff --git a/src/region.c b/src/region.c index c050556d5..c92ece9e0 100644 --- a/src/region.c +++ b/src/region.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 region.c $NHDT-Date: 1432512774 2015/05/25 00:12:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.33 $ */ +/* NetHack 3.6 region.c $NHDT-Date: 1445906843 2015/10/27 00:47:23 $ $NHDT-Branch: master $:$NHDT-Revision: 1.35 $ */ /* Copyright (c) 1996 by Jean-Christophe Collet */ /* NetHack may be freely redistributed. See license for details. */ @@ -831,8 +831,8 @@ genericptr_t p2; if (p2 == (genericptr_t)0) { /* That means the player */ if (!Blind) You("bump into %s. Ouch!", - Hallucination ? "an invisible tree" : - "some kind of invisible wall"); + Hallucination ? "an invisible tree" + : "some kind of invisible wall"); else pline("Ouch!"); } else { diff --git a/src/role.c b/src/role.c index f78e70cb1..2eb9c7e62 100644 --- a/src/role.c +++ b/src/role.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 role.c $NHDT-Date: 1434073671 2015/06/12 01:47:51 $ $NHDT-Branch: master $:$NHDT-Revision: 1.32 $ */ +/* NetHack 3.6 role.c $NHDT-Date: 1445906861 2015/10/27 00:47:41 $ $NHDT-Branch: master $:$NHDT-Revision: 1.33 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985-1999. */ /* NetHack may be freely redistributed. See license for details. */ @@ -809,13 +809,13 @@ boolean validrole(rolenum) int rolenum; { - return (rolenum >= 0 && rolenum < SIZE(roles) - 1); + return (boolean) (rolenum >= 0 && rolenum < SIZE(roles) - 1); } int randrole() { - return (rn2(SIZE(roles) - 1)); + return rn2(SIZE(roles) - 1); } STATIC_OVL int @@ -871,8 +871,9 @@ validrace(rolenum, racenum) int rolenum, racenum; { /* Assumes validrole */ - return (racenum >= 0 && racenum < SIZE(races) - 1 - && (roles[rolenum].allow & races[racenum].allow & ROLE_RACEMASK)); + return (boolean) (racenum >= 0 && racenum < SIZE(races) - 1 + && (roles[rolenum].allow & races[racenum].allow + & ROLE_RACEMASK)); } int @@ -895,11 +896,11 @@ int rolenum; if (n) n--; else - return (i); + return i; } /* This role has no permitted races? */ - return (rn2(SIZE(races) - 1)); + return rn2(SIZE(races) - 1); } int @@ -936,9 +937,9 @@ validgend(rolenum, racenum, gendnum) int rolenum, racenum, gendnum; { /* Assumes validrole and validrace */ - return (gendnum >= 0 && gendnum < ROLE_GENDERS - && (roles[rolenum].allow & races[racenum].allow - & genders[gendnum].allow & ROLE_GENDMASK)); + return (boolean) (gendnum >= 0 && gendnum < ROLE_GENDERS + && (roles[rolenum].allow & races[racenum].allow + & genders[gendnum].allow & ROLE_GENDMASK)); } int @@ -962,11 +963,11 @@ int rolenum, racenum; if (n) n--; else - return (i); + return i; } /* This role/race has no permitted genders? */ - return (rn2(ROLE_GENDERS)); + return rn2(ROLE_GENDERS); } int @@ -1002,9 +1003,9 @@ validalign(rolenum, racenum, alignnum) int rolenum, racenum, alignnum; { /* Assumes validrole and validrace */ - return (alignnum >= 0 && alignnum < ROLE_ALIGNS - && (roles[rolenum].allow & races[racenum].allow - & aligns[alignnum].allow & ROLE_ALIGNMASK)); + return (boolean) (alignnum >= 0 && alignnum < ROLE_ALIGNS + && (roles[rolenum].allow & races[racenum].allow + & aligns[alignnum].allow & ROLE_ALIGNMASK)); } int @@ -1028,11 +1029,11 @@ int rolenum, racenum; if (n) n--; else - return (i); + return i; } /* This role/race has no permitted alignments? */ - return (rn2(ROLE_ALIGNS)); + return rn2(ROLE_ALIGNS); } int @@ -2121,23 +2122,21 @@ struct monst *mtmp; { switch (Role_switch) { case PM_KNIGHT: - return ("Salutations"); /* Olde English */ + return "Salutations"; /* Olde English */ case PM_SAMURAI: - return (mtmp && mtmp->data == &mons[PM_SHOPKEEPER] + return (mtmp && mtmp->data == &mons[PM_SHOPKEEPER]) ? "Irasshaimase" - : "Konnichi wa"); /* Japanese */ + : "Konnichi wa"; /* Japanese */ case PM_TOURIST: - return ("Aloha"); /* Hawaiian */ + return "Aloha"; /* Hawaiian */ case PM_VALKYRIE: - return ( + return #ifdef MAIL - mtmp && mtmp->data == &mons[PM_MAIL_DAEMON] - ? "Hallo" - : + (mtmp && mtmp->data == &mons[PM_MAIL_DAEMON]) ? "Hallo" : #endif - "Velkommen"); /* Norse */ + "Velkommen"; /* Norse */ default: - return ("Hello"); + return "Hello"; } } @@ -2146,15 +2145,15 @@ Goodbye() { switch (Role_switch) { case PM_KNIGHT: - return ("Fare thee well"); /* Olde English */ + return "Fare thee well"; /* Olde English */ case PM_SAMURAI: - return ("Sayonara"); /* Japanese */ + return "Sayonara"; /* Japanese */ case PM_TOURIST: - return ("Aloha"); /* Hawaiian */ + return "Aloha"; /* Hawaiian */ case PM_VALKYRIE: - return ("Farvel"); /* Norse */ + return "Farvel"; /* Norse */ default: - return ("Goodbye"); + return "Goodbye"; } } diff --git a/src/shk.c b/src/shk.c index de832fa0f..64e17e411 100644 --- a/src/shk.c +++ b/src/shk.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 shk.c $NHDT-Date: 1433035328 2015/05/31 01:22:08 $ $NHDT-Branch: master $:$NHDT-Revision: 1.111 $ */ +/* NetHack 3.6 shk.c $NHDT-Date: 1445906862 2015/10/27 00:47:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.114 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -175,7 +175,7 @@ register boolean withbill; rile_shk(shkp); } } - return (shkp); + return shkp; } void shkgone(mtmp) /* called in mon.c */ @@ -316,7 +316,7 @@ register struct monst *shkp; total += bp->price * bp->bquan; bp++; } - return (total); + return total; } STATIC_OVL void @@ -381,9 +381,9 @@ register xchar x, y; rno = levl[x][y].roomno; if ((rno < ROOMOFFSET) || levl[x][y].edge || !IS_SHOP(rno - ROOMOFFSET)) - return (NO_ROOM); + return NO_ROOM; else - return (rno); + return rno; } void @@ -713,8 +713,8 @@ shopper_financial_report() long amt; int pass; - if (this_shkp - && !(ESHK(this_shkp)->credit || shop_debt(ESHK(this_shkp)))) { + eshkp = this_shkp ? ESHK(this_shkp) : 0; + if (eshkp && !(eshkp->credit || shop_debt(eshkp))) { You("have no credit or debt in here."); this_shkp = 0; /* skip first pass */ } @@ -744,9 +744,10 @@ int inhishop(mtmp) register struct monst *mtmp; { - return ( - index(in_rooms(mtmp->mx, mtmp->my, SHOPBASE), ESHK(mtmp)->shoproom) - && on_level(&(ESHK(mtmp)->shoplevel), &u.uz)); + struct eshk *eshkp = ESHK(mtmp); + + return (index(in_rooms(mtmp->mx, mtmp->my, SHOPBASE), eshkp->shoproom) + && on_level(&eshkp->shoplevel, &u.uz)); } struct monst * @@ -775,9 +776,9 @@ register struct mkroom *sroom; register struct monst *mtmp = sroom->resident; if (!mtmp) - return (FALSE); + return FALSE; else - return ((boolean)(inhishop(mtmp))); + return (boolean) inhishop(mtmp); } STATIC_OVL struct bill_x * @@ -808,7 +809,8 @@ boolean is_unpaid(obj) struct obj *obj; { - return (obj->unpaid || (Has_contents(obj) && count_unpaid(obj->cobj))); + return (boolean) (obj->unpaid + || (Has_contents(obj) && count_unpaid(obj->cobj))); } /* Delete the contents of the given object. */ @@ -905,9 +907,9 @@ register struct monst *shkp; { long credit = ESHK(shkp)->credit; - if (credit == 0L) - return (tmp); - if (credit >= tmp) { + if (credit == 0L) { + ; /* nothing to do; just 'return tmp;' */ + } else if (credit >= tmp) { pline_The("price is deducted from your credit."); ESHK(shkp)->credit -= tmp; tmp = 0L; @@ -916,7 +918,7 @@ register struct monst *shkp; ESHK(shkp)->credit = 0L; tmp -= credit; } - return (tmp); + return tmp; } STATIC_OVL void @@ -965,8 +967,8 @@ angry_shk_exists() for (shkp = next_shkp(fmon, FALSE); shkp; shkp = next_shkp(shkp->nmon, FALSE)) if (ANGRY(shkp)) - return (TRUE); - return (FALSE); + return TRUE; + return FALSE; } /* remove previously applied surcharge from all billed items */ @@ -1143,7 +1145,7 @@ register struct monst *shkp; gmin = bp->price * bp->bquan; bp++; } - return (gmin); + return gmin; } int @@ -1180,12 +1182,12 @@ dopay() if ((!sk && (!Blind || Blind_telepat)) || (!Blind && !seensk)) { There("appears to be no shopkeeper here to receive your payment."); - return (0); + return 0; } if (!seensk) { You_cant("see..."); - return (0); + return 0; } /* the usual case. allow paying at a distance when */ @@ -1203,7 +1205,7 @@ dopay() if (shkp != resident && distu(shkp->mx, shkp->my) > 2) { pline("%s is not near enough to receive your payment.", Monnam(shkp)); - return (0); + return 0; } } else { struct monst *mtmp; @@ -1219,31 +1221,31 @@ dopay() cy = cc.y; if (cx < 0) { pline("Try again..."); - return (0); + return 0; } if (u.ux == cx && u.uy == cy) { You("are generous to yourself."); - return (0); + return 0; } mtmp = m_at(cx, cy); if (!mtmp) { There("is no one there to receive your payment."); - return (0); + return 0; } if (!mtmp->isshk) { pline("%s is not interested in your payment.", Monnam(mtmp)); - return (0); + return 0; } if (mtmp != resident && distu(mtmp->mx, mtmp->my) > 2) { pline("%s is too far to receive your payment.", Monnam(mtmp)); - return (0); + return 0; } shkp = mtmp; } if (!shkp) { debugpline0("dopay: null shkp."); - return (0); + return 0; } proceed: eshkp = ESHK(shkp); @@ -1284,7 +1286,7 @@ proceed: else make_happy_shk(shkp, FALSE); } - return (1); + return 1; } /* ltmp is still eshkp->robbed here */ @@ -1301,7 +1303,7 @@ proceed: pline(no_money, stashed_gold ? " seem to" : ""); else pline(not_enough_money, mhim(shkp)); - return (1); + return 1; } pline("But since %s shop has been robbed recently,", mhis(shkp)); pline("you %scompensate %s for %s losses.", @@ -1318,7 +1320,7 @@ proceed: pline(no_money, stashed_gold ? " seem to" : ""); else pline(not_enough_money, mhim(shkp)); - return (1); + return 1; } You("try to appease %s by giving %s 1000 gold pieces.", x_monnam(shkp, ARTICLE_THE, "angry", 0, FALSE), mhim(shkp)); @@ -1328,13 +1330,13 @@ proceed: else pline("But %s is as angry as ever.", shkname(shkp)); } - return (1); + return 1; } if (shkp != resident) { impossible("dopay: not to shopkeeper?"); if (resident) setpaid(resident); - return (0); + return 0; } /* pay debt, if any, first */ if (eshkp->debit) { @@ -1357,7 +1359,7 @@ proceed: pline("But you don't%s have enough gold%s.", stashed_gold ? " seem to" : "", eshkp->credit ? " or credit" : ""); - return (1); + return 1; } else { if (eshkp->credit >= dtmp) { eshkp->credit -= dtmp; @@ -1391,14 +1393,14 @@ proceed: if (!umoney && !eshkp->credit) { You("%shave no money or credit%s.", stashed_gold ? "seem to " : "", paid ? " left" : ""); - return (0); + return 0; } if ((umoney + eshkp->credit) < cheapest_item(shkp)) { You("don't have enough money to buy%s the item%s you picked.", eshkp->billct > 1 ? " any of" : "", plur(eshkp->billct)); if (stashed_gold) pline("Maybe you have some gold stashed away?"); - return (0); + return 0; } /* this isn't quite right; it itemizes without asking if the @@ -1464,7 +1466,7 @@ proceed: if (!ANGRY(shkp) && paid && !muteshk(shkp)) verbalize("Thank you for shopping in %s %s!", s_suffix(shkname(shkp)), shtypes[eshkp->shoptype - SHOPBASE].name); - return (1); + return 1; } /* return 2 if used-up portion paid */ @@ -1760,7 +1762,7 @@ int croaked; clear: shkp->minvis = save_minvis; setpaid(shkp); - return (taken); + return taken; } STATIC_OVL void @@ -2050,7 +2052,7 @@ register struct obj *obj; else if (Has_contents(otmp)) value += contained_gold(otmp); - return (value); + return value; } STATIC_OVL void @@ -2630,7 +2632,7 @@ boolean ininv; price = stolen_container(otmp, shkp, price, ininv); } - return (price); + return price; } long @@ -2673,7 +2675,7 @@ boolean peaceful, silent; } if (gvalue + value == 0L) - return (0L); + return 0L; value += gvalue; @@ -2722,7 +2724,7 @@ boolean peaceful, silent; hot_pursuit(shkp); (void) angry_guards(FALSE); } - return (value); + return value; } /* auto-response flag for/from "sell foo?" 'a' => 'y', 'q' => 'n' */ @@ -3094,7 +3096,7 @@ int mode; /* 0: deliver count 1: paged */ display_nhwindow(datawin, FALSE); quit: destroy_nhwindow(datawin); - return (0); + return 0; } #define HUNGRY 2 @@ -3150,13 +3152,13 @@ register xchar x, y; register struct monst *shkp; if (!(shkp = shop_keeper(inside_shop(x, y))) || !inhishop(shkp)) - return (0); + return 0; if (shkp->mcanmove && !shkp->msleeping && (*u.ushops != ESHK(shkp)->shoproom || !inside_shop(u.ux, u.uy)) - && dist2(shkp->mx, shkp->my, x, y) < 3 && + && dist2(shkp->mx, shkp->my, x, y) < 3 /* if it is the shk's pos, you hit and anger him */ - (shkp->mx != x || shkp->my != y)) { + && (shkp->mx != x || shkp->my != y)) { if (mnearto(shkp, x, y, TRUE) && !muteshk(shkp)) verbalize("Out of my way, scum!"); if (cansee(x, y)) { @@ -3271,9 +3273,9 @@ boolean croaked; if (cansee(x, y)) { if (IS_WALL(levl[x][y].typ)) { saw_walls++; - } else if (IS_DOOR(levl[x][y].typ) && + } else if (IS_DOOR(levl[x][y].typ) /* an existing door here implies trap removal */ - !(old_doormask & (D_ISOPEN | D_CLOSED))) { + && !(old_doormask & (D_ISOPEN | D_CLOSED))) { saw_door = TRUE; } else if (disposition == 3) { /* untrapped */ saw_untrap++; @@ -3356,24 +3358,24 @@ boolean catchup; /* restoring a level */ register struct trap *ttmp; if ((monstermoves - tmp_dam->when) < REPAIR_DELAY) - return (0); + return 0; if (shkp->msleeping || !shkp->mcanmove || ESHK(shkp)->following) - return (0); + return 0; x = tmp_dam->place.x; y = tmp_dam->place.y; if (!IS_ROOM(tmp_dam->typ)) { if (x == u.ux && y == u.uy) if (!Passes_walls) - return (0); + return 0; if (x == shkp->mx && y == shkp->my) - return (0); + return 0; if ((mtmp = m_at(x, y)) && (!passes_walls(mtmp->data))) - return (0); + return 0; } if ((ttmp = t_at(x, y)) != 0) { if (x == u.ux && y == u.uy) if (!Passes_walls) - return (0); + return 0; if (ttmp->ttyp == LANDMINE || ttmp->ttyp == BEAR_TRAP) { /* convert to an object */ otmp = mksobj((ttmp->ttyp == LANDMINE) ? LAND_MINE : BEARTRAP, @@ -3391,16 +3393,16 @@ boolean catchup; /* restoring a level */ block_point(x, y); } newsym(x, y); - return (3); + return 3; } if (IS_ROOM(tmp_dam->typ)) { /* No messages, because player already filled trap door */ - return (1); + return 1; } if ((tmp_dam->typ == levl[x][y].typ) && (!IS_DOOR(tmp_dam->typ) || (levl[x][y].doormask > D_BROKEN))) /* No messages if player already replaced shop door */ - return (1); + return 1; levl[x][y].typ = tmp_dam->typ; (void) memset((genericptr_t) litter, 0, sizeof(litter)); if ((otmp = level.objects[x][y]) != 0) { @@ -3466,7 +3468,7 @@ boolean catchup; /* restoring a level */ for (i = 0; i < 9; i++) if (litter[i] & NEED_UPDATE) newsym(x + horiz(i), y + vert(i)); - return (2); + return 2; #undef NEED_UPDATE #undef OPEN #undef INSHOP @@ -3500,7 +3502,7 @@ register struct monst *shkp; if (Displaced) Your("displaced image doesn't fool %s!", mon_nam(shkp)); (void) mattacku(shkp); - return (0); + return 0; } if (eshkp->following) { if (strncmp(eshkp->customer, plname, PL_NSIZ)) { @@ -3508,7 +3510,7 @@ register struct monst *shkp; verbalize("%s, %s! I was looking for %s.", Hello(shkp), plname, eshkp->customer); eshkp->following = 0; - return (0); + return 0; } if (moves > followmsg + 4) { if (!muteshk(shkp)) @@ -3522,7 +3524,7 @@ register struct monst *shkp; } } if (udist < 2) - return (0); + return 0; } } @@ -3539,7 +3541,7 @@ register struct monst *shkp; invent, triggering billing impossibilities on the next level once the character fell through the hole.] */ if (udist > 4 && eshkp->following && !eshkp->billct) - return (-1); /* leave it to m_move */ + return -1; /* leave it to m_move */ gx = u.ux; gy = u.uy; } else if (ANGRY(shkp)) { @@ -3561,7 +3563,7 @@ register struct monst *shkp; || (Fast && (sobj_at(PICK_AXE, u.ux, u.uy) || sobj_at(DWARVISH_MATTOCK, u.ux, u.uy)))); if (satdoor && badinv) - return (0); + return 0; avoid = !badinv; } else { avoid = (*u.ushops && distu(gx, gy) > 8); @@ -3571,7 +3573,7 @@ register struct monst *shkp; if (((!eshkp->robbed && !eshkp->billct && !eshkp->debit) || avoid) && GDIST(omx, omy) < 3) { if (!badinv && !onlineu(omx, omy)) - return (0); + return 0; if (satdoor) appr = gx = gy = 0; } @@ -3606,7 +3608,7 @@ boolean is_fshk(mtmp) register struct monst *mtmp; { - return ((boolean)(mtmp->isshk && ESHK(mtmp)->following)); + return (boolean) (mtmp->isshk && ESHK(mtmp)->following); } /* You are digging in the shop. */ @@ -3896,17 +3898,17 @@ boolean costly_spot(x, y) register xchar x, y; { - register struct monst *shkp; + struct monst *shkp; + struct eshk *eshkp; if (!level.flags.has_shop) return FALSE; shkp = shop_keeper(*in_rooms(x, y, SHOPBASE)); if (!shkp || !inhishop(shkp)) - return (FALSE); - - return ( - (boolean)(inside_shop(x, y) - && !(x == ESHK(shkp)->shk.x && y == ESHK(shkp)->shk.y))); + return FALSE; + eshkp = ESHK(shkp); + return (boolean) (inside_shop(x, y) + && !(x == eshkp->shk.x && y == eshkp->shk.y)); } /* called by dotalk(sounds.c) when #chatting; returns obj if location @@ -3925,8 +3927,8 @@ register xchar x, y; if (otmp->oclass != COIN_CLASS) break; /* note: otmp might have ->no_charge set, but that's ok */ - return (otmp && costly_spot(x, y) && NOTANGRY(shkp) && shkp->mcanmove - && !shkp->msleeping) + return (otmp && costly_spot(x, y) + && NOTANGRY(shkp) && shkp->mcanmove && !shkp->msleeping) ? otmp : (struct obj *) 0; } @@ -4121,7 +4123,7 @@ boolean altusage; /* some items have an "alternate" use with different cost */ long tmp = 0L; if (!shkp || !inhishop(shkp)) - return (0L); /* insurance */ + return 0L; /* insurance */ tmp = get_cost(otmp, shkp); /* The idea is to make the exhaustive use of */ @@ -4164,7 +4166,7 @@ boolean altusage; /* some items have an "alternate" use with different cost */ } else if (otmp->otyp == POT_OIL) { tmp /= 5L; } - return (tmp); + return tmp; } /* Charge the player for partial use of an unpaid object. @@ -4273,14 +4275,14 @@ register xchar x, y; register struct monst *shkp; if (roomno < 0 || !IS_SHOP(roomno)) - return (FALSE); + return FALSE; if (!IS_DOOR(levl[x][y].typ)) - return (FALSE); + return FALSE; if (roomno != *u.ushops) - return (FALSE); + return FALSE; if (!(shkp = shop_keeper((char) roomno)) || !inhishop(shkp)) - return (FALSE); + return FALSE; if (shkp->mx == ESHK(shkp)->shk.x && shkp->my == ESHK(shkp)->shk.y /* Actually, the shk should be made to block _any_ @@ -4293,9 +4295,9 @@ register xchar x, y; && (ESHK(shkp)->debit || ESHK(shkp)->billct || ESHK(shkp)->robbed)) { pline("%s%s blocks your way!", shkname(shkp), Invis ? " senses your motion and" : ""); - return (TRUE); + return TRUE; } - return (FALSE); + return FALSE; } /* used in domove to block diagonal shop-entry */ @@ -4310,16 +4312,16 @@ register xchar x, y; if (!(IS_DOOR(levl[u.ux][u.uy].typ) && levl[u.ux][u.uy].doormask == D_BROKEN)) - return (FALSE); + return FALSE; roomno = *in_rooms(x, y, SHOPBASE); if (roomno < 0 || !IS_SHOP(roomno)) - return (FALSE); + return FALSE; if (!(shkp = shop_keeper((char) roomno)) || !inhishop(shkp)) - return (FALSE); + return FALSE; if (ESHK(shkp)->shd.x != u.ux || ESHK(shkp)->shd.y != u.uy) - return (FALSE); + return FALSE; sx = ESHK(shkp)->shk.x; sy = ESHK(shkp)->shk.y; @@ -4330,9 +4332,9 @@ register xchar x, y; || u.usteed)) { pline("%s%s blocks your way!", shkname(shkp), Invis ? " senses your motion and" : ""); - return (TRUE); + return TRUE; } - return (FALSE); + return FALSE; } /* "your " or "Foobar's " (note the trailing space) */ diff --git a/src/sit.c b/src/sit.c index 13d063888..b91da1581 100644 --- a/src/sit.c +++ b/src/sit.c @@ -1,15 +1,18 @@ -/* NetHack 3.6 sit.c $NHDT-Date: 1436753523 2015/07/13 02:12:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.50 $ */ +/* NetHack 3.6 sit.c $NHDT-Date: 1445906863 2015/10/27 00:47:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.51 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ #include "hack.h" #include "artifact.h" + +/* take away the hero's money */ void take_gold() { struct obj *otmp, *nobj; int lost_money = 0; + for (otmp = invent; otmp; otmp = nobj) { nobj = otmp->nobj; if (otmp->oclass == COIN_CLASS) { @@ -26,6 +29,7 @@ take_gold() } } +/* #sit command */ int dosit() { @@ -35,7 +39,7 @@ dosit() if (u.usteed) { You("are already sitting on %s.", mon_nam(u.usteed)); - return (0); + return 0; } if (u.uundetected && is_hider(youmonst.data) && u.umonnum != PM_TRAPPER) u.uundetected = 0; /* no longer on the ceiling */ @@ -60,9 +64,9 @@ dosit() goto in_water; } - if (OBJ_AT(u.ux, u.uy) && + if (OBJ_AT(u.ux, u.uy) /* ensure we're not standing on the precipice */ - !uteetering_at_seen_pit(trap)) { + && !uteetering_at_seen_pit(trap)) { register struct obj *obj; obj = level.objects[u.ux][u.uy]; @@ -306,10 +310,12 @@ dosit() } else { pline("Having fun sitting on the %s?", surface(u.ux, u.uy)); } - return (1); + return 1; } -void rndcurse() /* curse a few inventory items at random! */ +/* curse a few inventory items at random! */ +void +rndcurse() { int nobj = 0; int cnt, onum; @@ -377,7 +383,9 @@ void rndcurse() /* curse a few inventory items at random! */ } } -void attrcurse() /* remove a random INTRINSIC ability */ +/* remove a random INTRINSIC ability */ +void +attrcurse() { switch (rnd(11)) { case 1: @@ -438,6 +446,7 @@ void attrcurse() /* remove a random INTRINSIC ability */ break; } case 10: + /* intrinsic protection is just disabled, not set back to 0 */ if (HProtection & INTRINSIC) { HProtection &= ~INTRINSIC; You_feel("vulnerable."); diff --git a/src/sounds.c b/src/sounds.c index 5950db697..e73890a92 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 sounds.c $NHDT-Date: 1436753524 2015/07/13 02:12:04 $ $NHDT-Branch: master $:$NHDT-Revision: 1.69 $ */ +/* 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 may be freely redistributed. See license for details. */ @@ -180,14 +180,14 @@ dosounds() for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; - if (is_mercenary(mtmp->data) && + 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) && + && mon_in_room(mtmp, BARRACKS) /* sleeping implies not-yet-disturbed (usually) */ - (mtmp->msleeping || ++count > 5)) { + && (mtmp->msleeping || ++count > 5)) { You_hear1(barracks_msg[rn2(3) + hallu]); return; } @@ -229,11 +229,11 @@ dosounds() for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; - if (mtmp->ispriest && inhistemple(mtmp) && + if (mtmp->ispriest && inhistemple(mtmp) /* priest must be active */ - mtmp->mcanmove && !mtmp->msleeping && + && mtmp->mcanmove && !mtmp->msleeping /* hero must be outside this temple */ - temple_occupied(u.urooms) != EPRI(mtmp)->shroom) + && temple_occupied(u.urooms) != EPRI(mtmp)->shroom) break; } if (mtmp) { @@ -483,7 +483,7 @@ struct monst *mon; /* result depends upon whether map spot shows a gecko, which will be due to hallucination or to mimickery since mon isn't one */ glyph = glyph_at(mon->mx, mon->my); - return (boolean)(glyph_to_mon(glyph) == PM_GECKO); + return (boolean) (glyph_to_mon(glyph) == PM_GECKO); } STATIC_OVL int @@ -499,9 +499,9 @@ register struct monst *mtmp; /* presumably nearness and sleep checks have already been made */ if (Deaf) - return (0); + return 0; if (is_silent(ptr)) - return (0); + return 0; /* leader might be poly'd; if he can still speak, give leader speech */ if (mtmp->m_id == quest_status.leader_m_id && msound > MS_ANIMAL) @@ -904,29 +904,31 @@ register struct monst *mtmp; }; verbl_msg = mtmp->mpeaceful ? soldier_pax_msg[rn2(3)] : soldier_foe_msg[rn2(3)]; - } break; + break; + } case MS_RIDER: /* 3.6.0 tribute */ - if (ptr == &mons[PM_DEATH] && - !context.tribute.Deathnotice && u_have_novel()) { + if (ptr == &mons[PM_DEATH] + && !context.tribute.Deathnotice && u_have_novel()) { struct obj *book = u_have_novel(); const char *tribtitle = (char *)0; if (book) { int novelidx = book->novelidx; + tribtitle = noveltitle(&novelidx); } if (tribtitle) { Sprintf(verbuf, "Ah, so you have a copy of /%s/.", tribtitle); /* no Death featured in these two, so exclude them */ - if (!(strcmpi(tribtitle, "Snuff") == 0 || - strcmpi(tribtitle, "The Wee Free Men") == 0)) + if (!(strcmpi(tribtitle, "Snuff") == 0 + || strcmpi(tribtitle, "The Wee Free Men") == 0)) Strcat(verbuf, " I may have been misquoted there."); verbl_msg = verbuf; context.tribute.Deathnotice = 1; } - } else if (ptr == &mons[PM_DEATH] && - !rn2(2) && Death_quote(verbuf, BUFSZ)) { + } else if (ptr == &mons[PM_DEATH] + && !rn2(2) && Death_quote(verbuf, BUFSZ)) { verbl_msg = verbuf; } /* end of tribute addition */ @@ -952,9 +954,10 @@ register struct monst *mtmp; verbalize1(verbl_msg); } } - return (1); + return 1; } +/* #chat command */ int dotalk() { @@ -967,29 +970,29 @@ dotalk() STATIC_OVL int dochat() { - register struct monst *mtmp; - register int tx, ty; + struct monst *mtmp; + int tx, ty; struct obj *otmp; if (is_silent(youmonst.data)) { pline("As %s, you cannot speak.", an(youmonst.data->mname)); - return (0); + return 0; } if (Strangled) { You_cant("speak. You're choking!"); - return (0); + return 0; } if (u.uswallow) { pline("They won't hear you out there."); - return (0); + return 0; } if (Underwater) { Your("speech is unintelligible underwater."); - return (0); + return 0; } if (Deaf) { pline("How can you hold a conversation when you cannot hear?"); - return (0); + return 0; } if (!Blind && (otmp = shop_object(u.ux, u.uy)) != (struct obj *) 0) { @@ -998,73 +1001,67 @@ dochat() a shop, but that shouldn't matter much. shop_object() returns an object iff inside a shop and the shopkeeper is present and willing (not angry) and able (not asleep) to speak and the position - contains - any objects other than just gold. + contains any objects other than just gold. */ price_quote(otmp); - return (1); + return 1; } if (!getdir("Talk to whom? (in what direction)")) { /* decided not to chat */ - return (0); + return 0; } if (u.usteed && u.dz > 0) { if (!u.usteed->mcanmove || u.usteed->msleeping) { pline("%s seems not to notice you.", Monnam(u.usteed)); - return (1); + return 1; } else - return (domonnoise(u.usteed)); + return domonnoise(u.usteed); } if (u.dz) { pline("They won't hear you %s there.", u.dz < 0 ? "up" : "down"); - return (0); + return 0; } if (u.dx == 0 && u.dy == 0) { /* - * Let's not include this. It raises all sorts of questions: can you - wear + * Let's not include this. + * It raises all sorts of questions: can you wear * 2 helmets, 2 amulets, 3 pairs of gloves or 6 rings as a marilith, * etc... --KAA - if (u.umonnum == PM_ETTIN) { - You("discover that your other head makes boring - conversation."); - return(1); - } - */ + if (u.umonnum == PM_ETTIN) { + You("discover that your other head makes boring conversation."); + return 1; + } + */ pline("Talking to yourself is a bad habit for a dungeoneer."); - return (0); + return 0; } tx = u.ux + u.dx; ty = u.uy + u.dy; if (!isok(tx, ty)) - return (0); + return 0; mtmp = m_at(tx, ty); - if ((!mtmp || mtmp->mundetected) && (otmp = vobj_at(tx, ty)) - && otmp->otyp == STATUE) { + if ((!mtmp || mtmp->mundetected) + && (otmp = vobj_at(tx, ty)) != 0 && otmp->otyp == STATUE) { /* Talking to a statue */ - if (!Blind) { - if (Hallucination) { - /* if you're hallucinating, you can't tell it's a statue */ - pline_The("%s seems not to notice you.", rndmonnam(NULL)); - } else { - pline_The("statue seems not to notice you."); - } + pline_The("%s seems not to notice you.", + /* if hallucinating, you can't tell it's a statue */ + Hallucination ? rndmonnam((char *) 0) : "statue"); } - return (0); + return 0; } if (!mtmp || mtmp->mundetected || mtmp->m_ap_type == M_AP_FURNITURE || mtmp->m_ap_type == M_AP_OBJECT) - return (0); + return 0; /* sleeping monsters won't talk, except priests (who wake up) */ if ((!mtmp->mcanmove || mtmp->msleeping) && !mtmp->ispriest) { @@ -1072,7 +1069,7 @@ dochat() not noticing him and just not existing, so skip the message. */ if (canspotmon(mtmp)) pline("%s seems not to notice you.", Monnam(mtmp)); - return (0); + return 0; } /* if this monster is waiting for something, prod it into action */ @@ -1082,7 +1079,7 @@ dochat() if (!canspotmon(mtmp)) map_invisible(mtmp->mx, mtmp->my); pline("%s is eating noisily.", Monnam(mtmp)); - return (0); + return 0; } return domonnoise(mtmp); diff --git a/src/sp_lev.c b/src/sp_lev.c index 035a48b82..1fac220aa 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 sp_lev.c $NHDT-Date: 1444774496 2015/10/13 22:14:56 $ $NHDT-Branch: master $:$NHDT-Revision: 1.62 $ */ +/* 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 may be freely redistributed. See license for details. */ @@ -209,6 +209,7 @@ void solidify_map() { xchar x, y; + for (x = 0; x < COLNO; x++) for (y = 0; y < ROWNO; y++) if (IS_STWALL(levl[x][y].typ) && !SpLev_Map[x][y]) @@ -278,6 +279,7 @@ struct opvar *v; if (st->depth >= st->depth_alloc) { struct opvar **tmp = (struct opvar **) alloc( (st->depth_alloc + SPLEV_STACK_RESERVE) * sizeof(struct opvar *)); + (void) memcpy(tmp, st->stackdata, st->depth_alloc * sizeof(struct opvar *)); Free(st->stackdata); @@ -294,6 +296,7 @@ splev_stack_pop(st) struct splevstack *st; { struct opvar *ret = NULL; + if (!st) return ret; if (!st->stackdata) @@ -315,6 +318,7 @@ struct splevstack *st; { long i; struct opvar *tmp; + if (!st) return NULL; if (!st->stackdata) @@ -472,6 +476,7 @@ struct opvar *ov; struct splev_var *tmp; struct opvar *tmpov; struct opvar *array_idx = NULL; + if (!coder || !ov) return NULL; if (ov->spovartyp != SPOVAR_VARIABLE) @@ -505,6 +510,7 @@ struct sp_coder *coder; char *name; { struct splev_var *tmp; + if (!coder) return NULL; tmp = coder->frame->variables; @@ -523,6 +529,7 @@ xchar typ; { if (coder && coder->stack) { struct opvar *tmp = splev_stack_pop(coder->stack); + if (!tmp) panic("no value type %i in stack.", typ); if (tmp->spovartyp == SPOVAR_VARIABLE) @@ -605,7 +612,6 @@ schar lit; /* * Make walls of the area (x1, y1, x2, y2) non diggable/non passwall-able */ - STATIC_OVL void set_wall_property(x1, y1, x2, y2, prop) xchar x1, y1, x2, y2; @@ -624,6 +630,7 @@ shuffle_alignments() { int i; aligntyp atmp; + /* shuffle 3 alignments */ i = rn2(3); atmp = ralign[2]; @@ -643,6 +650,7 @@ STATIC_OVL void count_features() { xchar x, y; + level.flags.nfountains = level.flags.nsinks = 0; for (y = 0; y < ROWNO; y++) for (x = 0; x < COLNO; x++) { @@ -664,6 +672,7 @@ remove_boundary_syms() */ xchar x, y; boolean has_bounds = FALSE; + for (x = 0; x < COLNO - 1; x++) for (y = 0; y < ROWNO - 1; y++) if (levl[x][y].typ == CROSSWALL) { @@ -692,6 +701,7 @@ link_doors_rooms() { int x, y; int tmpi, m; + for (y = 0; y < ROWNO; y++) for (x = 0; x < COLNO; x++) if (IS_DOOR(levl[x][y].typ) || levl[x][y].typ == SDOOR) { @@ -708,6 +718,7 @@ void fill_rooms() { int tmpi; + for (tmpi = 0; tmpi < nroom; tmpi++) { int m; if (rooms[tmpi].needfill) @@ -725,6 +736,7 @@ STATIC_OVL int rnddoor() { int i = 1 << rn2(5); + i >>= 1; return i; } @@ -813,6 +825,7 @@ struct mkroom *croom; } while (++cpt < 100); if (cpt >= 100) { register int xx, yy; + /* last try */ for (xx = 0; xx < sx; xx++) for (yy = 0; yy < sy; yy++) { @@ -902,6 +915,7 @@ struct mkroom *croom; long crd; { unpacked_coord c; + c = get_unpacked_coord(crd, humidity); *x = c.x; *y = c.y; @@ -943,7 +957,6 @@ struct mkroom *croom; * Get a relative position inside a room. * negative values for x or y means RANDOM! */ - STATIC_OVL void get_free_room_loc(x, y, croom, pos) schar *x, *y; @@ -1028,7 +1041,6 @@ chk: * Create a new room. * This is still very incomplete... */ - boolean create_room(x, y, w, h, xal, yal, rtype, rlit) xchar x, y; @@ -1201,7 +1213,6 @@ xchar rtype, rlit; * Create a subroom in room proom at pos x,y with width w & height h. * x & y are relative to the parent room. */ - STATIC_OVL boolean create_subroom(proom, x, y, w, h, rtype, rlit) struct mkroom *proom; @@ -1249,7 +1260,6 @@ xchar rtype, rlit; * Create a new door in a room. * It's placed on a wall (north, south, east or west). */ - STATIC_OVL void create_door(dd, broom) room_door *dd; @@ -1404,7 +1414,6 @@ xchar walls; /* any of W_NORTH | W_SOUTH | W_EAST | W_WEST (or W_ANY) */ /* * Create a trap in a room. */ - STATIC_OVL void create_trap(t, croom) trap *t; @@ -1434,7 +1443,6 @@ struct mkroom *croom; /* * Create a monster in a room. */ - STATIC_OVL int noncoalignment(alignment) aligntyp alignment; @@ -1490,14 +1498,13 @@ struct mkroom *croom; if (class == MAXMCLASSES) panic("create_monster: unknown monster class '%c'", m->class); - amask = - (m->align == AM_SPLEV_CO) - ? Align2amask(u.ualignbase[A_ORIGINAL]) - : (m->align == AM_SPLEV_NONCO) + amask = (m->align == AM_SPLEV_CO) + ? Align2amask(u.ualignbase[A_ORIGINAL]) + : (m->align == AM_SPLEV_NONCO) ? Align2amask(noncoalignment(u.ualignbase[A_ORIGINAL])) : (m->align <= -(MAX_REGISTERS + 1)) - ? induced_align(80) - : (m->align < 0 ? ralign[-m->align - 1] : m->align); + ? induced_align(80) + : (m->align < 0 ? ralign[-m->align - 1] : m->align); if (!class) pm = (struct permonst *) 0; @@ -1565,8 +1572,8 @@ struct mkroom *croom; switch (m->appear) { case M_AP_NOTHING: - impossible("create_monster: mon has an appearance, \"%s\", " - "but no type", + impossible( + "create_monster: mon has an appearance, \"%s\", but no type", m->appear_as.str); break; @@ -1619,6 +1626,7 @@ struct mkroom *croom; case M_AP_MONSTER: { int mndx; + if (!strcmpi(m->appear_as.str, "random")) mndx = select_newcham_form(mtmp); else @@ -1642,7 +1650,8 @@ struct mkroom *croom; if (!mtmp->perminvis || pm_invisible(olddata)) mtmp->perminvis = pm_invisible(mdat); } - } break; + break; + } default: impossible("create_monster: unimplemented mon appear type " "[%d,\"%s\"]", @@ -1709,7 +1718,6 @@ struct mkroom *croom; /* * Create an object in a room. */ - STATIC_OVL void create_object(o, croom) object *o; @@ -1782,18 +1790,18 @@ struct mkroom *croom; otmp = oname(otmp, o->name.str); if (o->eroded) { - if (o->eroded < 0) + if (o->eroded < 0) { otmp->oerodeproof = 1; - else { + } else { otmp->oeroded = (o->eroded % 4); otmp->oeroded2 = ((o->eroded >> 2) % 4); } } if (o->recharged) otmp->recharged = (o->recharged % 8); - if (o->locked) + if (o->locked) { otmp->olocked = 1; - else if (o->broken) { + } else if (o->broken) { otmp->obroken = 1; otmp->olocked = 0; /* obj generation may set */ } @@ -1806,7 +1814,7 @@ struct mkroom *croom; otmp->oinvis = 1; #endif - if ((o->quan > 0) && objects[otmp->otyp].oc_merge) { + if (o->quan > 0 && objects[otmp->otyp].oc_merge) { otmp->quan = o->quan; otmp->owt = weight(otmp); } @@ -1913,7 +1921,8 @@ struct mkroom *croom; if (otmp->otyp == LUCKSTONE && Is_mineend_level(&u.uz)) { otmp->record_achieve_special = 1; } else if ((otmp->otyp == AMULET_OF_REFLECTION - || otmp->otyp == BAG_OF_HOLDING) && Is_sokoend_level(&u.uz)) { + || otmp->otyp == BAG_OF_HOLDING) + && Is_sokoend_level(&u.uz)) { otmp->record_achieve_special = 1; } @@ -1925,6 +1934,7 @@ struct mkroom *croom; if (o->buried) { boolean dealloced; + (void) bury_an_obj(otmp, &dealloced); if (dealloced && container_idx) { container_obj[container_idx - 1] = NULL; @@ -1935,7 +1945,6 @@ struct mkroom *croom; /* * Create an altar in a room. */ - STATIC_OVL void create_altar(a, croom) altar *a; @@ -1970,15 +1979,13 @@ struct mkroom *croom; * values to avoid conflicting with the rest of the encoding, * shared by many other parts of the special level code. */ - - amask = - (a->align == AM_SPLEV_CO) - ? Align2amask(u.ualignbase[A_ORIGINAL]) - : (a->align == AM_SPLEV_NONCO) + amask = (a->align == AM_SPLEV_CO) + ? Align2amask(u.ualignbase[A_ORIGINAL]) + : (a->align == AM_SPLEV_NONCO) ? Align2amask(noncoalignment(u.ualignbase[A_ORIGINAL])) : (a->align == -(MAX_REGISTERS + 1)) - ? induced_align(80) - : (a->align < 0 ? ralign[-a->align - 1] : a->align); + ? induced_align(80) + : (a->align < 0 ? ralign[-a->align - 1] : a->align); levl[x][y].typ = ALTAR; levl[x][y].altarmask = amask; @@ -2016,8 +2023,7 @@ struct mkroom *croom; for (x = max(x1, 0); x <= min(x2, COLNO - 1); x++) for (y = max(y1, 0); y <= min(y2, ROWNO - 1); y++) - if ((levl[x][y].typ == terr->fromter) - && (rn2(100) < terr->chance)) { + if (levl[x][y].typ == terr->fromter && rn2(100) < terr->chance) { SET_TYPLIT(x, y, terr->toter, terr->tolit); } } @@ -2025,7 +2031,6 @@ struct mkroom *croom; /* * Search for a door in a room on a specified wall. */ - STATIC_OVL boolean search_door(croom, x, y, wall, cnt) struct mkroom *croom; @@ -2082,16 +2087,15 @@ int cnt; /* * Dig a corridor between two points. */ - boolean dig_corridor(org, dest, nxcor, ftyp, btyp) coord *org, *dest; boolean nxcor; schar ftyp, btyp; { - register int dx = 0, dy = 0, dix, diy, cct; - register struct rm *crm; - register int tx, ty, xx, yy; + int dx = 0, dy = 0, dix, diy, cct; + struct rm *crm; + int tx, ty, xx, yy; xx = org->x; yy = org->y; @@ -2099,8 +2103,8 @@ schar ftyp, btyp; ty = dest->y; if (xx <= 0 || yy <= 0 || tx <= 0 || ty <= 0 || xx > COLNO - 1 || tx > COLNO - 1 || yy > ROWNO - 1 || ty > ROWNO - 1) { - debugpline4("dig_corridor: bad coords <%d,%d> <%d,%d>.", xx, yy, tx, - ty); + debugpline4("dig_corridor: bad coords <%d,%d> <%d,%d>.", + xx, yy, tx, ty); return FALSE; } if (tx > xx) @@ -2236,7 +2240,6 @@ fix_stair_rooms() * Basically we search for door coordinates or for endpoints coordinates * (from a distance). */ - STATIC_OVL void create_corridor(c) corridor *c; @@ -2292,7 +2295,6 @@ corridor *c; /* * Fill a room (shop, zoo, etc...) with appropriate stuff. */ - void fill_room(croom, prefilled) struct mkroom *croom; @@ -2315,8 +2317,8 @@ boolean prefilled; case VAULT: for (x = croom->lx; x <= croom->hx; x++) for (y = croom->ly; y <= croom->hy; y++) - (void) mkgold((long) rn1(abs(depth(&u.uz)) * 100, 51), x, - y); + (void) mkgold((long) rn1(abs(depth(&u.uz)) * 100, 51), + x, y); break; case COURT: case ZOO: @@ -2449,7 +2451,6 @@ int x1, y1, x2, y2; * We want a place not 'touched' by the loader. That is, a place in * the maze outside every part of the special level. */ - STATIC_OVL void maze1xy(m, humidity) coord *m; @@ -2581,6 +2582,7 @@ sp_lev *lvl; case SPOVAR_STRING: case SPOVAR_SEL: { char *opd; + Fread((genericptr_t) &nsize, 1, sizeof(nsize), fd); opd = (char *) alloc(nsize + 1); @@ -2588,7 +2590,8 @@ sp_lev *lvl; Fread(opd, 1, nsize, fd); opd[nsize] = 0; ov->vardata.str = opd; - } break; + break; + } default: panic("sp_level_loader: unknown opvar type %i", ov->spovartyp); @@ -2697,6 +2700,7 @@ spo_frame_push(coder) struct sp_coder *coder; { struct sp_frame *tmpframe = frame_new(coder->frame->n_opcode); + tmpframe->next = coder->frame; coder->frame = tmpframe; } @@ -2707,6 +2711,7 @@ struct sp_coder *coder; { if (coder->frame && coder->frame->next) { struct sp_frame *tmpframe = coder->frame->next; + frame_del(coder->frame); coder->frame = tmpframe; coder->stack = coder->frame->stack; @@ -2734,8 +2739,8 @@ struct sp_coder *coder; if (OV_i(params) < 0) return; - tmpframe = - frame_new(sp_code_jmpaddr(coder->frame->n_opcode, OV_i(addr) - 1)); + tmpframe = frame_new(sp_code_jmpaddr(coder->frame->n_opcode, + OV_i(addr) - 1)); while (OV_i(params)-- > 0) { splev_stack_push(tmpframe->stack, splev_stack_getdat_any(coder)); @@ -2807,9 +2812,9 @@ struct sp_coder *coder; { static const char nhFunc[] = "spo_message"; struct opvar *op; - char *msg, *levmsg; int old_n, n; + if (!OV_pop_s(op)) return; msg = OV_s(op); @@ -2838,7 +2843,6 @@ struct sp_coder *coder; { static const char nhFunc[] = "spo_monster"; int nparams = 0; - struct opvar *varparam; struct opvar *id, *mcoord, *has_inv; monster tmpmons; @@ -3023,6 +3027,7 @@ struct sp_coder *coder; if (OV_typ(parm) == SPOVAR_MONST) { char monclass = SP_MONST_CLASS(OV_i(parm)); int monid = SP_MONST_PM(OV_i(parm)); + if (monid >= 0 && monid < NUMMONS) { tmpobj.corpsenm = monid; break; /* we're done! */ @@ -3251,12 +3256,12 @@ spo_room(coder) struct sp_coder *coder; { static const char nhFunc[] = "spo_room"; + if (coder->n_subroom > MAX_NESTED_ROOMS) { panic("Too deeply nested rooms?!"); } else { struct opvar *rflags, *h, *w, *yalign, *xalign, *y, *x, *rlit, *chance, *rtype; - room tmproom; struct mkroom *tmpcr; @@ -3553,7 +3558,8 @@ struct opvar *s; { struct opvar *ov; int x, y; - ov = selection_opvar(NULL); + + ov = selection_opvar((char *) 0); if (!ov) return NULL; @@ -3573,7 +3579,7 @@ char oper; struct opvar *ov; int x, y; - ov = selection_opvar(NULL); + ov = selection_opvar((char *) 0); if (!ov) return NULL; @@ -3605,7 +3611,8 @@ struct opvar *mc; int x, y; schar mapc; xchar lit; - struct opvar *ret = selection_opvar(NULL); + struct opvar *ret = selection_opvar((char *) 0); + if (!ov || !mc || !ret) return NULL; mapc = SP_MAPCHAR_TYP(OV_i(mc)); @@ -3637,6 +3644,7 @@ struct opvar *ov; int percent; { int x, y; + if (!ov) return; for (x = 0; x < COLNO; x++) @@ -3730,17 +3738,16 @@ int dir; selection_setpoint(x, y, ov, 1); } -int (*selection_flood_check_func)(int, int) = NULL; +STATIC_VAR int FDECL((*selection_flood_check_func), (int, int)); +STATIC_VAR schar floodfill_checker_match_under_typ; void set_selection_floodfill_checker(f) -int (*f)(int, int); +int FDECL((*f), (int, int)); { selection_flood_check_func = f; } -static schar floodfill_checker_match_under_typ; - int floodfill_checker_match_under(x,y) int x,y; @@ -3749,8 +3756,8 @@ int x,y; } int -floodfill_checker_match_accessible(x,y) -int x,y; +floodfill_checker_match_accessible(x, y) +int x, y; { return (ACCESSIBLE(levl[x][y].typ) || levl[x][y].typ == SDOOR @@ -3764,7 +3771,7 @@ int x, y; boolean diagonals; { static const char nhFunc[] = "selection_floodfill"; - struct opvar *tmp = selection_opvar(NULL); + struct opvar *tmp = selection_opvar((char *) 0); #define SEL_FLOOD_STACK (COLNO * ROWNO) #define SEL_FLOOD(nx, ny) \ do { \ @@ -3784,6 +3791,7 @@ boolean diagonals; int idx = 0; xchar dx[SEL_FLOOD_STACK]; xchar dy[SEL_FLOOD_STACK]; + if (selection_flood_check_func == NULL) { opvar_free(tmp); return; @@ -3955,7 +3963,8 @@ long x, y, x2, y2, gtyp, mind, maxd, limit; selection_setpoint(dx, dy, ov, 1); } } - } break; + break; + } case SEL_GRADIENT_SQUARE: { for (dx = 0; dx < COLNO; dx++) for (dy = 0; dy < ROWNO; dy++) { @@ -3971,11 +3980,14 @@ long x, y, x2, y2, gtyp, mind, maxd, limit; selection_setpoint(dx, dy, ov, 1); } } - } break; - } + break; + } /*case*/ + } /*switch*/ } -void selection_do_line(x1, y1, x2, y2, ov) /* bresenham line algo */ +/* bresenham line algo */ +void +selection_do_line(x1, y1, x2, y2, ov) schar x1, y1, x2, y2; struct opvar *ov; { @@ -4077,6 +4089,7 @@ select_iter_func func; genericptr_t arg; { int x, y; + /* yes, this is very naive, but it's not _that_ expensive. */ for (x = 0; x < COLNO; x++) for (y = 0; y < ROWNO; y++) @@ -4090,7 +4103,8 @@ int x, y; genericptr_t arg; { terrain terr; - terr = (*(terrain *) arg); + + terr = *(terrain *) arg; SET_TYPLIT(x, y, terr.ter, terr.tlit); /* handle doors and secret doors */ if (levl[x][y].typ == SDOOR || IS_DOOR(levl[x][y].typ)) { @@ -4116,9 +4130,10 @@ sel_set_door(dx, dy, arg) int dx, dy; genericptr_t arg; { - xchar typ = (*(xchar *) arg); + xchar typ = *(xchar *) arg; xchar x = dx; xchar y = dy; + if (!IS_DOOR(levl[x][y].typ) && levl[x][y].typ != SDOOR) levl[x][y].typ = (typ & D_SECRET) ? SDOOR : DOOR; if (typ & D_SECRET) { @@ -4227,7 +4242,6 @@ struct sp_coder *coder; opvar_free(chance); } - boolean generate_way_out_method(nx,ny, ov) int nx,ny; @@ -4240,31 +4254,40 @@ struct opvar *ov; WAN_TELEPORTATION, SCR_TELEPORTATION, RIN_TELEPORTATION }; - struct opvar *ov2 = selection_opvar(NULL), *ov3; + struct opvar *ov2 = selection_opvar((char *) 0), *ov3; schar x, y; boolean res = TRUE; + selection_floodfill(ov2, nx, ny, TRUE); ov3 = opvar_clone(ov2); /* try to make a secret door */ while (selection_rndcoord(ov3, &x, &y, TRUE)) { - if (isok(x+1, y) && !selection_getpoint(x+1, y, ov) && IS_WALL(levl[x+1][y].typ) && - isok(x+2, y) && selection_getpoint(x+2, y, ov) && ACCESSIBLE(levl[x+2][y].typ)) { + if (isok(x+1, y) && !selection_getpoint(x+1, y, ov) + && IS_WALL(levl[x+1][y].typ) + && isok(x+2, y) && selection_getpoint(x+2, y, ov) + && ACCESSIBLE(levl[x+2][y].typ)) { levl[x+1][y].typ = SDOOR; goto gotitdone; } - if (isok(x-1, y) && !selection_getpoint(x-1, y, ov) && IS_WALL(levl[x-1][y].typ) && - isok(x-2, y) && selection_getpoint(x-2, y, ov) && ACCESSIBLE(levl[x-2][y].typ)) { + if (isok(x-1, y) && !selection_getpoint(x-1, y, ov) + && IS_WALL(levl[x-1][y].typ) + && isok(x-2, y) && selection_getpoint(x-2, y, ov) + && ACCESSIBLE(levl[x-2][y].typ)) { levl[x-1][y].typ = SDOOR; goto gotitdone; } - if (isok(x, y+1) && !selection_getpoint(x, y+1, ov) && IS_WALL(levl[x][y+1].typ) && - isok(x, y+2) && selection_getpoint(x, y+2, ov) && ACCESSIBLE(levl[x][y+2].typ)) { + if (isok(x, y+1) && !selection_getpoint(x, y+1, ov) + && IS_WALL(levl[x][y+1].typ) + && isok(x, y+2) && selection_getpoint(x, y+2, ov) + && ACCESSIBLE(levl[x][y+2].typ)) { levl[x][y+1].typ = SDOOR; goto gotitdone; } - if (isok(x, y-1) && !selection_getpoint(x, y-1, ov) && IS_WALL(levl[x][y-1].typ) && - isok(x, y-2) && selection_getpoint(x, y-2, ov) && ACCESSIBLE(levl[x][y-2].typ)) { + if (isok(x, y-1) && !selection_getpoint(x, y-1, ov) + && IS_WALL(levl[x][y-1].typ) + && isok(x, y-2) && selection_getpoint(x, y-2, ov) + && ACCESSIBLE(levl[x][y-2].typ)) { levl[x][y-1].typ = SDOOR; goto gotitdone; } @@ -4293,12 +4316,11 @@ struct opvar *ov; return res; } - void ensure_way_out() { static const char nhFunc[] = "ensure_way_out"; - struct opvar *ov = selection_opvar(NULL); + struct opvar *ov = selection_opvar((char *) 0); struct trap *ttmp = ftrap; int x,y; boolean ret = TRUE; @@ -4626,8 +4648,9 @@ struct sp_coder *coder; static const char nhFunc[] = "spo_wall_property"; struct opvar *r; xchar dx1, dy1, dx2, dy2; - int wprop = - (coder->opcode == SPO_NON_DIGGABLE) ? W_NONDIGGABLE : W_NONPASSWALL; + int wprop = (coder->opcode == SPO_NON_DIGGABLE) + ? W_NONDIGGABLE + : W_NONPASSWALL; if (!OV_pop_r(r)) return; @@ -4691,7 +4714,7 @@ struct sp_coder *coder; return; switch (OV_i(typ)) { default: - case 0: { + case 0: if (!OV_pop_r(r)) return; dx1 = (xchar) SP_REGION_X1(OV_i(r)); @@ -4701,12 +4724,12 @@ struct sp_coder *coder; wallify_map(dx1 < 0 ? xstart : dx1, dy1 < 0 ? ystart : dy1, dx2 < 0 ? xstart + xsize : dx2, dy2 < 0 ? ystart + ysize : dy2); - } break; - case 1: { + break; + case 1: if (!OV_pop_typ(r, SPOVAR_SEL)) return; selection_iterate(r, sel_set_wallify, NULL); - } break; + break; } opvar_free(r); } @@ -4876,6 +4899,7 @@ sp_lev *lvl; static const char nhFunc[] = "spo_jmp"; struct opvar *tmpa; long a; + if (!OV_pop_i(tmpa)) return; a = sp_code_jmpaddr(coder->frame->n_opcode, (OV_i(tmpa) - 1)); @@ -5210,8 +5234,10 @@ sp_lev *lvl; break; case SPO_POP: { struct opvar *ov = splev_stack_pop(coder->stack); + opvar_free(ov); - } break; + break; + } case SPO_PUSH: splev_stack_push(coder->stack, opvar_clone(coder->opdat)); break; @@ -5312,33 +5338,42 @@ sp_lev *lvl; break; case SPO_COPY: { struct opvar *a = splev_stack_pop(coder->stack); + splev_stack_push(coder->stack, opvar_clone(a)); splev_stack_push(coder->stack, opvar_clone(a)); opvar_free(a); - } break; + break; + } case SPO_DEC: { struct opvar *a; + if (!OV_pop_i(a)) break; OV_i(a)--; splev_stack_push(coder->stack, a); - } break; + break; + } case SPO_INC: { struct opvar *a; + if (!OV_pop_i(a)) break; OV_i(a)++; splev_stack_push(coder->stack, a); - } break; + break; + } case SPO_MATH_SIGN: { struct opvar *a; + if (!OV_pop_i(a)) break; OV_i(a) = ((OV_i(a) < 0) ? -1 : ((OV_i(a) > 0) ? 1 : 0)); splev_stack_push(coder->stack, a); - } break; + break; + } case SPO_MATH_ADD: { struct opvar *a, *b; + if (!OV_pop(b) || !OV_pop(a)) break; if (OV_typ(b) == OV_typ(a)) { @@ -5348,8 +5383,9 @@ sp_lev *lvl; opvar_free(b); } else if (OV_typ(a) == SPOVAR_STRING) { struct opvar *c; - char *tmpbuf = - (char *) alloc(strlen(OV_s(a)) + strlen(OV_s(b)) + 1); + char *tmpbuf = (char *) alloc(strlen(OV_s(a)) + + strlen(OV_s(b)) + 1); + (void) sprintf(tmpbuf, "%s%s", OV_s(a), OV_s(b)); c = opvar_new_str(tmpbuf); splev_stack_push(coder->stack, c); @@ -5366,25 +5402,31 @@ sp_lev *lvl; opvar_free(b); impossible("adding different types"); } - } break; + break; + } case SPO_MATH_SUB: { struct opvar *a, *b; + if (!OV_pop_i(b) || !OV_pop_i(a)) break; OV_i(a) = OV_i(a) - OV_i(b); splev_stack_push(coder->stack, a); opvar_free(b); - } break; + break; + } case SPO_MATH_MUL: { struct opvar *a, *b; + if (!OV_pop_i(b) || !OV_pop_i(a)) break; OV_i(a) = OV_i(a) * OV_i(b); splev_stack_push(coder->stack, a); opvar_free(b); - } break; + break; + } case SPO_MATH_DIV: { struct opvar *a, *b; + if (!OV_pop_i(b) || !OV_pop_i(a)) break; if (OV_i(b) >= 1) { @@ -5394,9 +5436,11 @@ sp_lev *lvl; } splev_stack_push(coder->stack, a); opvar_free(b); - } break; + break; + } case SPO_MATH_MOD: { struct opvar *a, *b; + if (!OV_pop_i(b) || !OV_pop_i(a)) break; if (OV_i(b) > 0) { @@ -5406,7 +5450,8 @@ sp_lev *lvl; } splev_stack_push(coder->stack, a); opvar_free(b); - } break; + break; + } case SPO_CMP: { struct opvar *a; struct opvar *b; @@ -5415,17 +5460,14 @@ sp_lev *lvl; OV_pop(b); OV_pop(a); - if (!a || !b) { impossible("spo_cmp: no values in stack"); break; } - if (OV_typ(a) != OV_typ(b)) { impossible("spo_cmp: trying to compare differing datatypes"); break; } - switch (OV_typ(a)) { case SPOVAR_COORD: case SPOVAR_REGION: @@ -5442,8 +5484,9 @@ sp_lev *lvl; c = opvar_new_int(val); break; case SPOVAR_STRING: - c = opvar_new_int( - ((!strcmp(OV_s(b), OV_s(a))) ? SP_CPUFLAG_EQ : 0)); + c = opvar_new_int(!strcmp(OV_s(b), OV_s(a)) + ? SP_CPUFLAG_EQ + : 0); break; default: c = opvar_new_int(0); @@ -5452,7 +5495,8 @@ sp_lev *lvl; splev_stack_push(coder->stack, c); opvar_free(a); opvar_free(b); - } break; + break; + } case SPO_JMP: spo_jmp(coder, lvl); break; @@ -5467,14 +5511,17 @@ sp_lev *lvl; case SPO_RN2: { struct opvar *tmpv; struct opvar *t; + if (!OV_pop_i(tmpv)) break; t = opvar_new_int((OV_i(tmpv) > 1) ? rn2(OV_i(tmpv)) : 0); splev_stack_push(coder->stack, t); opvar_free(tmpv); - } break; + break; + } case SPO_DICE: { struct opvar *a, *b, *t; + if (!OV_pop_i(b) || !OV_pop_i(a)) break; if (OV_i(b) < 1) @@ -5485,7 +5532,8 @@ sp_lev *lvl; splev_stack_push(coder->stack, t); opvar_free(a); opvar_free(b); - } break; + break; + } case SPO_MAP: spo_map(coder); break; @@ -5498,6 +5546,7 @@ sp_lev *lvl; case SPO_SEL_ADD: /* actually, logical or */ { struct opvar *sel1, *sel2, *pt; + if (!OV_pop_typ(sel1, SPOVAR_SEL)) panic("no sel1 for add"); if (!OV_pop_typ(sel2, SPOVAR_SEL)) @@ -5506,23 +5555,28 @@ sp_lev *lvl; opvar_free(sel1); opvar_free(sel2); splev_stack_push(coder->stack, pt); - } break; + break; + } case SPO_SEL_COMPLEMENT: { struct opvar *sel, *pt; + if (!OV_pop_typ(sel, SPOVAR_SEL)) panic("no sel for not"); pt = selection_not(sel); opvar_free(sel); splev_stack_push(coder->stack, pt); - } break; + break; + } case SPO_SEL_FILTER: /* sorta like logical and */ { struct opvar *filtertype; + if (!OV_pop_i(filtertype)) panic("no sel filter type"); switch (OV_i(filtertype)) { case SPOFILTER_PERCENT: { struct opvar *tmp1, *sel; + if (!OV_pop_i(tmp1)) panic("no sel filter percent"); if (!OV_pop_typ(sel, SPOVAR_SEL)) @@ -5530,10 +5584,12 @@ sp_lev *lvl; selection_filter_percent(sel, OV_i(tmp1)); splev_stack_push(coder->stack, sel); opvar_free(tmp1); - } break; + break; + } case SPOFILTER_SELECTION: /* logical and */ { struct opvar *pt, *sel1, *sel2; + if (!OV_pop_typ(sel1, SPOVAR_SEL)) panic("no sel filter sel1"); if (!OV_pop_typ(sel2, SPOVAR_SEL)) @@ -5542,9 +5598,11 @@ sp_lev *lvl; splev_stack_push(coder->stack, pt); opvar_free(sel1); opvar_free(sel2); - } break; + break; + } case SPOFILTER_MAPCHAR: { struct opvar *pt, *tmp1, *sel; + if (!OV_pop_typ(sel, SPOVAR_SEL)) panic("no sel filter"); if (!OV_pop_typ(tmp1, SPOVAR_MAPCHAR)) @@ -5553,27 +5611,32 @@ sp_lev *lvl; splev_stack_push(coder->stack, pt); opvar_free(tmp1); opvar_free(sel); - } break; + break; + } default: panic("unknown sel filter type"); } opvar_free(filtertype); - } break; + break; + } case SPO_SEL_POINT: { struct opvar *tmp; - struct opvar *pt = selection_opvar(NULL); + struct opvar *pt = selection_opvar((char *) 0); schar x, y; + if (!OV_pop_c(tmp)) panic("no ter sel coord"); get_location_coord(&x, &y, ANY_LOC, coder->croom, OV_i(tmp)); selection_setpoint(x, y, pt, 1); splev_stack_push(coder->stack, pt); opvar_free(tmp); - } break; + break; + } case SPO_SEL_RECT: case SPO_SEL_FILLRECT: { - struct opvar *tmp, *pt = selection_opvar(NULL); + struct opvar *tmp, *pt = selection_opvar((char *) 0); schar x, y, x1, y1, x2, y2; + if (!OV_pop_r(tmp)) panic("no ter sel region"); x1 = min(SP_REGION_X1(OV_i(tmp)), SP_REGION_X2(OV_i(tmp))); @@ -5602,11 +5665,13 @@ sp_lev *lvl; } splev_stack_push(coder->stack, pt); opvar_free(tmp); - } break; + break; + } case SPO_SEL_LINE: { struct opvar *tmp = NULL, *tmp2 = NULL, - *pt = selection_opvar(NULL); + *pt = selection_opvar((char *) 0); schar x1, y1, x2, y2; + if (!OV_pop_c(tmp)) panic("no ter sel linecoord1"); if (!OV_pop_c(tmp2)) @@ -5621,11 +5686,13 @@ sp_lev *lvl; splev_stack_push(coder->stack, pt); opvar_free(tmp); opvar_free(tmp2); - } break; + break; + } case SPO_SEL_RNDLINE: { struct opvar *tmp = NULL, *tmp2 = NULL, *tmp3, - *pt = selection_opvar(NULL); + *pt = selection_opvar((char *) 0); schar x1, y1, x2, y2; + if (!OV_pop_i(tmp3)) panic("no ter sel randline1"); if (!OV_pop_c(tmp)) @@ -5643,9 +5710,11 @@ sp_lev *lvl; opvar_free(tmp); opvar_free(tmp2); opvar_free(tmp3); - } break; + break; + } case SPO_SEL_GROW: { struct opvar *dirs, *pt; + if (!OV_pop_i(dirs)) panic("no dirs for grow"); if (!OV_pop_typ(pt, SPOVAR_SEL)) @@ -5653,25 +5722,30 @@ sp_lev *lvl; selection_do_grow(pt, OV_i(dirs)); splev_stack_push(coder->stack, pt); opvar_free(dirs); - } break; + break; + } case SPO_SEL_FLOOD: { struct opvar *tmp; schar x, y; + if (!OV_pop_c(tmp)) panic("no ter sel flood coord"); get_location_coord(&x, &y, ANY_LOC, coder->croom, OV_i(tmp)); if (isok(x, y)) { - struct opvar *pt = selection_opvar(NULL); + struct opvar *pt = selection_opvar((char *) 0); + set_selection_floodfill_checker(floodfill_checker_match_under); floodfill_checker_match_under_typ = levl[x][y].typ; selection_floodfill(pt, x, y, FALSE); splev_stack_push(coder->stack, pt); } opvar_free(tmp); - } break; + break; + } case SPO_SEL_RNDCOORD: { struct opvar *pt; schar x, y; + if (!OV_pop_typ(pt, SPOVAR_SEL)) panic("no selection for rndcoord"); if (selection_rndcoord(pt, &x, &y, FALSE)) { @@ -5680,11 +5754,13 @@ sp_lev *lvl; } splev_stack_push(coder->stack, opvar_new_coord(x, y)); opvar_free(pt); - } break; + break; + } case SPO_SEL_ELLIPSE: { struct opvar *filled, *xaxis, *yaxis, *pt; - struct opvar *sel = selection_opvar(NULL); + struct opvar *sel = selection_opvar((char *) 0); schar x, y; + if (!OV_pop_i(filled)) panic("no filled for ellipse"); if (!OV_pop_i(yaxis)) @@ -5701,11 +5777,13 @@ sp_lev *lvl; opvar_free(yaxis); opvar_free(xaxis); opvar_free(pt); - } break; + break; + } case SPO_SEL_GRADIENT: { struct opvar *gtyp, *glim, *mind, *maxd, *gcoord, *coord2; struct opvar *sel; schar x, y, x2, y2; + if (!OV_pop_i(gtyp)) panic("no gtyp for grad"); if (!OV_pop_i(glim)) @@ -5721,7 +5799,7 @@ sp_lev *lvl; get_location_coord(&x, &y, ANY_LOC, coder->croom, OV_i(gcoord)); get_location_coord(&x2, &y2, ANY_LOC, coder->croom, OV_i(coord2)); - sel = selection_opvar(NULL); + sel = selection_opvar((char *) 0); selection_do_gradient(sel, x, y, x2, y2, OV_i(gtyp), OV_i(mind), OV_i(maxd), OV_i(glim)); splev_stack_push(coder->stack, sel); @@ -5732,7 +5810,8 @@ sp_lev *lvl; opvar_free(coord2); opvar_free(maxd); opvar_free(mind); - } break; + break; + } default: panic("sp_level_coder: Unknown opcode %i", coder->opcode); } @@ -5778,7 +5857,6 @@ sp_lev *lvl; /* * General loader */ - boolean load_special(name) const char *name; diff --git a/src/spell.c b/src/spell.c index 2eaf74d86..c072bae7a 100644 --- a/src/spell.c +++ b/src/spell.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 spell.c $NHDT-Date: 1444295991 2015/10/08 09:19:51 $ $NHDT-Branch: master $:$NHDT-Revision: 1.64 $ */ +/* NetHack 3.6 spell.c $NHDT-Date: 1445906865 2015/10/27 00:47:45 $ $NHDT-Branch: master $:$NHDT-Revision: 1.66 $ */ /* Copyright (c) M. Stephenson 1988 */ /* NetHack may be freely redistributed. See license for details. */ @@ -49,8 +49,7 @@ STATIC_DCL const char *FDECL(spelltypemnemonic, (int)); * Reasoning: * spelbase, spelheal: * Arc are aware of magic through historical research - * Bar abhor magic (Conan finds it "interferes with his animal - *instincts") + * Bar abhor magic (Conan finds it "interferes with his animal instincts") * Cav are ignorant to magic * Hea are very aware of healing magic through medical research * Kni are moderately aware of healing from Paladin training @@ -343,19 +342,19 @@ learn(VOID_ARGS) multi_reason = "reading a book"; nomovemsg = 0; context.spbook.delay = 0; - return (0); + return 0; } if (context .spbook.delay) { /* not if (context.spbook.delay++), so at end delay == 0 */ context.spbook.delay++; - return (1); /* still busy */ + return 1; /* still busy */ } exercise(A_WIS, TRUE); /* you're studying. */ booktype = book->otyp; if (booktype == SPE_BOOK_OF_THE_DEAD) { deadbook(book); - return (0); + return 0; } Sprintf(splname, @@ -419,7 +418,7 @@ learn(VOID_ARGS) check_unpaid(book); context.spbook.book = 0; context.spbook.o_id = 0; - return (0); + return 0; } int @@ -453,20 +452,17 @@ register struct obj *spellbook; } if (context.spbook.delay && !confused && spellbook == context.spbook.book - && - /* handle the sequence: start reading, get interrupted, - have context.spbook.book become erased somehow, resume reading it - */ - booktype != SPE_BLANK_PAPER) { - You("continue your efforts to %s.", (booktype == SPE_NOVEL) - ? "read the novel" - : "memorize the spell"); + /* handle the sequence: start reading, get interrupted, have + context.spbook.book become erased somehow, resume reading it */ + && booktype != SPE_BLANK_PAPER) { + You("continue your efforts to %s.", + (booktype == SPE_NOVEL) ? "read the novel" : "memorize the spell"); } else { /* KMH -- Simplified this code */ if (booktype == SPE_BLANK_PAPER) { pline("This spellbook is all blank."); makeknown(booktype); - return (1); + return 1; } /* 3.6.0 tribute */ @@ -483,7 +479,7 @@ register struct obj *spellbook; u.uevent.read_tribute = 1; /* only once */ } } - return (1); + return 1; } switch (objects[booktype].oc_level) { @@ -529,7 +525,7 @@ register struct obj *spellbook; (read_ability < 12 ? "very " : "")); if (yn(qbuf) != 'y') { spellbook->in_use = FALSE; - return (1); + return 1; } } /* its up to random luck now */ @@ -555,7 +551,7 @@ register struct obj *spellbook; useup(spellbook); } else spellbook->in_use = FALSE; - return (1); + return 1; } else if (confused) { if (!confused_book(spellbook)) { spellbook->in_use = FALSE; @@ -564,7 +560,7 @@ register struct obj *spellbook; multi_reason = "reading a book"; nomovemsg = 0; context.spbook.delay = 0; - return (1); + return 1; } spellbook->in_use = FALSE; @@ -576,7 +572,7 @@ register struct obj *spellbook; if (context.spbook.book) context.spbook.o_id = context.spbook.book->o_id; set_occupation(learn, "studying", 0); - return (1); + return 1; } /* a spellbook has been destroyed or the character has changed levels; @@ -714,7 +710,7 @@ int spell_skilltype(booktype) int booktype; { - return (objects[booktype].oc_skill); + return objects[booktype].oc_skill; } STATIC_OVL void @@ -849,7 +845,7 @@ boolean atme; Your("knowledge of this spell is twisted."); pline("It invokes nightmarish images in your mind..."); spell_backfire(spell); - return (0); + return 0; } else if (spellknow(spell) <= KEEN / 200) { /* 100 turns left */ You("strain to recall the spell."); } else if (spellknow(spell) <= KEEN / 40) { /* 500 turns left */ @@ -863,16 +859,16 @@ boolean atme; if (u.uhunger <= 10 && spellid(spell) != SPE_DETECT_FOOD) { You("are too hungry to cast that spell."); - return (0); + return 0; } else if (ACURR(A_STR) < 4 && spellid(spell) != SPE_RESTORE_ABILITY) { You("lack the strength to cast spells."); - return (0); + return 0; } else if (check_capacity("Your concentration falters while carrying so " "much stuff.")) { - return (1); + return 1; } else if (!freehand()) { Your("arms are not free to cast!"); - return (0); + return 0; } if (u.uhave.amulet) { @@ -881,7 +877,7 @@ boolean atme; } if (energy > u.uen) { You("don't have enough energy to cast that spell."); - return (0); + return 0; } else { if (spellid(spell) != SPE_DETECT_FOOD) { int hungr = energy * 2; @@ -938,7 +934,7 @@ boolean atme; You("fail to cast the spell correctly."); u.uen -= energy / 2; context.botl = 1; - return (1); + return 1; } u.uen -= energy; @@ -948,10 +944,10 @@ boolean atme; pseudo = mksobj(spellid(spell), FALSE, FALSE); pseudo->blessed = pseudo->cursed = 0; pseudo->quan = 20L; /* do not let useup get it */ - /* - * Find the skill the hero has in a spell type category. - * See spell_skilltype for categories. - */ + /* + * Find the skill the hero has in a spell type category. + * See spell_skilltype for categories. + */ skill = spell_skilltype(pseudo->otyp); role_skill = P_SKILL(skill); @@ -978,11 +974,12 @@ boolean atme; losehp(damage, buf, NO_KILLER_PREFIX); } } else { - explode( - u.dx, u.dy, pseudo->otyp - SPE_MAGIC_MISSILE + 10, - spell_damage_bonus(u.ulevel / 2 + 1), 0, - (pseudo->otyp == SPE_CONE_OF_COLD) ? EXPL_FROSTY - : EXPL_FIERY); + explode(u.dx, u.dy, + pseudo->otyp - SPE_MAGIC_MISSILE + 10, + spell_damage_bonus(u.ulevel / 2 + 1), 0, + (pseudo->otyp == SPE_CONE_OF_COLD) + ? EXPL_FROSTY + : EXPL_FIERY); } u.dx = cc.x + rnd(3) - 2; u.dy = cc.y + rnd(3) - 2; @@ -1100,14 +1097,14 @@ boolean atme; default: impossible("Unknown spell %d attempted.", spell); obfree(pseudo, (struct obj *) 0); - return (0); + return 0; } /* gain skill for successful cast */ use_skill(skill, spellev(spell)); obfree(pseudo, (struct obj *) 0); /* now, get rid of it */ - return (1); + return 1; } /* Choose location where spell takes effect. */ diff --git a/src/steal.c b/src/steal.c index 53b276ad9..15b1cb649 100644 --- a/src/steal.c +++ b/src/steal.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 steal.c $NHDT-Date: 1437877184 2015/07/26 02:19:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.62 $ */ +/* NetHack 3.6 steal.c $NHDT-Date: 1445906866 2015/10/27 00:47:46 $ $NHDT-Branch: master $:$NHDT-Revision: 1.64 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -253,7 +253,7 @@ char *objnambuf; *objnambuf = '\0'; /* the following is true if successful on first of two attacks. */ if (!monnear(mtmp, u.ux, u.uy)) - return (0); + return 0; /* food being eaten might already be used up but will not have been removed from inventory yet; we don't want to steal that, @@ -269,7 +269,7 @@ char *objnambuf; else pline("%s tries to rob you, but there is nothing to steal!", Monnam(mtmp)); - return (1); /* let her flee */ + return 1; /* let her flee */ } monkey_business = is_animal(mtmp->data); @@ -301,7 +301,7 @@ retry: } if (!otmp) { impossible("Steal fails!"); - return (0); + return 0; } /* can't steal ring(s) while wearing gloves */ if ((otmp == uleft || otmp == uright) && uarmg) @@ -320,7 +320,7 @@ retry: gotobj: if (otmp->o_id == stealoid) - return (0); + return 0; if (otmp->otyp == BOULDER && !throws_rocks(mtmp->data)) { if (!retrycnt++) @@ -337,10 +337,10 @@ gotobj: else if (otmp == uquiver || (otmp == uswapwep && !u.twoweap)) ostuck = FALSE; /* not really worn; curse doesn't matter */ else - ostuck = ((otmp->cursed && otmp->owornmask) || + ostuck = ((otmp->cursed && otmp->owornmask) /* nymphs can steal rings from under cursed weapon but animals can't */ - (otmp == uright && welded(uwep)) + || (otmp == uright && welded(uwep)) || (otmp == uleft && welded(uwep) && bimanual(uwep))); if (ostuck || can_carry(mtmp, otmp) == 0) { @@ -433,7 +433,7 @@ gotobj: stealoid = otmp->o_id; stealmid = mtmp->m_id; afternmv = stealarm; - return (0); + return 0; } } break; @@ -463,7 +463,7 @@ gotobj: minstapetrify(mtmp, TRUE); return -1; } - return ((multi < 0) ? 0 : 1); + return (multi < 0) ? 0 : 1; } /* Returns 1 if otmp is free'd, 0 otherwise. */ @@ -617,11 +617,10 @@ boolean verbosely; /* don't charge for an owned saddle on dead steed (provided that the hero is within the same shop at the time) */ } else if (mon->mtame && (obj->owornmask & W_SADDLE) && !obj->unpaid - && costly_spot(omx, omy) && - /* being at a costly_spot guarantees lev->roomno is not 0 - */ - index(in_rooms(u.ux, u.uy, SHOPBASE), - levl[omx][omy].roomno)) { + && costly_spot(omx, omy) + /* being at costly_spot guarantees lev->roomno is not 0 */ + && index(in_rooms(u.ux, u.uy, SHOPBASE), + levl[omx][omy].roomno)) { obj->no_charge = 1; } /* this should be done even if the monster has died */ diff --git a/src/steed.c b/src/steed.c index ed0c15d8c..1129a27cc 100644 --- a/src/steed.c +++ b/src/steed.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 steed.c $NHDT-Date: 1432512766 2015/05/25 00:12:46 $ $NHDT-Branch: master $:$NHDT-Revision: 1.45 $ */ +/* NetHack 3.6 steed.c $NHDT-Date: 1445906867 2015/10/27 00:47:47 $ $NHDT-Branch: master $:$NHDT-Revision: 1.47 $ */ /* Copyright (c) Kevin Hugo, 1998-1999. */ /* NetHack may be freely redistributed. See license for details. */ @@ -676,9 +676,9 @@ place_monster(mon, x, y) struct monst *mon; int x, y; { - if (mon == u.usteed || + if (mon == u.usteed /* special case is for convoluted vault guard handling */ - (DEADMONSTER(mon) && !(mon->isgd && x == 0 && y == 0))) { + || (DEADMONSTER(mon) && !(mon->isgd && x == 0 && y == 0))) { impossible("placing %s onto map?", (mon == u.usteed) ? "steed" : "defunct monster"); return;