X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/b1c8e14afd5a078ca925fe471733a693ca4a8076..ad0312c45756a5ad1ce7ebda2a0b1b17b71353e8:/larn/object.c?ds=sidebyside diff --git a/larn/object.c b/larn/object.c index 59df0215..1c7e607d 100644 --- a/larn/object.c +++ b/larn/object.c @@ -1,18 +1,31 @@ -/* $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 #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. @@ -22,7 +35,7 @@ lookforobject() { 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; @@ -149,7 +162,7 @@ lookforobject() 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 @@ -174,7 +187,7 @@ lookforobject() 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(); @@ -197,7 +210,7 @@ lookforobject() 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 @@ -220,7 +233,7 @@ lookforobject() iopts(); i = 0; while ((i != 'c') && (i != 'i') && (i != '\33')) - i = lgetchar(); + i = ttgetch(); if ((i == '\33') || (i == 'i')) { ignore(); break; @@ -239,7 +252,7 @@ lookforobject() iopts(); i = 0; while ((i != 'o') && (i != 'i') && (i != '\33')) - i = lgetchar(); + i = ttgetch(); if ((i == '\33') || (i == 'i')) { ignore(); playerx = lastpx; @@ -290,7 +303,7 @@ lookforobject() iopts(); i = 0; while ((i != 'g') && (i != 'i') && (i != '\33')) - i = lgetchar(); + i = ttgetch(); if (i == 'g') { newcavelevel(1); playerx = 33; @@ -310,7 +323,7 @@ lookforobject() iopts(); i = 0; while ((i != 'c') && (i != 'i') && (i != '\33')) - i = lgetchar(); + i = ttgetch(); if ((i == '\33') || (i == 'i')) { ignore(); break; @@ -350,7 +363,7 @@ lookforobject() iopts(); i = 0; while ((i != 'c') && (i != 'i') && (i != '\33')) - i = lgetchar(); + i = ttgetch(); if ((i == '\33') || (i == 'i')) { ignore(); break; @@ -446,7 +459,7 @@ lookforobject() 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 @@ -460,7 +473,7 @@ lookforobject() 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 @@ -481,7 +494,7 @@ lookforobject() 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 @@ -497,14 +510,13 @@ lookforobject() /* 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: @@ -517,18 +529,18 @@ finditem(itm) 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; } @@ -538,14 +550,10 @@ finditem(itm) /* - ******* - OSTAIRS - ******* - subroutine to process the stair cases if dir > 0 the up else down */ -void +static void ostairs(dir) int dir; { @@ -558,7 +566,7 @@ ostairs(dir) lprcat("or (f) kick stairs? "); while (1) - switch (lgetchar()) { + switch (ttgetch()) { case '\33': case 's': case 'i': @@ -571,7 +579,7 @@ ostairs(dir) 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(); @@ -609,10 +617,6 @@ ostairs(dir) /* - ********* - OTELEPORTER - ********* - subroutine to handle a teleport trap +/- 1 level maximum */ void @@ -650,20 +654,16 @@ oteleport(err) /* - ******* - 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(); @@ -863,13 +863,9 @@ quaffpotion(pot) /* - ******* - OSCROLL - ******* - function to process a magic scroll */ -void +static void oscroll(typ) int typ; { @@ -879,7 +875,7 @@ oscroll(typ) lprcat("(t) take it"); iopts(); while (1) - switch (lgetchar()) { + switch (ttgetch()) { case '\33': case 'i': ignore(); @@ -919,7 +915,7 @@ static u_char exten[] = { 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, @@ -996,9 +992,9 @@ read_scroll(typ) 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; @@ -1101,12 +1097,12 @@ read_scroll(typ) -void +static void oorb() { } -void +static void opit() { int i; @@ -1122,7 +1118,7 @@ opit() 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 */ } @@ -1135,7 +1131,7 @@ opit() } } -void +static void obottomless() { lprcat("\nYou fell into a bottomless pit!"); @@ -1143,7 +1139,8 @@ obottomless() nap(3000); died(262); } -void + +static void oelevator(dir) int dir; { @@ -1154,17 +1151,17 @@ oelevator(dir) #endif /* lint */ } -void +static void ostatue() { } -void +static void omirror() { } -void +static void obook() { lprcat("\nDo you "); @@ -1173,7 +1170,7 @@ obook() lprcat("(t) take it"); iopts(); while (1) - switch (lgetchar()) { + switch (ttgetch()) { case '\33': case 'i': ignore(); @@ -1216,14 +1213,15 @@ readbook(lev) } } -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(); @@ -1253,7 +1251,7 @@ ocookie() * routine to pick up some gold -- if arg==OMAXGOLD then the pile is worth * 100* the argument */ -void +static void ogold(arg) int arg; { @@ -1265,13 +1263,13 @@ ogold(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; @@ -1314,7 +1312,7 @@ ohome() 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"); @@ -1323,9 +1321,9 @@ ohome() 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 */