-/* $NetBSD: hack.mon.c,v 1.6 2003/04/02 18:36:38 jsm 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,
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.mon.c,v 1.6 2003/04/02 18:36:38 jsm Exp $");
+__RCSID("$NetBSD: hack.mon.c,v 1.14 2011/08/07 06:03:45 dholland Exp $");
#endif /* not lint */
#include <stdlib.h>
#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;
}
void
-justswld(mtmp, name)
- struct monst *mtmp;
- const char *name;
+justswld(struct monst *mtmp, const char *name)
{
mtmp->mx = u.ux;
}
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;
#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)
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;
if (mmoved) {
if (info[chi] & ALLOW_M) {
mtmp2 = m_at(nix, niy);
+ if (mtmp2 == NULL)
+ panic("error in m_move");
if (hitmm(mtmp, mtmp2) == 1 && rn2(4) &&
hitmm(mtmp2, mtmp) == 2)
return (2);
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) {
}
}
-void
-mpickgems(mtmp)
- struct monst *mtmp;
+static void
+mpickgems(struct monst *mtmp)
{
struct obj *otmp;
for (otmp = fobj; otmp; otmp = otmp->nobj)
/* 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;
}
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;
}
void
-mondead(mtmp)
- struct monst *mtmp;
+mondead(struct monst *mtmp)
{
relobj(mtmp, 1);
unpmon(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);
}
void
-relmon(mon)
- struct monst *mon;
+relmon(struct monst *mon)
{
struct monst *mtmp;
* 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) {
}
void
-killed(mtmp)
- struct monst *mtmp;
+killed(struct monst *mtmp)
{
#ifdef lint
#define NEW_SCORING
{
int ul = u.ulevel;
int ml = mdat->mlevel;
+ int tmp2;
if (ul < 14) /* points are given based on present and
* future level */
}
void
-rescham()
+rescham(void)
{ /* force all chameleons to become normal */
struct monst *mtmp;
}
}
-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;
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);
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;
* object
*/
int
-canseemon(mtmp)
- struct monst *mtmp;
+canseemon(struct monst *mtmp)
{
return ((!mtmp->minvis || See_invisible)
&& (!mtmp->mhide || !o_at(mtmp->mx, mtmp->my))