From: PatR Date: Sat, 7 Nov 2015 10:35:22 +0000 (-0800) Subject: formatting: more (typedef) (expression) X-Git-Tag: NetHack-3.6.0_RC01~74 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eaec3fee7537a016dc87213693096c1b5239b067;p=nethack formatting: more (typedef) (expression) --- diff --git a/src/mkobj.c b/src/mkobj.c index f211c255c..bfc5b6cee 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mkobj.c $NHDT-Date: 1445215021 2015/10/19 00:37:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.111 $ */ +/* NetHack 3.6 mkobj.c $NHDT-Date: 1446892448 2015/11/07 10:34:08 $ $NHDT-Branch: master $:$NHDT-Revision: 1.112 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -6,8 +6,8 @@ STATIC_DCL void FDECL(mkbox_cnts, (struct obj *)); STATIC_DCL void FDECL(maybe_adjust_light, (struct obj *, int)); -STATIC_DCL void FDECL(obj_timer_checks, - (struct obj *, XCHAR_P, XCHAR_P, int)); +STATIC_DCL void FDECL(obj_timer_checks, (struct obj *, + XCHAR_P, XCHAR_P, int)); STATIC_DCL void FDECL(container_weight, (struct obj *)); STATIC_DCL struct obj *FDECL(save_mtraits, (struct obj *, struct monst *)); STATIC_DCL void FDECL(objlist_sanity, (struct obj *, int, const char *)); @@ -104,8 +104,8 @@ struct obj *otmp; if (!otmp->oextra) otmp->oextra = newoextra(); if (!OMONST(otmp)) { - OMONST(otmp) = (struct monst *) alloc(sizeof(struct monst)); - (void) memset((genericptr_t) OMONST(otmp), 0, sizeof(struct monst)); + OMONST(otmp) = (struct monst *) alloc(sizeof (struct monst)); + (void) memset((genericptr_t) OMONST(otmp), 0, sizeof (struct monst)); } } @@ -126,8 +126,8 @@ struct obj *otmp; if (!otmp->oextra) otmp->oextra = newoextra(); if (!OMID(otmp)) { - OMID(otmp) = (unsigned *) alloc(sizeof(unsigned)); - (void) memset((genericptr_t) OMID(otmp), 0, sizeof(unsigned)); + OMID(otmp) = (unsigned *) alloc(sizeof (unsigned)); + (void) memset((genericptr_t) OMID(otmp), 0, sizeof (unsigned)); } } @@ -148,8 +148,8 @@ struct obj *otmp; if (!otmp->oextra) otmp->oextra = newoextra(); if (!OLONG(otmp)) { - OLONG(otmp) = (long *) alloc(sizeof(long)); - (void) memset((genericptr_t) OLONG(otmp), 0, sizeof(long)); + OLONG(otmp) = (long *) alloc(sizeof (long)); + (void) memset((genericptr_t) OLONG(otmp), 0, sizeof (long)); } } @@ -195,7 +195,7 @@ boolean artif; otmp = mkobj(let, artif); place_object(otmp, x, y); - return (otmp); + return otmp; } struct obj * @@ -207,7 +207,7 @@ boolean init, artif; otmp = mksobj(otyp, init, artif); place_object(otmp, x, y); - return (otmp); + return otmp; } struct obj * @@ -218,11 +218,10 @@ boolean artif; int tprob, i, prob = rnd(1000); if (oclass == RANDOM_CLASS) { - const struct icp *iprobs = - (Is_rogue_level(&u.uz)) - ? (const struct icp *) rogueprobs - : Inhell ? (const struct icp *) hellprobs - : (const struct icp *) mkobjprobs; + const struct icp *iprobs = Is_rogue_level(&u.uz) + ? (const struct icp *) rogueprobs + : Inhell ? (const struct icp *) hellprobs + : (const struct icp *) mkobjprobs; for (tprob = rnd(100); (tprob -= iprobs->iprob) > 0; iprobs++) ; @@ -236,7 +235,7 @@ boolean artif; if (objects[i].oc_class != oclass || !OBJ_NAME(objects[i])) panic("probtype error, oclass=%d i=%d", (int) oclass, i); - return (mksobj(i, TRUE, artif)); + return mksobj(i, TRUE, artif); } STATIC_OVL void @@ -321,7 +320,9 @@ struct obj *box; } } -int rndmonnum() /* select a random, common monster type */ +/* select a random, common monster type */ +int +rndmonnum() { register struct permonst *ptr; register int i; @@ -330,7 +331,7 @@ int rndmonnum() /* select a random, common monster type */ /* Plan A: get a level-appropriate common monster */ ptr = rndmonst(); if (ptr) - return (monsndx(ptr)); + return monsndx(ptr); /* Plan B: get any common monster */ excludeflags = G_UNIQ | G_NOGEN | (Inhell ? G_NOHELL : G_HELL); @@ -339,7 +340,7 @@ int rndmonnum() /* select a random, common monster type */ ptr = &mons[i]; } while ((ptr->geno & excludeflags) != 0); - return (i); + return i; } void @@ -1031,7 +1032,7 @@ boolean artif; if (objects[otyp].oc_unique && !otmp->oartifact) otmp = mk_artifact(otmp, (aligntyp) A_NONE); otmp->owt = weight(otmp); - return (otmp); + return otmp; } /* @@ -1184,9 +1185,9 @@ int old_range; } /* - * bless(), curse(), unbless(), uncurse() -- any relevant message - * about glowing amber/black/&c should be delivered prior to calling - * these routines to make the actual curse/bless state change. + * bless(), curse(), unbless(), uncurse() -- any relevant message + * about glowing amber/black/&c should be delivered prior to calling + * these routines to make the actual curse/bless state change. */ void @@ -1313,8 +1314,8 @@ register struct obj *otmp; * and calculate the weight of any containers. * * Note: It is possible to end up with an incorrect weight if some part - * of the code messes with a contained object and doesn't update the - * container's weight. + * of the code messes with a contained object and doesn't update the + * container's weight. */ int weight(obj) @@ -1338,11 +1339,11 @@ register struct obj *obj; * of the bag plus the weight of the bag's contents modified * as follows: * - * Bag status Weight of contents - * ---------- ------------------ - * cursed 2x - * blessed x/4 [rounded up: (x+3)/4] - * otherwise x/2 [rounded up: (x+1)/2] + * Bag status Weight of contents + * ---------- ------------------ + * cursed 2x + * blessed x/4 [rounded up: (x+3)/4] + * otherwise x/2 [rounded up: (x+1)/2] * * The macro DELTA_CWT in pickup.c also implements these * weight equations. @@ -1362,10 +1363,11 @@ register struct obj *obj; return wt; } else if (obj->oclass == FOOD_CLASS && obj->oeaten) { return eaten_stat((int) obj->quan * wt, obj); - } else if (obj->oclass == COIN_CLASS) + } else if (obj->oclass == COIN_CLASS) { return (int) ((obj->quan + 50L) / 100L); - else if (obj->otyp == HEAVY_IRON_BALL && obj->owt != 0) - return ((int) (obj->owt)); /* kludge for "very" heavy iron ball */ + } else if (obj->otyp == HEAVY_IRON_BALL && obj->owt != 0) { + return (int) obj->owt; /* kludge for "very" heavy iron ball */ + } return (wt ? wt * (int) obj->quan : ((int) obj->quan + 1) >> 1); } @@ -1394,7 +1396,7 @@ int x, y; gold->quan = amount; } gold->owt = weight(gold); - return (gold); + return gold; } /* return TRUE if the corpse has special timing */ @@ -1407,7 +1409,7 @@ int x, y; * even if ptr passed as well, but ptr is always used for * the corpse type (corpsenm). That allows the corpse type * to be different from the original monster, - * i.e. vampire -> human corpse + * i.e. vampire -> human corpse * yet still allow restoration of the original monster upon * resurrection. */ @@ -1455,7 +1457,7 @@ unsigned corpstatflags; } } } - return (otmp); + return otmp; } /* @@ -1569,7 +1571,7 @@ register int x, y; if ((otmp2 = tt_oname(otmp)) != 0) otmp = otmp2; } - return (otmp); + return otmp; } /* make a new corpse or statue, uninitialized if a statue (i.e. no books) */ @@ -1587,7 +1589,7 @@ const char *nm; otmp = mkcorpstat(objtype, (struct monst *) 0, ptr, x, y, corpstatflags); if (nm) otmp = oname(otmp, nm); - return (otmp); + return otmp; } boolean @@ -1607,7 +1609,7 @@ register struct obj *otmp; if (objects[otyp].oc_oprop == FIRE_RES || otyp == WAN_FIRE) return FALSE; - return ((boolean)((omat <= WOOD && omat != LIQUID) || omat == PLASTIC)); + return (boolean) ((omat <= WOOD && omat != LIQUID) || omat == PLASTIC); } boolean @@ -1616,8 +1618,8 @@ register struct obj *otmp; { int otyp = otmp->otyp; - return ((boolean)(objects[otyp].oc_material <= WOOD - && objects[otyp].oc_material != LIQUID)); + return (boolean) (objects[otyp].oc_material <= WOOD + && objects[otyp].oc_material != LIQUID); } /* @@ -1751,9 +1753,9 @@ int force; /* 0 = no force so do checks, <0 = force off, >0 force on */ age = monstermoves - otmp->age; otmp->age = monstermoves - (age * ROT_ICE_ADJUSTMENT); } - } + /* Check for corpses coming off ice */ - else if ((force < 0) || (otmp->otyp == CORPSE && otmp->on_ice + } else if (force < 0 || (otmp->otyp == CORPSE && otmp->on_ice && !((on_floor || buried) && is_ice(x, y)))) { tleft = stop_timer(action, obj_to_any(otmp)); if (tleft == 0L) { @@ -1774,6 +1776,7 @@ int force; /* 0 = no force so do checks, <0 = force off, >0 force on */ otmp->age += age * (ROT_ICE_ADJUSTMENT - 1) / ROT_ICE_ADJUSTMENT; } } + /* now re-start the timer with the appropriate modifications */ if (restart_timer) (void) start_timer(tleft, TIMER_OBJECT, action, obj_to_any(otmp)); @@ -1829,14 +1832,14 @@ struct monst *mtmp; * Doesn't handle unwearing of objects in hero's or monsters' inventories. * * Object positions: - * OBJ_FREE not on any list - * OBJ_FLOOR fobj, level.locations[][] chains (use remove_object) - * OBJ_CONTAINED cobj chain of container object - * OBJ_INVENT hero's invent chain (use freeinv) - * OBJ_MINVENT monster's invent chain - * OBJ_MIGRATING migrating chain - * OBJ_BURIED level.buriedobjs chain - * OBJ_ONBILL on billobjs chain + * OBJ_FREE not on any list + * OBJ_FLOOR fobj, level.locations[][] chains (use remove_object) + * OBJ_CONTAINED cobj chain of container object + * OBJ_INVENT hero's invent chain (use freeinv) + * OBJ_MINVENT monster's invent chain + * OBJ_MIGRATING migrating chain + * OBJ_BURIED level.buriedobjs chain + * OBJ_ONBILL on billobjs chain */ void obj_extract_self(obj) @@ -1967,13 +1970,13 @@ struct obj *container, *obj; /* merge if possible */ for (otmp = container->cobj; otmp; otmp = otmp->nobj) if (merged(&otmp, &obj)) - return (otmp); + return otmp; obj->where = OBJ_CONTAINED; obj->ocontainer = container; obj->nobj = container->cobj; container->cobj = obj; - return (obj); + return obj; } void @@ -2561,7 +2564,7 @@ struct obj * obj_nexto(otmp) struct obj *otmp; { - struct obj *otmp2 = NULL; + struct obj *otmp2 = (struct obj *) 0; if (otmp) { otmp2 = obj_nexto_xy(otmp->otyp, otmp->ox, otmp->oy, otmp->o_id); @@ -2615,7 +2618,7 @@ unsigned oid; } } } - return NULL; + return (struct obj *) 0; } /* @@ -2627,7 +2630,7 @@ struct obj * obj_absorb(obj1, obj2) struct obj **obj1, **obj2; { - struct obj *otmp1 = NULL, *otmp2 = NULL; + struct obj *otmp1 = (struct obj *) 0, *otmp2 = (struct obj *) 0; int extrawt = 0; /* don't let people dumb it up */ @@ -2642,13 +2645,13 @@ struct obj **obj1, **obj2; obj_extract_self(otmp2); newsym(otmp2->ox, otmp2->oy); /* in case of floor */ dealloc_obj(otmp2); - *obj2 = NULL; + *obj2 = (struct obj *) 0; return otmp1; } } impossible("obj_absorb: not called with two actual objects"); - return NULL; + return (struct obj *) 0; } /* @@ -2660,7 +2663,7 @@ struct obj * obj_meld(obj1, obj2) struct obj **obj1, **obj2; { - struct obj *otmp1 = NULL, *otmp2 = NULL; + struct obj *otmp1 = (struct obj *) 0, *otmp2 = (struct obj *) 0; if (obj1 && obj2) { otmp1 = *obj1; @@ -2674,7 +2677,7 @@ struct obj **obj1, **obj2; } impossible("obj_meld: not called with two actual objects"); - return NULL; + return (struct obj *) 0; } /*mkobj.c*/ diff --git a/src/o_init.c b/src/o_init.c index e31484caf..17f49b8ba 100644 --- a/src/o_init.c +++ b/src/o_init.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 o_init.c $NHDT-Date: 1432512767 2015/05/25 00:12:47 $ $NHDT-Branch: master $:$NHDT-Revision: 1.18 $ */ +/* NetHack 3.6 o_init.c $NHDT-Date: 1446892449 2015/11/07 10:34:09 $ $NHDT-Branch: master $:$NHDT-Revision: 1.20 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -279,7 +279,9 @@ find_skates() return -1; /* not 0, or caller would try again each move */ } -void oinit() /* level dependent initialization */ +/* level dependent initialization */ +void +oinit() { setgemprobs(&u.uz); } @@ -395,9 +397,9 @@ interesting_to_discover(i) register int i; { /* Pre-discovered objects are now printed with a '*' */ - return ((boolean)(objects[i].oc_uname != (char *) 0 + return (boolean) (objects[i].oc_uname != (char *) 0 || (objects[i].oc_name_known - && OBJ_DESCR(objects[i]) != (char *) 0))); + && OBJ_DESCR(objects[i]) != (char *) 0)); } /* items that should stand out once they're known */ @@ -407,7 +409,8 @@ static short uniq_objs[] = { }; /* the '\' command - show discovered object types */ -int dodiscovered() /* free after Robert Viduya */ +int +dodiscovered() /* free after Robert Viduya */ { register int i, dis; int ct = 0; @@ -485,12 +488,11 @@ char *buf; int doclassdisco() { - static NEARDATA const char prompt[] = - "View discoveries for which sort of objects?", - havent_discovered_any[] = - "haven't discovered any %s yet.", - unique_items[] = "unique items", - artifact_items[] = "artifacts"; + static NEARDATA const char + prompt[] = "View discoveries for which sort of objects?", + havent_discovered_any[] = "haven't discovered any %s yet.", + unique_items[] = "unique items", + artifact_items[] = "artifacts"; char *s, c, oclass, menulet, allclasses[MAXOCLASSES], discosyms[2 + MAXOCLASSES + 1], buf[BUFSZ]; int i, ct, dis, xtras; diff --git a/src/objnam.c b/src/objnam.c index 16649b375..3a1a66acb 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 objnam.c $NHDT-Date: 1446634657 2015/11/04 10:57:37 $ $NHDT-Branch: master $:$NHDT-Revision: 1.151 $ */ +/* NetHack 3.6 objnam.c $NHDT-Date: 1446892450 2015/11/07 10:34:10 $ $NHDT-Branch: master $:$NHDT-Revision: 1.153 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -3652,7 +3652,7 @@ const char *lastR; if (qsuffix && len < lenlimit) { (void) strncpy(&qbuf[len], qsuffix, lenlimit - len); *endp = '\0'; - /* len = (unsigned)strlen(qbuf); */ + /* len = (unsigned) strlen(qbuf); */ } } } else { diff --git a/src/pager.c b/src/pager.c index 6cc8b3e76..ba34d2974 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 pager.c $NHDT-Date: 1445556880 2015/10/22 23:34:40 $ $NHDT-Branch: master $:$NHDT-Revision: 1.82 $ */ +/* NetHack 3.6 pager.c $NHDT-Date: 1446892451 2015/11/07 10:34:11 $ $NHDT-Branch: master $:$NHDT-Revision: 1.83 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -256,7 +256,7 @@ lookat(x, y, buf, monbuf) int x, y; char *buf, *monbuf; { - register struct monst *mtmp = (struct monst *) 0; + struct monst *mtmp = (struct monst *) 0; struct permonst *pm = (struct permonst *) 0; int glyph; @@ -356,7 +356,7 @@ char *buf, *monbuf; break; } - return ((pm && !Hallucination) ? pm : (struct permonst *) 0); + return (pm && !Hallucination) ? pm : (struct permonst *) 0; } /* @@ -365,9 +365,9 @@ char *buf, *monbuf; * with a character/glyph and flags.help is TRUE. * * NOTE: when (user_typed_name == FALSE), inp is considered read-only and - * must not be changed directly, e.g. via lcase(). We want to force - * lcase() for data.base lookup so that we can have a clean key. - * Therefore, we create a copy of inp _just_ for data.base lookup. + * must not be changed directly, e.g. via lcase(). We want to force + * lcase() for data.base lookup so that we can have a clean key. + * Therefore, we create a copy of inp _just_ for data.base lookup. */ STATIC_OVL void checkfile(inp, pm, user_typed_name, without_asking) @@ -581,7 +581,7 @@ const char **firstmatch; * "the interior of a monster". */ if (u.uswallow && looked - && (is_swallow_sym(sym) || (int)showsyms[S_stone] == sym)) { + && (is_swallow_sym(sym) || (int) showsyms[S_stone] == sym)) { if (!found) { Sprintf(out_str, "%s%s", prefix, mon_interior); *firstmatch = mon_interior; @@ -960,7 +960,7 @@ coord *click_cc; char temp_buf[BUFSZ]; Strcpy(temp_buf, firstmatch); checkfile(temp_buf, pm, FALSE, - (boolean)(ans == LOOK_VERBOSE)); + (boolean) (ans == LOOK_VERBOSE)); } } else { pline("I've never heard of such things."); diff --git a/src/priest.c b/src/priest.c index b1a81e367..f17f431e3 100644 --- a/src/priest.c +++ b/src/priest.c @@ -1,5 +1,5 @@ -/* NetHack 3.6 priest.c $NHDT-Date: 1445556883 2015/10/22 23:34:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.40 $ */ -/* Copyright (c) Izchak Miller, Steve Linhart, 1989. */ +/* NetHack 3.6 priest.c $NHDT-Date: 1446892452 2015/11/07 10:34:12 $ $NHDT-Branch: master $:$NHDT-Revision: 1.41 $ */ +/* Copyright (c) Izchak Miller, Steve Linhart, 1989. */ /* NetHack may be freely redistributed. See license for details. */ #include "hack.h" @@ -233,7 +233,7 @@ boolean sanctum; /* is it the seat of the high priest? */ priest = makemon(&mons[sanctum ? PM_HIGH_PRIEST : PM_ALIGNED_PRIEST], sx + 1, sy, MM_EPRI); if (priest) { - EPRI(priest)->shroom = (schar)((sroom - rooms) + ROOMOFFSET); + EPRI(priest)->shroom = (schar) ((sroom - rooms) + ROOMOFFSET); EPRI(priest)->shralign = Amask2align(levl[sx][sy].altarmask); EPRI(priest)->shrpos.x = sx; EPRI(priest)->shrpos.y = sy; @@ -280,13 +280,13 @@ struct monst *mon; /* * Specially aligned monsters are named specially. - * - aligned priests with ispriest and high priests have shrines - * they retain ispriest and epri when polymorphed - * - aligned priests without ispriest are roamers - * they have isminion set and use emin rather than epri - * - minions do not have ispriest but have isminion and emin - * - caller needs to inhibit Hallucination if it wants to force - * the true name even when under that influence + * - aligned priests with ispriest and high priests have shrines + * they retain ispriest and epri when polymorphed + * - aligned priests without ispriest are roamers + * they have isminion set and use emin rather than epri + * - minions do not have ispriest but have isminion and emin + * - caller needs to inhibit Hallucination if it wants to force + * the true name even when under that influence */ char * priestname(mon, pname) @@ -565,7 +565,7 @@ register struct monst *priest; if (priest->mpeaceful && *in_rooms(priest->mx, priest->my, TEMPLE) && !has_shrine(priest)) { verbalize( - "Begone! Thou desecratest this holy place with thy presence."); + "Begone! Thou desecratest this holy place with thy presence."); priest->mpeaceful = 0; return; } @@ -593,11 +593,11 @@ register struct monst *priest; if (coaligned) adjalign(-1); } else if (offer < (u.ulevel * 200)) { - if (money_cnt(invent) > (offer * 2L)) + if (money_cnt(invent) > (offer * 2L)) { verbalize("Cheapskate."); - else { + } else { verbalize("I thank thee for thy contribution."); - /* give player some token */ + /* give player some token */ exercise(A_WIS, TRUE); } } else if (offer < (u.ulevel * 400)) { @@ -648,15 +648,15 @@ boolean peaceful; register boolean coaligned = (u.ualign.type == alignment); #if 0 /* this was due to permonst's pxlth field which is now gone */ - if (ptr != &mons[PM_ALIGNED_PRIEST] && ptr != &mons[PM_ANGEL]) - return((struct monst *)0); + if (ptr != &mons[PM_ALIGNED_PRIEST] && ptr != &mons[PM_ANGEL]) + return (struct monst *) 0; #endif if (MON_AT(x, y)) (void) rloc(m_at(x, y), FALSE); /* insurance */ if (!(roamer = makemon(ptr, x, y, MM_ADJACENTOK | MM_EMIN))) - return ((struct monst *) 0); + return (struct monst *) 0; EMIN(roamer)->min_align = alignment; EMIN(roamer)->renegade = (coaligned && !peaceful); @@ -712,7 +712,9 @@ xchar x, y; && priest->mpeaceful); } -void ghod_hitsu(priest) /* when attacking "priest" in his temple */ +/* when attacking "priest" in his temple */ +void +ghod_hitsu(priest) struct monst *priest; { int x, y, ax, ay, roomno = (int) temple_occupied(u.urooms); @@ -798,8 +800,8 @@ angry_priest() * If the altar has been destroyed or converted, let the * priest run loose. * (When it's just a conversion and there happens to be - * a fresh corpse nearby, the priest ought to have an - * opportunity to try converting it back; maybe someday...) + * a fresh corpse nearby, the priest ought to have an + * opportunity to try converting it back; maybe someday...) */ lev = &levl[eprip->shrpos.x][eprip->shrpos.y]; if (!IS_ALTAR(lev->typ) diff --git a/src/questpgr.c b/src/questpgr.c index cf331967a..cf13f30b0 100644 --- a/src/questpgr.c +++ b/src/questpgr.c @@ -1,5 +1,5 @@ -/* NetHack 3.6 questpgr.c $NHDT-Date: 1436515198 2015/07/10 07:59:58 $ $NHDT-Branch: master $:$NHDT-Revision: 1.33 $ */ -/* Copyright 1991, M. Stephenson */ +/* NetHack 3.6 questpgr.c $NHDT-Date: 1446892453 2015/11/07 10:34:13 $ $NHDT-Branch: master $:$NHDT-Revision: 1.34 $ */ +/* Copyright 1991, M. Stephenson */ /* NetHack may be freely redistributed. See license for details. */ #include "hack.h" @@ -39,8 +39,11 @@ static dlb *msg_file; /* used by ldrname() and neminame(), then copied into cvt_buf */ static char nambuf[sizeof cvt_buf]; +/* dump the character msg list to check appearance; + build with DEBUG enabled and use DEBUGFILES=questpgr.c + in sysconf file or environment */ static void -dump_qtlist() /* dump the character msg list to check appearance */ +dump_qtlist() { #ifdef DEBUG struct qtmsg *msg; @@ -52,7 +55,7 @@ dump_qtlist() /* dump the character msg list to check appearance */ (void) dlb_fseek(msg_file, msg->offset, SEEK_SET); deliver_by_window(msg, NHW_MAP); } -#endif /* !DEBUG */ +#endif /* DEBUG */ return; } @@ -89,7 +92,7 @@ long hdr_offset; msg_file); msg_list[n_msgs].msgnum = -1; - return (msg_list); + return msg_list; } void @@ -155,21 +158,22 @@ int typ; { switch (typ) { case 0: - return (urole.questarti); + return urole.questarti; case MS_LEADER: - return (urole.ldrnum); + return urole.ldrnum; case MS_NEMESIS: - return (urole.neminum); + return urole.neminum; case MS_GUARDIAN: - return (urole.guardnum); + return urole.guardnum; default: impossible("quest_info(%d)", typ); } return 0; } +/* return your role leader's name */ const char * -ldrname() /* return your role leader's name */ +ldrname() { int i = urole.ldrnum; @@ -178,21 +182,23 @@ ldrname() /* return your role leader's name */ return nambuf; } +/* return your intermediate target string */ STATIC_OVL const char * -intermed() /* return your intermediate target string */ +intermed() { - return (urole.intermed); + return urole.intermed; } boolean is_quest_artifact(otmp) struct obj *otmp; { - return ((boolean)(otmp->oartifact == urole.questarti)); + return (boolean) (otmp->oartifact == urole.questarti); } +/* return your role nemesis' name */ STATIC_OVL const char * -neminame() /* return your role nemesis' name */ +neminame() { int i = urole.neminum; @@ -206,13 +212,13 @@ guardname() /* return your role leader's guard monster name */ { int i = urole.guardnum; - return (mons[i].mname); + return mons[i].mname; } STATIC_OVL const char * homebase() /* return your role leader's location */ { - return (urole.homebase); + return urole.homebase; } /* replace deity, leader, nemesis, or artifact name with pronoun; @@ -263,9 +269,9 @@ int msgnum; for (qt_msg = qtm_list; qt_msg->msgnum > 0; qt_msg++) if (qt_msg->msgnum == msgnum) - return (qt_msg); + return qt_msg; - return ((struct qtmsg *) 0); + return (struct qtmsg *) 0; } STATIC_OVL void @@ -480,6 +486,7 @@ int how; #ifdef DEBUG if (qtdump) { char buf[BUFSZ]; + /* when dumping quest messages at startup, all of them are passed to * deliver_by_window(), even if normally given to deliver_by_pline() */ @@ -577,13 +584,13 @@ qt_montype() if (rn2(5)) { qpm = urole.enemy1num; if (qpm != NON_PM && rn2(5) && !(mvitals[qpm].mvflags & G_GENOD)) - return (&mons[qpm]); - return (mkclass(urole.enemy1sym, 0)); + return &mons[qpm]; + return mkclass(urole.enemy1sym, 0); } qpm = urole.enemy2num; if (qpm != NON_PM && rn2(5) && !(mvitals[qpm].mvflags & G_GENOD)) - return (&mons[qpm]); - return (mkclass(urole.enemy2sym, 0)); + return &mons[qpm]; + return mkclass(urole.enemy2sym, 0); } /* special levels can include a custom arrival message; display it */ diff --git a/src/region.c b/src/region.c index c92ece9e0..6699716c0 100644 --- a/src/region.c +++ b/src/region.c @@ -1,5 +1,5 @@ -/* 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 3.6 region.c $NHDT-Date: 1446892454 2015/11/07 10:34:14 $ $NHDT-Branch: master $:$NHDT-Revision: 1.36 $ */ +/* Copyright (c) 1996 by Jean-Christophe Collet */ /* NetHack may be freely redistributed. See license for details. */ #include "hack.h" @@ -38,7 +38,7 @@ void FDECL(remove_region, (NhRegion *)); void FDECL(replace_mon_regions, (struct monst *,struct monst *)); void FDECL(remove_mon_from_regions, (struct monst *)); NhRegion *FDECL(create_msg_region, (XCHAR_P,XCHAR_P,XCHAR_P,XCHAR_P, - const char *,const char *)); + const char *,const char *)); boolean FDECL(enter_force_field, (genericptr,genericptr)); NhRegion *FDECL(create_force_field, (XCHAR_P,XCHAR_P,int,long)); #endif @@ -58,7 +58,7 @@ inside_rect(r, x, y) NhRect *r; int x, y; { - return (x >= r->lx && x <= r->hx && y >= r->ly && y <= r->hy); + return (boolean) (x >= r->lx && x <= r->hx && y >= r->ly && y <= r->hy); } /* @@ -248,15 +248,16 @@ NhRegion *reg; ret_reg->can_enter_f = reg->can_enter_f; ret_reg->leave_f = reg->leave_f; ret_reg->can_leave_f = reg->can_leave_f; - ret_reg->player_flags = reg->player_flags; /* set/clear_hero_inside,&c*/ + ret_reg->player_flags = reg->player_flags; /* set/clear_hero_inside,&c*/ ret_reg->n_monst = reg->n_monst; if (reg->n_monst > 0) { - ret_reg->monsters = (unsigned int *) - alloc((sizeof (unsigned)) * reg->n_monst); - (void) memcpy((genericptr_t) ret_reg->monsters, (genericptr_t) reg->monsters, - sizeof (unsigned) * reg->n_monst); + ret_reg->monsters = (unsigned int *) + alloc((sizeof (unsigned)) * reg->n_monst); + (void) memcpy((genericptr_t) ret_reg->monsters, + (genericptr_t) reg->monsters, + sizeof (unsigned) * reg->n_monst); } else - ret_reg->monsters = (unsigned int *)0; + ret_reg->monsters = (unsigned int *) 0; return ret_reg; } @@ -565,10 +566,10 @@ struct monst *monold, *monnew; register int i; for (i = 0; i < n_regions; i++) - if (mon_in_region(regions[i], monold)) { - remove_mon_from_reg(regions[i], monold); - add_mon_to_reg(regions[i], monnew); - } + if (mon_in_region(regions[i], monold)) { + remove_mon_from_reg(regions[i], monold); + add_mon_to_reg(regions[i], monnew); + } } /* @@ -581,8 +582,8 @@ struct monst *mon; register int i; for (i = 0; i < n_regions; i++) - if (mon_in_region(regions[i], mon)) - remove_mon_from_reg(regions[i], mon); + if (mon_in_region(regions[i], mon)) + remove_mon_from_reg(regions[i], mon); } #endif /*0*/ @@ -786,9 +787,9 @@ NhRegion *reg; /* not yet used */ /*--------------------------------------------------------------* - * * - * Create Region with just a message * - * * + * * + * Create Region with just a message * + * * *--------------------------------------------------------------*/ NhRegion * @@ -802,9 +803,9 @@ const char *msg_leave; NhRegion *reg = create_region((NhRect *) 0, 0); if (msg_enter) - reg->enter_msg = dupstr(msg_enter); + reg->enter_msg = dupstr(msg_enter); if (msg_leave) - reg->leave_msg = dupstr(msg_leave); + reg->leave_msg = dupstr(msg_leave); tmprect.lx = x; tmprect.ly = y; tmprect.hx = x + w; @@ -816,9 +817,9 @@ const char *msg_leave; /*--------------------------------------------------------------* - * * - * Force Field Related Code * - * (unused yet) * + * * + * Force Field Related Cod * + * (unused yet) * *--------------------------------------------------------------*/ boolean @@ -828,17 +829,17 @@ genericptr_t p2; { struct monst *mtmp; - 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"); - else - pline("Ouch!"); + 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"); + else + pline("Ouch!"); } else { - mtmp = (struct monst *) p2; - if (canseemon(mtmp)) - pline("%s bumps into %s!", Monnam(mtmp), something); + mtmp = (struct monst *) p2; + if (canseemon(mtmp)) + pline("%s bumps into %s!", Monnam(mtmp), something); } return FALSE; } @@ -861,15 +862,15 @@ long ttl; tmprect.ly = y - (radius - 1); tmprect.hy = y + (radius - 1); for (i = 0; i < nrect; i++) { - add_rect_to_reg(ff, &tmprect); - tmprect.lx--; - tmprect.hx++; - tmprect.ly++; - tmprect.hy--; + add_rect_to_reg(ff, &tmprect); + tmprect.lx--; + tmprect.hx++; + tmprect.ly++; + tmprect.hy--; } ff->ttl = ttl; if (!in_mklev && !context.mon_moving) - set_heros_fault(ff); /* assume player has created it */ + set_heros_fault(ff); /* assume player has created it */ /* ff->can_enter_f = enter_force_field; */ /* ff->can_leave_f = enter_force_field; */ add_region(ff); @@ -879,9 +880,9 @@ long ttl; #endif /*0*/ /*--------------------------------------------------------------* - * * - * Gas cloud related code * - * * + * * + * Gas cloud related code * + * * *--------------------------------------------------------------*/ /* diff --git a/src/restore.c b/src/restore.c index 851f0c22a..99c5ad61f 100644 --- a/src/restore.c +++ b/src/restore.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 restore.c $NHDT-Date: 1432536531 2015/05/25 06:48:51 $ $NHDT-Branch: master $:$NHDT-Revision: 1.99 $ */ +/* NetHack 3.6 restore.c $NHDT-Date: 1446892455 2015/11/07 10:34:15 $ $NHDT-Branch: master $:$NHDT-Revision: 1.101 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -321,7 +321,7 @@ boolean ghostly, frozen; otmp2->nobj = 0; } - return (first); + return first; } /* restore one monster */ @@ -453,7 +453,7 @@ boolean ghostly; impossible("Restmonchn: error reading monchn."); mtmp2->nmon = 0; } - return (first); + return first; } STATIC_OVL struct fruit * @@ -595,7 +595,7 @@ unsigned int *stuckid, *steedid; #ifdef SYSFLAGS sysflags = newgamesysflags; #endif - return (FALSE); + return FALSE; } /* in case hangup save occurred in midst of level change */ assign_level(&u.uz0, &u.uz); @@ -667,7 +667,7 @@ unsigned int *stuckid, *steedid; /* must come after all mons & objs are restored */ relink_timers(FALSE); relink_light_sources(FALSE); - return (TRUE); + return TRUE; } /* update game state pointers to those valid for the current level (so we @@ -774,7 +774,7 @@ register int fd; (void) nhclose(fd); (void) delete_savefile(); restoring = FALSE; - return (0); + return 0; } restlevelstate(stuckid, steedid); #ifdef INSURANCE @@ -782,7 +782,7 @@ register int fd; #endif rtmp = restlevelfile(fd, ledger_no(&u.uz)); if (rtmp < 2) - return (rtmp); /* dorecover called recursively */ + return rtmp; /* dorecover called recursively */ /* these pointers won't be valid while we're processing the * other levels, but they'll be reset again by restlevelstate() @@ -834,7 +834,7 @@ register int fd; #endif rtmp = restlevelfile(fd, ltmp); if (rtmp < 2) - return (rtmp); /* dorecover called recursively */ + return rtmp; /* dorecover called recursively */ } restoreprocs.mread_flags = 0; @@ -876,13 +876,13 @@ register int fd; /* in_use processing must be after: * + The inventory has been read so that freeinv() works. * + The current level has been restored so billing information - * is available. + * is available. */ inven_inuse(FALSE); load_qtlist(); /* re-load the quest text info */ - /* Set up the vision internals, after levl[] data is loaded */ - /* but before docrt(). */ + /* Set up the vision internals, after levl[] data is loaded + but before docrt(). */ reglyph_darkroom(); vision_reset(); vision_full_recalc = 1; /* recompute vision (not saved) */ @@ -895,7 +895,7 @@ register int fd; /* Success! */ welcome(FALSE); check_special_room(FALSE); - return (1); + return 1; } void @@ -1021,7 +1021,7 @@ boolean ghostly; } restcemetery(fd, &level.bonesinfo); rest_levl(fd, - (boolean)((sfrestinfo.sfi1 & SFI1_RLECOMP) == SFI1_RLECOMP)); + (boolean) ((sfrestinfo.sfi1 & SFI1_RLECOMP) == SFI1_RLECOMP)); mread(fd, (genericptr_t) lastseentyp, sizeof(lastseentyp)); mread(fd, (genericptr_t) &omoves, sizeof(omoves)); elapsed = monstermoves - omoves; @@ -1128,24 +1128,23 @@ boolean ghostly; assign_level(&sstairs.tolev, <mp); break; case BR_PORTAL: /* max of 1 portal per level */ - { - register struct trap *ttmp; - for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) - if (ttmp->ttyp == MAGIC_PORTAL) + for (trap = ftrap; trap; trap = trap->ntrap) + if (trap->ttyp == MAGIC_PORTAL) break; - if (!ttmp) + if (!trap) panic("getlev: need portal but none found"); - assign_level(&ttmp->dst, <mp); - } break; + assign_level(&trap->dst, <mp); + break; } } else if (!br) { + struct trap *ttmp = 0; + /* Remove any dangling portals. */ - register struct trap *ttmp; - for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) - if (ttmp->ttyp == MAGIC_PORTAL) { - deltrap(ttmp); - break; /* max of 1 portal/level */ - } + for (trap = ftrap; trap; trap = ttmp) { + ttmp = trap->ntrap; + if (trap->ttyp == MAGIC_PORTAL) + deltrap(trap); + } } } @@ -1284,9 +1283,10 @@ boolean ghostly; } #ifdef SELECTSAVED -/* put up a menu listing each character from this player's saved games */ +/* put up a menu listing each character from this player's saved games; + returns 1: use plname[], 0: new game, -1: quit */ int -restore_menu(bannerwin) /* returns 1: use plname[], 0: new game, -1: quit */ +restore_menu(bannerwin) winid bannerwin; /* if not WIN_ERR, clear window and show copyright in menu */ { winid tmpwin; @@ -1578,14 +1578,14 @@ register genericptr_t buf; register unsigned int len; { register int rlen; - #if defined(BSD) || defined(ULTRIX) - rlen = read(fd, buf, (int) len); - if (rlen != len) { +#define readLenType int #else /* e.g. SYSV, __TURBOC__ */ - rlen = read(fd, buf, (unsigned) len); - if ((unsigned) rlen != len) { +#define readLenType unsigned #endif + + rlen = read(fd, buf, (readLenType) len); + if ((readLenType) rlen != (readLenType) len) { if (restoreprocs.mread_flags == 1) { /* means "return anyway" */ restoreprocs.mread_flags = -1; return; diff --git a/src/save.c b/src/save.c index cb080ef78..18d9a1534 100644 --- a/src/save.c +++ b/src/save.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 save.c $NHDT-Date: 1446516854 2015/11/03 02:14:14 $ $NHDT-Branch: master $:$NHDT-Revision: 1.91 $ */ +/* NetHack 3.6 save.c $NHDT-Date: 1446892456 2015/11/07 10:34:16 $ $NHDT-Branch: master $:$NHDT-Revision: 1.92 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -157,7 +157,7 @@ dosave0() if (fd < 0) { HUP pline("Cannot open save file."); (void) delete_savefile(); /* ab@unido */ - return (0); + return 0; } vision_recalc(2); /* shut down vision to prevent problems @@ -251,7 +251,7 @@ dosave0() (void) delete_savefile(); HUP Strcpy(killer.name, whynot); HUP done(TRICKED); - return (0); + return 0; } minit(); /* ZEROCOMP */ getlev(ofd, hackpid, ltmp, FALSE); @@ -270,7 +270,7 @@ dosave0() nh_compress(fq_save); /* this should probably come sooner... */ program_state.something_worth_saving = 0; - return (1); + return 1; } STATIC_OVL void @@ -499,7 +499,8 @@ int mode; bwrite(fd, (genericptr_t) &lev, sizeof(lev)); #endif savecemetery(fd, mode, &level.bonesinfo); - savelevl(fd, (boolean)((sfsaveinfo.sfi1 & SFI1_RLECOMP) == SFI1_RLECOMP)); + savelevl(fd, + (boolean) ((sfsaveinfo.sfi1 & SFI1_RLECOMP) == SFI1_RLECOMP)); bwrite(fd, (genericptr_t) lastseentyp, sizeof(lastseentyp)); bwrite(fd, (genericptr_t) &monstermoves, sizeof(monstermoves)); bwrite(fd, (genericptr_t) &upstair, sizeof(stairway)); @@ -617,7 +618,8 @@ int fd; return; } -void bflush(fd) /* flush run and buffer */ +/* flush run and buffer */ +void bflush(fd) register int fd; { (*saveprocs.save_bflush)(fd); @@ -706,7 +708,7 @@ register unsigned num; } else #endif /* UNIX */ { -/* lint wants the 3rd arg of write to be an int; lint -p an unsigned */ + /* lint wants 3rd arg of write to be an int; lint -p an unsigned */ #if defined(BSD) || defined(ULTRIX) || defined(WIN32) || defined(_MSC_VER) failed = ((long) write(fd, loc, (int) num) != (long) num); #else /* e.g. SYSV, __TURBOC__ */ @@ -805,7 +807,9 @@ int fd; return; } -STATIC_OVL void zerocomp_bflush(fd) /* flush run and buffer */ +/* flush run and buffer */ +STATIC_OVL void +zerocomp_bflush(fd) register int fd; { bwritefd = fd; @@ -1019,7 +1023,8 @@ register struct obj *otmp; if (Has_contents(otmp)) saveobjchn(fd, otmp->cobj, mode); if (release_data(mode)) { - /* if (otmp->oclass == FOOD_CLASS) food_disappears(otmp); + /* if (otmp->oclass == FOOD_CLASS) + * food_disappears(otmp); */ /* * If these are on the floor, the discarding could @@ -1041,7 +1046,8 @@ register struct obj *otmp; /* invalidate the pointer; on reload it will get restored */ context.tin.tin = (struct obj *) 0; } - /* if (otmp->oclass == SPBOOK_CLASS) book_disappears(otmp); + /* if (otmp->oclass == SPBOOK_CLASS) + * book_disappears(otmp); */ if (otmp == context.spbook.book) { /* Store the o_id of your spellbook */ @@ -1365,7 +1371,7 @@ freedynamicdata() freeobjchn(migrating_objs); freemonchn(migrating_mons); freemonchn(mydogs); /* ascension or dungeon escape */ - /* freelevchn(); [folded into free_dungeons()] */ + /* freelevchn(); -- [folded into free_dungeons()] */ free_animals(); free_oracles(); freefruitchn(); @@ -1461,7 +1467,6 @@ copyfile(from, to) char *from, *to; { #ifdef TOS - if (_copyfile(from, to)) panic("Can't copy %s to %s", from, to); #else @@ -1471,8 +1476,7 @@ char *from, *to; if ((fdfrom = open(from, O_RDONLY | O_BINARY, FCMASK)) < 0) panic("Can't copy from %s !?", from); - if ((fdto = open(to, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, FCMASK)) - < 0) + if ((fdto = open(to, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, FCMASK)) < 0) panic("Can't copy to %s", to); do { nfrom = read(fdfrom, buf, BUFSIZ);