-/* $NetBSD: object.c,v 1.10 2001/02/05 00:57:34 christos Exp $ */
+/* $NetBSD: object.c,v 1.15 2009/08/12 08:04:05 dholland 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.15 2009/08/12 08:04:05 dholland 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.
{
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;
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;
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
+static void
ostairs(dir)
int dir;
{
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
/*
- *******
- OPOTION
- *******
-
function to process a potion
*/
-void
+static void
opotion(pot)
int pot;
{
lprcat("\nDo you (d) drink it, (t) take it");
iopts();
while (1)
- switch (lgetchar()) {
+ switch (ttgetch()) {
case '\33':
case 'i':
ignore();
/*
- *******
- OSCROLL
- *******
-
function to process a magic scroll
*/
-void
+static void
oscroll(typ)
int typ;
{
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,
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
+static void
oorb()
{
}
-void
+static void
opit()
{
int i;
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
+static void
obottomless()
{
lprcat("\nYou fell into a bottomless pit!");
nap(3000);
died(262);
}
-void
+
+static void
oelevator(dir)
int dir;
{
#endif /* lint */
}
-void
+static void
ostatue()
{
}
-void
+static void
omirror()
{
}
-void
+static void
obook()
{
lprcat("\nDo you ");
lprcat("(t) take it");
iopts();
while (1)
- switch (lgetchar()) {
+ switch (ttgetch()) {
case '\33':
case 'i':
ignore();
}
}
-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
+static void
ogold(arg)
int arg;
{
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
+static void
ohome()
{
int i;
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 */