-/* $NetBSD: subr.c,v 1.5 1997/10/11 01:53:36 lukem Exp $ */
+/* $NetBSD: subr.c,v 1.11 2005/07/01 00:03:36 jmc Exp $ */
/*-
* Copyright (c) 1991, 1993
* 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
#if 0
static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: subr.c,v 1.5 1997/10/11 01:53:36 lukem Exp $");
+__RCSID("$NetBSD: subr.c,v 1.11 2005/07/01 00:03:36 jmc Exp $");
#endif
#endif /* not lint */
/* Re-coding of advent in C: subroutines from main */
#include <stdio.h>
+#include <stdlib.h>
#include "hdr.h"
#include "extern.h"
/* Statement functions */
int
-toting(objj)
- int objj;
+toting(int objj)
{
if (place[objj] == -1)
return (TRUE);
}
int
-here(objj)
- int objj;
+here(int objj)
{
if (place[objj] == loc || toting(objj))
return (TRUE);
}
int
-at(objj)
- int objj;
+at(int objj)
{
if (place[objj] == loc || fixed[objj] == loc)
return (TRUE);
}
int
-liq2(pbotl)
- int pbotl;
+liq2(int pbotl)
{
return ((1 - pbotl) * water + (pbotl / 2) * (water + oil));
}
int
-liq(foo)
+liq(void)
{
int i;
i = prop[bottle];
return (liq2(-1 - i));
}
+/* may want to clean this one up a bit */
int
-liqloc(locc) /* may want to clean this one up a bit */
- int locc;
+liqloc(int locc)
{
int i, j, l;
i = cond[locc] / 2;
}
int
-bitset(l, n)
- int l, n;
+bitset(int l, int n)
{
if (cond[l] & setbit[n])
return (TRUE);
}
int
-forced(locc)
- int locc;
+forced(int locc)
{
if (cond[locc] == 2)
return (TRUE);
}
int
-dark(foo)
+dark(void)
{
if ((cond[loc] % 2) == 0 && (prop[lamp] == 0 || !here(lamp)))
return (TRUE);
}
int
-pct(n)
- int n;
+pct(int n)
{
if (ran(100) < n)
return (TRUE);
int
-fdwarf()
+fdwarf(void)
{ /* 71 */
int i, j;
struct travlist *kk;
j = 1 + ran(j);
odloc[i] = dloc[i];
dloc[i] = tk[j];
- dseen[i] = (dseen[i] && loc >= 15) || (dloc[i] == loc || odloc[i] == loc);
+ dseen[i] = (dseen[i] && loc >= 15) ||
+ (dloc[i] == loc || odloc[i] == loc);
if (!dseen[i])
continue; /* i.e. goto 6030 */
dloc[i] = loc;
if (loc == chloc || prop[chest] >= 0)
continue;
k = 0;
- for (j = 50; j <= maxtrs; j++) { /* loop to 6020 */
+ for (j = 50; j <= maxtrs; j++) { /* loop to 6020 */
if (j == pyram && (loc == plac[pyram]
|| loc == plac[emrald]))
goto l6020;
if (place[messag] == 0)
move(chest, chloc);
move(messag, chloc2);
- for (j = 50; j <= maxtrs; j++) { /* loop to 6023 */
+ for (j = 50; j <= maxtrs; j++) { /* loop to 6023 */
if (j == pyram && (loc == plac[pyram]
|| loc == plac[emrald]))
continue;
}
+/* label 8 */
int
-march()
-{ /* label 8 */
+march(void)
+{
int ll1, ll2;
if ((tkk = travel[newloc = loc]) == 0)
goto l11;
}
-
-
+/* 20 */
int
-mback()
-{ /* 20 */
+mback(void)
+{
struct travlist *tk2, *j;
int ll;
if (forced(k = oldloc))
return (2);
}
-
+/* 30000 */
int
-specials()
-{ /* 30000 */
+specials(void)
+{
switch (newloc -= 300) {
case 1: /* 30100 */
newloc = 99 + 100 - loc;
}
}
-
+/* 30300 */
int
-trbridge()
-{ /* 30300 */
+trbridge(void)
+{
if (prop[troll] == 1) {
pspeak(troll, 1);
prop[troll] = 0;
newloc = loc;
return (2);
}
- newloc = plac[troll] + fixd[troll] - loc; /* 30310 */
+ newloc = plac[troll] + fixd[troll] - loc; /* 30310 */
if (prop[troll] == 0)
prop[troll] = 1;
if (!toting(bear))
return (99);
}
-
-int
-badmove()
-{ /* 20 */
+/* 20 */
+void
+badmove(void)
+{
spk = 12;
if (k >= 43 && k <= 50)
spk = 9;
if (k == 17)
spk = 80;
rspeak(spk);
- return (2);
}
-int
-bug(n)
- int n;
+void
+bug(int n)
{
printf("Please tell jim@rand.org that fatal bug %d happened.\n", n);
- exit(0);
+ exit(1);
}
-
-int
-checkhints()
-{ /* 2600 &c */
+/* 2600 &c */
+void
+checkhints(void)
+{
int hint;
for (hint = 4; hint <= hntmax; hint++) {
if (hinted[hint])
hinted[hint] = yes(175, hints[hint][4], 54);
l40020: hintlc[hint] = 0;
}
- return 0;
}
-
+/* 9030 */
int
-trsay()
-{ /* 9030 */
+trsay(void)
+{
int i;
if (*wd2 != 0)
copystr(wd2, wd1);
return (2012);
}
-
+/* 9010 */
int
-trtake()
-{ /* 9010 */
+trtake(void)
+{
if (toting(obj))
return (2011); /* 9010 */
spk = 25;
if (fixed[obj] != 0)
return (2011);
if (obj == water || obj == oil) {
- if (here(bottle) && liq(0) == obj) {
+ if (here(bottle) && liq() == obj) {
obj = bottle;
goto l9017;
}
l9014: if ((obj == bird || obj == cage) && prop[bird] != 0)
carry(bird + cage - obj, loc);
carry(obj, loc);
- k = liq(0);
+ k = liq();
if (obj == bottle && k != 0)
place[k] = -1;
return (2009);
}
-
+/* 9021 */
int
-dropper()
-{ /* 9021 */
- k = liq(0);
+dropper(void)
+{
+ k = liq();
if (k == obj)
obj = bottle;
if (obj == bottle && k != 0)
return (2012);
}
+/* 9020 */
int
-trdrop()
-{ /* 9020 */
+trdrop(void)
+{
if (toting(rod2) && obj == rod && !toting(rod))
obj = rod2;
if (!toting(obj))
pspeak(batter, 0);
return (2012);
}
- if (obj == bird && at(dragon) && prop[dragon] == 0) { /* 9025 */
+ if (obj == bird && at(dragon) && prop[dragon] == 0) { /* 9025 */
rspeak(154);
dstroy(bird);
prop[bird] = 0;
prop[troll] = 2;
return (dropper());
}
- if (obj != vase || loc == plac[pillow]) { /* 9027 */
+ if (obj != vase || loc == plac[pillow]) { /* 9027 */
rspeak(54);
return (dropper());
}
return (dropper());
}
-
+/* 9040 */
int
-tropen()
-{ /* 9040 */
+tropen(void)
+{
if (obj == clam || obj == oyster) {
k = 0; /* 9046 */
if (obj == oyster)
return (2010);
}
-
+/* 9120 */
int
-trkill()
-{ /* 9120 */
+trkill(void)
+{
int i;
for (i = 1; i <= 5; i++)
if (dloc[i] == loc && dflag >= 2)
return (8);
}
-
+/* 9170: throw */
int
-trtoss()
-{ /* 9170: throw */
+trtoss(void)
+{
int i;
if (toting(rod2) && obj == rod && !toting(rod))
obj = rod2;
return (9120);
}
-
+/* 9210 */
int
-trfeed()
-{ /* 9210 */
+trfeed(void)
+{
if (obj == bird) {
spk = 100;
return (2011);
return (2011);
}
-
+/* 9220 */
int
-trfill()
-{ /* 9220 */
+trfill(void)
+{
if (obj == vase) {
spk = 29;
if (liqloc(loc) == 0)
spk = 107;
if (liqloc(loc) == 0)
spk = 106;
- if (liq(0) != 0)
+ if (liq() != 0)
spk = 105;
if (spk != 107)
return (2011);
prop[bottle] = ((cond[loc] % 4) / 2) * 2;
- k = liq(0);
+ k = liq();
if (toting(bottle))
place[k] = -1;
if (k == oil)
return (2011);
}
-
-int
-closing()
-{ /* 10000 */
+/* 10000 */
+void
+closing(void)
+{
int i;
prop[grate] = prop[fissur] = 0;
rspeak(129);
clock1 = -1;
closng = TRUE;
- return (19999);
}
-
-int
-caveclose()
-{ /* 11000 */
+/* 11000 */
+void
+caveclose(void)
+{
int i;
prop[bottle] = put(bottle, 115, 1);
prop[plant] = put(plant, 115, 0);
dstroy(i);
rspeak(132);
closed = TRUE;
- return (2);
}