-/* $NetBSD: object.c,v 1.10 2001/02/05 00:57:34 christos Exp $ */
+/* $NetBSD: object.c,v 1.17 2019/02/03 03:19:25 mrg Exp $ */
/* object.c Larn is copyrighted 1986 by Noah Morgan. */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: object.c,v 1.10 2001/02/05 00:57:34 christos Exp $");
+__RCSID("$NetBSD: object.c,v 1.17 2019/02/03 03:19:25 mrg Exp $");
#endif /* not lint */
#include "header.h"
#include "extern.h"
+static void finditem(int);
+static void ostairs(int);
+static void opotion(int);
+static void oscroll(int);
+static void oorb(void);
+static void opit(void);
+static void obottomless(void);
+static void oelevator(int);
+static void ostatue(void);
+static void omirror(void);
+static void obook(void);
+static void ocookie(void);
+static void ogold(int);
+static void ohome(void);
+
/*
- ***************
- LOOK_FOR_OBJECT
- ***************
+ lookforobject
subroutine to look for an object and give the player his options
if an object was found.
*/
void
-lookforobject()
+lookforobject(void)
{
int i, j;
if (c[TIMESTOP])
- return; /* can't find objects is time is stopped */
+ return; /* can't find objects if time is stopped */
i = item[playerx][playery];
if (i == 0)
return;
item[playerx][playery] = OTELEPORTER;
know[playerx][playery] = 1;
+ /* FALLTHROUGH */
case OTELEPORTER:
lprcat("\nZaaaappp! You've been teleported!\n");
beep();
lprcat("\nDo you (g) go inside, or (i) stay here? ");
i = 0;
while ((i != 'g') && (i != 'i') && (i != '\33'))
- i = lgetchar();
+ i = ttgetch();
if (i == 'g') {
oschool(); /* the college of larn */
} else
lprcat("\nDo you (g) go inside, or (i) stay here? ");
j = 0;
while ((j != 'g') && (j != 'i') && (j != '\33'))
- j = lgetchar();
+ j = ttgetch();
if (j == 'g') {
if (i == OBANK)
obank();
lprcat("\nDo you (g) go inside, or (i) stay here? ");
i = 0;
while ((i != 'g') && (i != 'i') && (i != '\33'))
- i = lgetchar();
+ i = ttgetch();
if (i == 'g')
dndstore(); /* the dnd adventurers store */
else
iopts();
i = 0;
while ((i != 'c') && (i != 'i') && (i != '\33'))
- i = lgetchar();
+ i = ttgetch();
if ((i == '\33') || (i == 'i')) {
ignore();
break;
iopts();
i = 0;
while ((i != 'o') && (i != 'i') && (i != '\33'))
- i = lgetchar();
+ i = ttgetch();
if ((i == '\33') || (i == 'i')) {
ignore();
playerx = lastpx;
iopts();
i = 0;
while ((i != 'g') && (i != 'i') && (i != '\33'))
- i = lgetchar();
+ i = ttgetch();
if (i == 'g') {
newcavelevel(1);
playerx = 33;
iopts();
i = 0;
while ((i != 'c') && (i != 'i') && (i != '\33'))
- i = lgetchar();
+ i = ttgetch();
if ((i == '\33') || (i == 'i')) {
ignore();
break;
iopts();
i = 0;
while ((i != 'c') && (i != 'i') && (i != '\33'))
- i = lgetchar();
+ i = ttgetch();
if ((i == '\33') || (i == 'i')) {
ignore();
break;
item[playerx][playery] = OTRAPARROW;
know[playerx][playery] = 0;
+ /* FALLTHROUGH */
case OTRAPARROW:
lprcat("\nYou are hit by an arrow");
beep(); /* for an arrow trap */
item[playerx][playery] = ODARTRAP;
know[playerx][playery] = 0;
+ /* FALLTHROUGH */
case ODARTRAP:
lprcat("\nYou are hit by a dart");
beep(); /* for a dart trap */
item[playerx][playery] = OTRAPDOOR;
know[playerx][playery] = 1;
+ /* FALLTHROUGH */
case OTRAPDOOR:
lastnum = 272; /* a trap door */
if ((level == MAXLEVEL - 1) || (level == MAXLEVEL + MAXVLEVEL - 1)) {
lprcat("\nDo you (g) go inside, or (i) stay here? ");
i = 0;
while ((i != 'g') && (i != 'i') && (i != '\33'))
- i = lgetchar();
+ i = ttgetch();
if (i == 'g')
otradepost();
else
lprcat("\nDo you (g) go inside, or (i) stay here? ");
i = 0;
while ((i != 'g') && (i != 'i') && (i != '\33'))
- i = lgetchar();
+ i = ttgetch();
if (i == 'g')
ohome();
else
lprcat("\nDo you (g) go inside, or (i) stay here? ");
i = 0;
while ((i != 'g') && (i != 'i') && (i != '\33'))
- i = lgetchar();
+ i = ttgetch();
if (i == 'g')
olrs(); /* the larn revenue service */
else
/*
function to say what object we found and ask if player wants to take it
*/
-void
-finditem(itm)
- int itm;
+static void
+finditem(int theitem)
{
int tmp, i;
- lprintf("\n\nYou have found %s ", objectname[itm]);
+ lprintf("\n\nYou have found %s ", objectname[theitem]);
tmp = iarg[playerx][playery];
- switch (itm) {
+ switch (theitem) {
case ODIAMOND:
case ORUBY:
case OEMERALD:
default:
if (tmp > 0)
- lprintf("+ %d", (long) tmp);
+ lprintf("+ %ld", (long) tmp);
else if (tmp < 0)
- lprintf(" %d", (long) tmp);
+ lprintf(" %ld", (long) tmp);
}
lprcat("\nDo you want to (t) take it");
iopts();
i = 0;
while (i != 't' && i != 'i' && i != '\33')
- i = lgetchar();
+ i = ttgetch();
if (i == 't') {
lprcat("take");
- if (take(itm, tmp) == 0)
+ if (take(theitem, tmp) == 0)
forget();
return;
}
/*
- *******
- OSTAIRS
- *******
-
subroutine to process the stair cases
if dir > 0 the up else down
*/
-void
-ostairs(dir)
- int dir;
+static void
+ostairs(int dir)
{
int k;
lprcat("\nDo you (s) stay here ");
lprcat("or (f) kick stairs? ");
while (1)
- switch (lgetchar()) {
+ switch (ttgetch()) {
case '\33':
case 's':
case 'i':
lprcat("\nI hope you feel better. Showing anger rids you of frustration.");
else {
k = rnd((level + 1) << 1);
- lprintf("\nYou hurt your foot dumb dumb! You suffer %d hit points", (long) k);
+ lprintf("\nYou hurt your foot dumb dumb! You suffer %ld hit points", (long) k);
lastnum = 276;
losehp(k);
bottomline();
/*
- *********
- OTELEPORTER
- *********
-
subroutine to handle a teleport trap +/- 1 level maximum
*/
void
-oteleport(err)
- int err;
+oteleport(int err)
{
int tmp;
if (err)
/*
- *******
- OPOTION
- *******
-
function to process a potion
*/
-void
-opotion(pot)
- int pot;
+static void
+opotion(int pot)
{
lprcat("\nDo you (d) drink it, (t) take it");
iopts();
while (1)
- switch (lgetchar()) {
+ switch (ttgetch()) {
case '\33':
case 'i':
ignore();
function to drink a potion
*/
void
-quaffpotion(pot)
- int pot;
+quaffpotion(int pot)
{
int i, j, k;
if (pot < 0 || pot >= MAXPOTION)
/*
- *******
- OSCROLL
- *******
-
function to process a magic scroll
*/
-void
-oscroll(typ)
- int typ;
+static void
+oscroll(int typ)
{
lprcat("\nDo you ");
if (c[BLINDCOUNT] == 0)
lprcat("(t) take it");
iopts();
while (1)
- switch (lgetchar()) {
+ switch (ttgetch()) {
case '\33':
case 'i':
ignore();
CANCELLATION, HASTESELF, GLOBE, SCAREMONST, HOLDMONST, TIMESTOP
};
-u_char time_change[] = {
+static u_char time_change[] = {
HASTESELF, HERO, ALTPRO, PROTECTIONTIME, DEXCOUNT, STRCOUNT,
GIANTSTR, CHARMCOUNT, INVISIBILITY, CANCELLATION, HASTESELF,
AGGRAVATE, SCAREMONST, STEALTH, AWARENESS, HOLDMONST,
* function to adjust time when time warping and taking courses in school
*/
void
-adjusttime(tim)
- long tim;
+adjusttime(long tim)
{
int j;
for (j = 0; j < 26; j++)/* adjust time related parameters */
function to read a scroll
*/
void
-read_scroll(typ)
- int typ;
+read_scroll(int typ)
{
int i, j;
if (typ < 0 || typ >= MAXSCROLL)
case 7:
gltime += (i = rnd(1000) - 850); /* time warp */
if (i >= 0)
- lprintf("\nYou went forward in time by %d mobuls", (long) ((i + 99) / 100));
+ lprintf("\nYou went forward in time by %ld mobuls", (long) ((i + 99) / 100));
else
- lprintf("\nYou went backward in time by %d mobuls", (long) (-(i + 99) / 100));
+ lprintf("\nYou went backward in time by %ld mobuls", (long) (-(i + 99) / 100));
adjusttime((long) i); /* adjust time for time warping */
return;
-void
-oorb()
+static void
+oorb(void)
{
}
-void
-opit()
+static void
+opit(void)
{
int i;
if (rnd(101) < 81) {
lprcat("\nYou fell into a pit! Your fall is cushioned by an unknown force\n");
} else {
i = rnd(level * 3 + 3);
- lprintf("\nYou fell into a pit! You suffer %d hit points damage", (long) i);
+ lprintf("\nYou fell into a pit! You suffer %ld hit points damage", (long) i);
lastnum = 261; /* if he dies scoreboard
* will say so */
}
}
}
-void
-obottomless()
+static void
+obottomless(void)
{
lprcat("\nYou fell into a bottomless pit!");
beep();
nap(3000);
died(262);
}
-void
-oelevator(dir)
- int dir;
+
+static void
+oelevator(int dir)
{
#ifdef lint
int x;
#endif /* lint */
}
-void
-ostatue()
+static void
+ostatue(void)
{
}
-void
-omirror()
+static void
+omirror(void)
{
}
-void
-obook()
+static void
+obook(void)
{
lprcat("\nDo you ");
if (c[BLINDCOUNT] == 0)
lprcat("(t) take it");
iopts();
while (1)
- switch (lgetchar()) {
+ switch (ttgetch()) {
case '\33':
case 'i':
ignore();
function to read a book
*/
void
-readbook(lev)
- int lev;
+readbook(int lev)
{
int i, tmp;
if (lev <= 3)
}
}
-void
-ocookie()
+static void
+ocookie(void)
{
- char *p;
+ const char *p;
+
lprcat("\nDo you (e) eat it, (t) take it");
iopts();
while (1)
- switch (lgetchar()) {
+ switch (ttgetch()) {
case '\33':
case 'i':
ignore();
* routine to pick up some gold -- if arg==OMAXGOLD then the pile is worth
* 100* the argument
*/
-void
-ogold(arg)
- int arg;
+static void
+ogold(int arg)
{
long i;
i = iarg[playerx][playery];
i *= 1000;
else if (arg == ODGOLD)
i *= 10;
- lprintf("\nIt is worth %d!", (long) i);
+ lprintf("\nIt is worth %ld!", (long) i);
c[GOLD] += i;
bottomgold();
item[playerx][playery] = know[playerx][playery] = 0; /* destroy gold */
}
-void
-ohome()
+static void
+ohome(void)
{
int i;
nosignal = 1; /* disable signals */
died(269);
}
lprcat("\nThe diagnosis is confirmed as dianthroritis. He guesses that\n");
- lprintf("your daughter has only %d mobuls left in this world. It's up to you,\n", (long) ((TIMELIMIT - gltime + 99) / 100));
+ lprintf("your daughter has only %ld mobuls left in this world. It's up to you,\n", (long) ((TIMELIMIT - gltime + 99) / 100));
lprintf("%s, to find the only hope for your daughter, the very rare\n", logname);
lprcat("potion of cure dianthroritis. It is rumored that only deep in the\n");
lprcat("depths of the caves can this potion be found.\n\n\n");
lprcat(" to continue, ");
standout("escape");
lprcat(" to leave ----- ");
- i = lgetchar();
+ i = ttgetch();
while (i != '\33' && i != '\n')
- i = lgetchar();
+ i = ttgetch();
if (i == '\33') {
drawscreen();
nosignal = 0; /* enable signals */
/* routine to save program space */
void
-iopts()
+iopts(void)
{
lprcat(", or (i) ignore it? ");
}
void
-ignore()
+ignore(void)
{
lprcat("ignore\n");
}