-/* 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. */
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 *));
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));
}
}
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));
}
}
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));
}
}
otmp = mkobj(let, artif);
place_object(otmp, x, y);
- return (otmp);
+ return otmp;
}
struct obj *
otmp = mksobj(otyp, init, artif);
place_object(otmp, x, y);
- return (otmp);
+ return otmp;
}
struct obj *
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++)
;
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
}
}
-int rndmonnum() /* select a random, common monster type */
+/* select a random, common monster type */
+int
+rndmonnum()
{
register struct permonst *ptr;
register int i;
/* 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);
ptr = &mons[i];
} while ((ptr->geno & excludeflags) != 0);
- return (i);
+ return i;
}
void
if (objects[otyp].oc_unique && !otmp->oartifact)
otmp = mk_artifact(otmp, (aligntyp) A_NONE);
otmp->owt = weight(otmp);
- return (otmp);
+ return otmp;
}
/*
}
/*
- * 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
* 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)
* 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.
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);
}
gold->quan = amount;
}
gold->owt = weight(gold);
- return (gold);
+ return gold;
}
/* return TRUE if the corpse has special timing */
* 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.
*/
}
}
}
- return (otmp);
+ return otmp;
}
/*
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) */
otmp = mkcorpstat(objtype, (struct monst *) 0, ptr, x, y, corpstatflags);
if (nm)
otmp = oname(otmp, nm);
- return (otmp);
+ return otmp;
}
boolean
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
{
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);
}
/*
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) {
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));
* 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)
/* 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
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);
}
}
}
- return NULL;
+ return (struct obj *) 0;
}
/*
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 */
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;
}
/*
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;
}
impossible("obj_meld: not called with two actual objects");
- return NULL;
+ return (struct obj *) 0;
}
/*mkobj.c*/
-/* 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. */
return -1; /* not 0, or caller would try again each move */
}
-void oinit() /* level dependent initialization */
+/* level dependent initialization */
+void
+oinit()
{
setgemprobs(&u.uz);
}
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 */
};
/* 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;
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;
-/* 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. */
if (qsuffix && len < lenlimit) {
(void) strncpy(&qbuf[len], qsuffix, lenlimit - len);
*endp = '\0';
- /* len = (unsigned)strlen(qbuf); */
+ /* len = (unsigned) strlen(qbuf); */
}
}
} else {
-/* 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. */
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;
break;
}
- return ((pm && !Hallucination) ? pm : (struct permonst *) 0);
+ return (pm && !Hallucination) ? pm : (struct permonst *) 0;
}
/*
* 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)
* "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;
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.");
-/* 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"
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;
/*
* 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)
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;
}
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)) {
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);
&& 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);
* 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)
-/* 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"
/* 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;
(void) dlb_fseek(msg_file, msg->offset, SEEK_SET);
deliver_by_window(msg, NHW_MAP);
}
-#endif /* !DEBUG */
+#endif /* DEBUG */
return;
}
msg_file);
msg_list[n_msgs].msgnum = -1;
- return (msg_list);
+ return msg_list;
}
void
{
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;
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;
{
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;
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
#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()
*/
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 */
-/* 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"
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
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);
}
/*
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;
}
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);
+ }
}
/*
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*/
/* not yet used */
/*--------------------------------------------------------------*
- * *
- * Create Region with just a message *
- * *
+ * *
+ * Create Region with just a message *
+ * *
*--------------------------------------------------------------*/
NhRegion *
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;
/*--------------------------------------------------------------*
- * *
- * Force Field Related Code *
- * (unused yet) *
+ * *
+ * Force Field Related Cod *
+ * (unused yet) *
*--------------------------------------------------------------*/
boolean
{
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;
}
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);
#endif /*0*/
/*--------------------------------------------------------------*
- * *
- * Gas cloud related code *
- * *
+ * *
+ * Gas cloud related code *
+ * *
*--------------------------------------------------------------*/
/*
-/* 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. */
otmp2->nobj = 0;
}
- return (first);
+ return first;
}
/* restore one monster */
impossible("Restmonchn: error reading monchn.");
mtmp2->nmon = 0;
}
- return (first);
+ return first;
}
STATIC_OVL struct fruit *
#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);
/* 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
(void) nhclose(fd);
(void) delete_savefile();
restoring = FALSE;
- return (0);
+ return 0;
}
restlevelstate(stuckid, steedid);
#ifdef INSURANCE
#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()
#endif
rtmp = restlevelfile(fd, ltmp);
if (rtmp < 2)
- return (rtmp); /* dorecover called recursively */
+ return rtmp; /* dorecover called recursively */
}
restoreprocs.mread_flags = 0;
/* 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) */
/* Success! */
welcome(FALSE);
check_special_room(FALSE);
- return (1);
+ return 1;
}
void
}
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;
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);
+ }
}
}
}
#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;
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;
-/* 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. */
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
(void) delete_savefile();
HUP Strcpy(killer.name, whynot);
HUP done(TRICKED);
- return (0);
+ return 0;
}
minit(); /* ZEROCOMP */
getlev(ofd, hackpid, ltmp, FALSE);
nh_compress(fq_save);
/* this should probably come sooner... */
program_state.something_worth_saving = 0;
- return (1);
+ return 1;
}
STATIC_OVL void
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));
return;
}
-void bflush(fd) /* flush run and buffer */
+/* flush run and buffer */
+void bflush(fd)
register int fd;
{
(*saveprocs.save_bflush)(fd);
} 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__ */
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;
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
/* 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 */
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();
char *from, *to;
{
#ifdef TOS
-
if (_copyfile(from, to))
panic("Can't copy %s to %s", from, to);
#else
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);