X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/4fb5b4006b9fecf6ee1b155e1f47685515c580fe..bcbc46f191b73fe1b817d448571b248466e49272:/hack/hack.mon.c diff --git a/hack/hack.mon.c b/hack/hack.mon.c index e88ce6cb..8dd587ec 100644 --- a/hack/hack.mon.c +++ b/hack/hack.mon.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.mon.c,v 1.7 2006/03/30 01:28:46 jnemeth Exp $ */ +/* $NetBSD: hack.mon.c,v 1.14 2011/08/07 06:03:45 dholland Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, @@ -63,7 +63,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.mon.c,v 1.7 2006/03/30 01:28:46 jnemeth Exp $"); +__RCSID("$NetBSD: hack.mon.c,v 1.14 2011/08/07 06:03:45 dholland Exp $"); #endif /* not lint */ #include @@ -71,19 +71,22 @@ __RCSID("$NetBSD: hack.mon.c,v 1.7 2006/03/30 01:28:46 jnemeth Exp $"); #include "extern.h" #include "hack.mfndpos.h" -#ifndef NULL -#define NULL (char *) 0 -#endif +static int warnlevel; /* used by movemon and dochugw */ +static long lastwarntime; +static int lastwarnlev; -int warnlevel; /* used by movemon and dochugw */ -long lastwarntime; -int lastwarnlev; -const char *const warnings[] = { +static const char *const warnings[] = { "white", "pink", "red", "ruby", "purple", "black" }; +static int dochugw(struct monst *); +static void mpickgold(struct monst *); +static void mpickgems(struct monst *); +static void dmonsfree(void); +static int ishuman(struct monst *); + void -movemon() +movemon(void) { struct monst *mtmp; int fr; @@ -173,9 +176,7 @@ next_mon: } void -justswld(mtmp, name) - struct monst *mtmp; - const char *name; +justswld(struct monst *mtmp, const char *name) { mtmp->mx = u.ux; @@ -191,10 +192,7 @@ justswld(mtmp, name) } void -youswld(mtmp, dam, die, name) - struct monst *mtmp; - int dam, die; - const char *name; +youswld(struct monst *mtmp, int dam, unsigned int die, const char *name) { if (mtmp != u.ustuck) return; @@ -211,15 +209,15 @@ youswld(mtmp, dam, die, name) #endif } -int -dochugw(mtmp) - struct monst *mtmp; +static int +dochugw(struct monst *mtmp) { int x = mtmp->mx; int y = mtmp->my; - int d = dochug(mtmp); + int dead = dochug(mtmp); int dd; - if (!d) /* monster still alive */ + + if (!dead) /* monster still alive */ if (Warning) if (!mtmp->mpeaceful) if (mtmp->data->mlevel > warnlevel) @@ -227,13 +225,12 @@ dochugw(mtmp) if (dd < 100) if (!canseemon(mtmp)) warnlevel = mtmp->data->mlevel; - return (d); + return (dead); } /* returns 1 if monster died moving, 0 otherwise */ int -dochug(mtmp) - struct monst *mtmp; +dochug(struct monst *mtmp) { const struct permonst *mdat; int tmp = 0, nearby, scared; @@ -546,9 +543,8 @@ postmov: return (mmoved); } -void -mpickgold(mtmp) - struct monst *mtmp; +static void +mpickgold(struct monst *mtmp) { struct gold *gold; while ((gold = g_at(mtmp->mx, mtmp->my)) != NULL) { @@ -559,9 +555,8 @@ mpickgold(mtmp) } } -void -mpickgems(mtmp) - struct monst *mtmp; +static void +mpickgems(struct monst *mtmp) { struct obj *otmp; for (otmp = fobj; otmp; otmp = otmp->nobj) @@ -578,10 +573,7 @@ mpickgems(mtmp) /* return number of acceptable neighbour positions */ int -mfndpos(mon, poss, info, flag) - struct monst *mon; - coord poss[9]; - int info[9], flag; +mfndpos(struct monst *mon, coord poss[9], int info[9], int flag) { int x, y, nx, ny, cnt = 0, ntyp; struct monst *mtmp; @@ -673,15 +665,13 @@ nexttry: /* eels prefer the water, but if there is no } int -dist(x, y) - int x, y; +dist(int x, int y) { return ((x - u.ux) * (x - u.ux) + (y - u.uy) * (y - u.uy)); } void -poisoned(string, pname) - const char *string, *pname; +poisoned(const char *string, const char *pname) { int i; @@ -709,8 +699,7 @@ poisoned(string, pname) } void -mondead(mtmp) - struct monst *mtmp; +mondead(struct monst *mtmp) { relobj(mtmp, 1); unpmon(mtmp); @@ -729,8 +718,7 @@ mondead(mtmp) /* called when monster is moved to larger structure */ void -replmon(mtmp, mtmp2) - struct monst *mtmp, *mtmp2; +replmon(struct monst *mtmp, struct monst *mtmp2) { relmon(mtmp); monfree(mtmp); @@ -745,8 +733,7 @@ replmon(mtmp, mtmp2) } void -relmon(mon) - struct monst *mon; +relmon(struct monst *mon) { struct monst *mtmp; @@ -762,30 +749,28 @@ relmon(mon) * we do not free monsters immediately, in order to have their name available * shortly after their demise */ -struct monst *fdmon; /* chain of dead monsters, need not to be +static struct monst *fdmon; /* chain of dead monsters, need not to be * saved */ void -monfree(mtmp) - struct monst *mtmp; +monfree(struct monst *mtmp) { mtmp->nmon = fdmon; fdmon = mtmp; } -void -dmonsfree() +static void +dmonsfree(void) { struct monst *mtmp; while ((mtmp = fdmon) != NULL) { fdmon = mtmp->nmon; - free((char *) mtmp); + free(mtmp); } } void -unstuck(mtmp) - struct monst *mtmp; +unstuck(struct monst *mtmp) { if (u.ustuck == mtmp) { if (u.uswallow) { @@ -800,8 +785,7 @@ unstuck(mtmp) } void -killed(mtmp) - struct monst *mtmp; +killed(struct monst *mtmp) { #ifdef lint #define NEW_SCORING @@ -864,6 +848,7 @@ killed(mtmp) { int ul = u.ulevel; int ml = mdat->mlevel; + int tmp2; if (ul < 14) /* points are given based on present and * future level */ @@ -939,7 +924,7 @@ kludge(const char *str, const char *arg) } void -rescham() +rescham(void) { /* force all chameleons to become normal */ struct monst *mtmp; @@ -950,11 +935,10 @@ rescham() } } -int -newcham(mtmp, mdat) /* make a chameleon look like a new monster */ +/* make a chameleon look like a new monster */ /* returns 1 if the monster actually changed */ - struct monst *mtmp; - const struct permonst *mdat; +int +newcham(struct monst *mtmp, const struct permonst *mdat) { int mhp, hpn, hpd; @@ -995,10 +979,9 @@ newcham(mtmp, mdat) /* make a chameleon look like a new monster */ return (1); } +/* Make monster mtmp next to you (if possible) */ void -mnexto(mtmp) /* Make monster mtmp next to you (if - * possible) */ - struct monst *mtmp; +mnexto(struct monst *mtmp) { coord mm; mm = enexto(u.ux, u.uy); @@ -1007,16 +990,14 @@ mnexto(mtmp) /* Make monster mtmp next to you (if pmon(mtmp); } -int -ishuman(mtmp) - struct monst *mtmp; +static int +ishuman(struct monst *mtmp) { return (mtmp->data->mlet == '@'); } void -setmangry(mtmp) - struct monst *mtmp; +setmangry(struct monst *mtmp) { if (!mtmp->mpeaceful) return; @@ -1032,8 +1013,7 @@ setmangry(mtmp) * object */ int -canseemon(mtmp) - struct monst *mtmp; +canseemon(struct monst *mtmp) { return ((!mtmp->minvis || See_invisible) && (!mtmp->mhide || !o_at(mtmp->mx, mtmp->my))