-/* $NetBSD: hack.dog.c,v 1.6 2003/04/02 18:36:36 jsm Exp $ */
+/* $NetBSD: hack.dog.c,v 1.12 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.dog.c,v 1.6 2003/04/02 18:36:36 jsm Exp $");
+__RCSID("$NetBSD: hack.dog.c,v 1.12 2011/08/07 06:03:45 dholland Exp $");
#endif /* not lint */
#include "hack.h"
const struct permonst la_dog =
{"large dog", 'd', 6, 15, 4, 2, 4, sizeof(struct edog)};
+static void initedog(struct monst *);
+static int dogfood(struct obj *);
void
-makedog()
+makedog(void)
{
struct monst *mtmp = makemon(&li_dog, u.ux, u.uy);
if (!mtmp)
initedog(mtmp);
}
-void
-initedog(mtmp)
- struct monst *mtmp;
+static void
+initedog(struct monst *mtmp)
{
mtmp->mtame = mtmp->mpeaceful = 1;
EDOG(mtmp)->hungrytime = 1000 + moves;
/* they will appear on the next level @ goes to, even if he goes up! */
void
-losedogs()
+losedogs(void)
{
struct monst *mtmp;
while ((mtmp = mydogs) != NULL) {
}
void
-keepdogs()
+keepdogs(void)
{
struct monst *mtmp;
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
}
void
-fall_down(mtmp)
- struct monst *mtmp;
+fall_down(struct monst *mtmp)
{
relmon(mtmp);
mtmp->nmon = fallen_down;
#define APPORT 4
#define POISON 5
#define UNDEF 6
-int
-dogfood(obj)
- struct obj *obj;
+static int
+dogfood(struct obj *obj)
{
switch (obj->olet) {
case FOOD_SYM:
default:
if (!obj->cursed)
return (APPORT);
- /* fall into next case */
+ /* FALLTHROUGH */
case BALL_SYM:
case CHAIN_SYM:
case ROCK_SYM:
/* Note: if apport == 1 then our behaviour is independent of udist */
if (mtmp->minvent) {
if (!rn2(udist) || !rn2((int) edog->apport))
- if (rn2(10) < edog->apport) {
+ if ((unsigned) rn2(10) < edog->apport) {
relobj(mtmp, (int) mtmp->minvis);
if (edog->apport > 1)
edog->apport--;
goto eatobj;
}
if (obj->owt < 10 * mtmp->data->mlevel)
- if (rn2(20) < edog->apport + 3)
+ if ((unsigned) rn2(20) < edog->apport + 3)
if (rn2(udist) || !rn2((int) edog->apport)) {
freeobj(obj);
unpobj(obj);
}
} else if (gtyp == UNDEF && dogroom >= 0 &&
uroom == dogroom &&
- !mtmp->minvent && edog->apport > rn2(8)) {
+ !mtmp->minvent && edog->apport > (unsigned)rn2(8)) {
gx = obj->ox;
gy = obj->oy;
gtyp = APPORT;
ny = poss[i].y;
if (info[i] & ALLOW_M) {
mtmp2 = m_at(nx, ny);
+ if (mtmp2 == NULL)
+ panic("error in dog_move");
if (mtmp2->data->mlevel >= mdat->mlevel + 2 ||
mtmp2->data->mlet == 'c')
continue;
/* return roomnumber or -1 */
int
-inroom(x, y)
- xchar x, y;
+inroom(xchar x, xchar y)
{
#ifndef QUEST
- struct mkroom *croom = &rooms[0];
- while (croom->hx >= 0) {
- if (croom->hx >= x - 1 && croom->lx <= x + 1 &&
- croom->hy >= y - 1 && croom->ly <= y + 1)
- return (croom - rooms);
- croom++;
+ int pos = 0;
+
+ while (rooms[pos].hx >= 0) {
+ if (rooms[pos].hx >= x - 1 && rooms[pos].lx <= x + 1 &&
+ rooms[pos].hy >= y - 1 && rooms[pos].ly <= y + 1)
+ return pos;
+ pos++;
}
#endif /* QUEST */
return (-1); /* not in room or on door */
}
int
-tamedog(mtmp, obj)
- struct monst *mtmp;
- struct obj *obj;
+tamedog(struct monst *mtmp, struct obj *obj)
{
struct monst *mtmp2;