-/* $NetBSD: hack.eat.c,v 1.4 1997/10/19 16:57:53 christos Exp $ */
+/* $NetBSD: hack.eat.c,v 1.13 2019/02/04 03:33:15 mrg Exp $ */
/*
- * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
+ * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
+ * Amsterdam
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of the Stichting Centrum voor Wiskunde en
+ * Informatica, nor the names of its contributors may be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1982 Jay Fenlason <hack@gnu.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.eat.c,v 1.4 1997/10/19 16:57:53 christos Exp $");
+__RCSID("$NetBSD: hack.eat.c,v 1.13 2019/02/04 03:33:15 mrg Exp $");
#endif /* not lint */
#include "hack.h"
#include "extern.h"
-char POISONOUS[] = "ADKSVabhks";
+static char POISONOUS[] = "ADKSVabhks";
/* hunger texts used on bottom line (each 8 chars long) */
#define SATIATED 0
#define FAINTED 5
#define STARVED 6
-char *hu_stat[] = {
+const char *const hu_stat[] = {
"Satiated",
" ",
"Hungry ",
"Starved "
};
+static int opentin(void);
+static int Meatdone(void);
+static int unfaint(void);
+static void newuhs(boolean);
+static int eatcorpse(struct obj *);
+
void
-init_uhunger()
+init_uhunger(void)
{
u.uhunger = 900;
u.uhs = NOT_HUNGRY;
}
#define TTSZ SIZE(tintxts)
-struct {
- char *txt;
+static const struct {
+ const char *txt;
int nut;
} tintxts[] = {
{ "It contains first quality peaches - what a surprise!", 40 },
int usedtime, reqtime;
} tin;
-int
-opentin()
+static int
+opentin(void)
{
int r;
useup(tin.tin);
r = rn2(2 * TTSZ);
if (r < TTSZ) {
- pline(tintxts[r].txt);
+ pline("%s", tintxts[r].txt);
lesshungry(tintxts[r].nut);
if (r == 1) { /* SALMON */
Glib = rnd(15);
return (0);
}
-int
-Meatdone()
+static int
+Meatdone(void)
{
u.usym = '@';
prme();
}
int
-doeat()
+doeat(void)
{
struct obj *otmp;
struct objclass *ftmp;
goto no_opener;
}
pline("Using your %s you try to open the tin.",
- aobjnam(uwep, (char *) 0));
+ aobjnam(uwep, NULL));
} else {
no_opener:
pline("It is not so easy to open this tin.");
eatx:
if (multi < 0 && !nomovemsg) {
static char msgbuf[BUFSZ];
- (void) sprintf(msgbuf, "You finished eating the %s.",
+ (void) snprintf(msgbuf, sizeof(msgbuf),
+ "You finished eating the %s.",
ftmp->oc_name);
nomovemsg = msgbuf;
}
/* called in hack.main.c */
void
-gethungry()
+gethungry(void)
{
--u.uhunger;
if (moves % 2) {
/* called after vomiting and after performing feats of magic */
void
-morehungry(num)
- int num;
+morehungry(int num)
{
u.uhunger -= num;
newuhs(TRUE);
/* called after eating something (and after drinking fruit juice) */
void
-lesshungry(num)
- int num;
+lesshungry(int num)
{
u.uhunger += num;
newuhs(FALSE);
}
-int
-unfaint()
+static int
+unfaint(void)
{
u.uhs = FAINTING;
flags.botl = 1;
return 0;
}
-void
-newuhs(incr)
- boolean incr;
+static void
+newuhs(boolean incr)
{
int newhs, h = u.uhunger;
? 'a' + (otyp - DEAD_ACID_BLOB)\
: '@' + (otyp - DEAD_HUMAN))
int
-poisonous(otmp)
- struct obj *otmp;
+poisonous(struct obj *otmp)
{
return (strchr(POISONOUS, CORPSE_I_TO_C(otmp->otyp)) != 0);
}
/* returns 1 if some text was printed */
-int
-eatcorpse(otmp)
- struct obj *otmp;
+static int
+eatcorpse(struct obj *otmp)
{
char let = CORPSE_I_TO_C(otmp->otyp);
int tp = 0;
case 'n':
u.uhp = u.uhpmax;
flags.botl = 1;
- /* fall into next case */
+ /* FALLTHROUGH */
case '@':
pline("You cannibal! You will be sorry for this!");
/* not tp++; */
- /* fall into next case */
+ /* FALLTHROUGH */
case 'd':
Aggravate_monster |= INTRINSIC;
break;
Invis |= INTRINSIC;
See_invisible |= INTRINSIC;
}
- /* fall into next case */
+ /* FALLTHROUGH */
case 'y':
#ifdef QUEST
u.uhorizon++;
#endif /* QUEST */
- /* fall into next case */
+ /* FALLTHROUGH */
case 'B':
Confusion = 50;
break;
pline("You turn to stone.");
killer = "dead cockatrice";
done("died");
- /* NOTREACHED */
+ break;
case 'a':
if (Stoned) {
pline("What a pity - you just destroyed a future piece of art!");