X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/f12b51f99bbe8bb6ad7eca12b047ba9b46836ee6..3a8de0fa374d25dd9b8c96c15a8ff130376b2e0a:/larn/store.c diff --git a/larn/store.c b/larn/store.c index 7c963d55..2d335380 100644 --- a/larn/store.c +++ b/larn/store.c @@ -1,4 +1,4 @@ -/* $NetBSD: store.c,v 1.9 2003/08/07 09:37:23 agc Exp $ */ +/* $NetBSD: store.c,v 1.16 2012/06/19 05:30:44 dholland Exp $ */ /*- * Copyright (c) 1988 The Regents of the University of California. @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)store.c 5.4 (Berkeley) 5/13/91"; #else -__RCSID("$NetBSD: store.c,v 1.9 2003/08/07 09:37:23 agc Exp $"); +__RCSID("$NetBSD: store.c,v 1.16 2012/06/19 05:30:44 dholland Exp $"); #endif #endif /* not lint */ @@ -42,17 +42,21 @@ __RCSID("$NetBSD: store.c,v 1.9 2003/08/07 09:37:23 agc Exp $"); #include "header.h" #include "extern.h" -static void handsfull __P((void)); -static void outofstock __P((void)); -static void nogold __P((void)); -static void dnditem __P((int)); -static void banktitle __P((char *)); -static void otradhead __P((void)); +static void handsfull(void); +static void outofstock(void); +static void nogold(void); +static void dnditem(int); +static void banktitle(const char *); +static void obanksub(void); +static void otradhead(void); +static void cnsitm(void); static int dndcount = 0, dnditm = 0; +/* number of items in the dnd inventory table */ +#define MAXITM 83 + /* this is the data for the stuff in the dnd store */ -int maxitm = 83; /* number of items in the dnd inventory table */ struct _itm itm[90] = { /* * cost iven name iven arg how gp @@ -187,16 +191,16 @@ struct _itm itm[90] = { /* function for the dnd store */ -void -dnd_2hed() +static void +dnd_2hed(void) { lprcat("Welcome to the Larn Thrift Shoppe. We stock many items explorers find useful\n"); lprcat(" in their adventures. Feel free to browse to your hearts content.\n"); lprcat("Also be advised, if you break 'em, you pay for 'em."); } -void -dnd_hed() +static void +dnd_hed(void) { int i; for (i = dnditm; i < 26 + dnditm; i++) @@ -206,7 +210,7 @@ dnd_hed() } static void -handsfull() +handsfull(void) { lprcat("\nYou can't carry anything more!"); lflush(); @@ -214,7 +218,7 @@ handsfull() } static void -outofstock() +outofstock(void) { lprcat("\nSorry, but we are out of that item."); lflush(); @@ -222,7 +226,7 @@ outofstock() } static void -nogold() +nogold(void) { lprcat("\nYou don't have enough gold to pay for that!"); lflush(); @@ -230,7 +234,7 @@ nogold() } void -dndstore() +dndstore(void) { int i; dnditm = 0; @@ -240,7 +244,7 @@ dndstore() if (outstanding_taxes > 0) { lprcat("\n\nThe Larn Revenue Service has ordered us to not do business with tax evaders.\n"); beep(); - lprintf("They have also told us that you owe %d gp in back taxes, and as we must\n", (long) outstanding_taxes); + lprintf("They have also told us that you owe %ld gp in back taxes, and as we must\n", (long) outstanding_taxes); lprcat("comply with the law, we cannot serve you at this time. Soo Sorry.\n"); cursors(); lprcat("\nPress "); @@ -249,7 +253,7 @@ dndstore() lflush(); i = 0; while (i != '\33') - i = lgetchar(); + i = ttgetch(); drawscreen(); nosignal = 0; /* enable signals */ return; @@ -257,7 +261,7 @@ dndstore() dnd_hed(); while (1) { cursor(59, 18); - lprintf("%d gold pieces", (long) c[GOLD]); + lprintf("%ld gold pieces", (long) c[GOLD]); cltoeoln(); cl_dn(1, 20); /* erase to eod */ lprcat("\nEnter your transaction ["); @@ -267,7 +271,7 @@ dndstore() lprcat(" to leave]? "); i = 0; while ((i < 'a' || i > 'z') && (i != ' ') && (i != '\33') && (i != 12)) - i = lgetchar(); + i = ttgetch(); if (i == 12) { clear(); dnd_2hed(); @@ -278,13 +282,13 @@ dndstore() return; } else if (i == ' ') { cl_dn(1, 4); - if ((dnditm += 26) >= maxitm) + if ((dnditm += 26) >= MAXITM) dnditm = 0; dnd_hed(); } else { /* buy something */ lprc(i);/* echo the byte */ i += dnditm - 'a'; - if (i >= maxitm) + if (i >= MAXITM) outofstock(); else if (itm[i].qty <= 0) outofstock(); @@ -316,11 +320,10 @@ dndstore() to print the item list; used in dndstore() enter with the index into itm */ static void -dnditem(i) - int i; +dnditem(int i) { int j, k; - if (i >= maxitm) + if (i >= MAXITM) return; cursor((j = (i & 1) * 40 + 1), (k = ((i % 26) >> 1) + 5)); if (itm[i].qty == 0) { @@ -335,7 +338,7 @@ dnditem(i) } else lprintf("%s", objectname[itm[i].obj]); cursor(j + 31, k); - lprintf("%6d", (long) (itm[i].price * 10)); + lprintf("%6ld", (long) (itm[i].price * 10)); } @@ -344,12 +347,12 @@ dnditem(i) for the college of larn */ u_char course[26] = {0}; /* the list of courses taken */ -char coursetime[] = {10, 15, 10, 20, 10, 10, 10, 5}; +static char coursetime[] = {10, 15, 10, 20, 10, 10, 10, 5}; /* function to display the header info for the school */ -void -sch_hed() +static void +sch_hed(void) { clear(); lprcat("The College of Larn offers the exciting opportunity of higher education to\n"); @@ -386,7 +389,7 @@ sch_hed() } void -oschool() +oschool(void) { int i; long time_used; @@ -394,7 +397,7 @@ oschool() sch_hed(); while (1) { cursor(57, 18); - lprintf("%d gold pieces. ", (long) c[GOLD]); + lprintf("%ld gold pieces. ", (long) c[GOLD]); cursors(); lprcat("\nWhat is your choice ["); standout("escape"); @@ -402,7 +405,7 @@ oschool() yrepcount = 0; i = 0; while ((i < 'a' || i > 'h') && (i != '\33') && (i != 12)) - i = lgetchar(); + i = ttgetch(); if (i == 12) { sch_hed(); continue; @@ -511,18 +514,18 @@ oschool() int lasttime = 0; /* last time he was in bank */ void -obank() +obank(void) { banktitle(" Welcome to the First National Bank of Larn."); } void -obank2() +obank2(void) { banktitle("Welcome to the 5th level branch office of the First National Bank of Larn."); } + static void -banktitle(str) - char *str; +banktitle(const char *str) { nosignal = 1; /* disable signals */ clear(); @@ -531,7 +534,7 @@ banktitle(str) int i; lprcat("\n\nThe Larn Revenue Service has ordered that your account be frozen until all\n"); beep(); - lprintf("levied taxes have been paid. They have also told us that you owe %d gp in\n", (long) outstanding_taxes); + lprintf("levied taxes have been paid. They have also told us that you owe %ld gp in\n", (long) outstanding_taxes); lprcat("taxes, and we must comply with them. We cannot serve you at this time. Sorry.\n"); lprcat("We suggest you go to the LRS office and pay your taxes.\n"); cursors(); @@ -541,7 +544,7 @@ banktitle(str) lflush(); i = 0; while (i != '\33') - i = lgetchar(); + i = ttgetch(); drawscreen(); nosignal = 0; /* enable signals */ return; @@ -556,7 +559,7 @@ banktitle(str) * function to put interest on your bank account */ void -ointerest() +ointerest(void) { int i; if (c[BANKACCOUNT] < 0) @@ -575,9 +578,9 @@ static short gemorder[26] = {0}; /* the reference to screen location * for each */ static long gemvalue[26] = {0}; /* the appraisal of the gems */ void -obanksub() +obanksub(void) { - unsigned long amt; + long amt; int i, k; ointerest(); /* credit any needed interest */ @@ -599,13 +602,13 @@ obanksub() cursor((k % 2) * 40 + 1, (k >> 1) + 4); lprintf("%c) %s", i + 'a', objectname[iven[i]]); cursor((k % 2) * 40 + 33, (k >> 1) + 4); - lprintf("%5d", (long) gemvalue[i]); + lprintf("%5ld", (long) gemvalue[i]); k++; }; cursor(31, 17); - lprintf("You have %8d gold pieces in the bank.", (long) c[BANKACCOUNT]); + lprintf("You have %8ld gold pieces in the bank.", (long) c[BANKACCOUNT]); cursor(40, 18); - lprintf("You have %8d gold pieces", (long) c[GOLD]); + lprintf("You have %8ld gold pieces", (long) c[GOLD]); if (c[BANKACCOUNT] + c[GOLD] >= 500000) lprcat("\nNote: Larndom law states that only deposits under 500,000gp can earn interest."); while (1) { @@ -622,7 +625,7 @@ obanksub() yrepcount = 0; i = 0; while (i != 'd' && i != 'w' && i != 's' && i != '\33') - i = lgetchar(); + i = ttgetch(); switch (i) { case 'd': lprcat("deposit\nHow much? "); @@ -660,7 +663,7 @@ obanksub() lprcat("\nWhich stone would you like to sell? "); i = 0; while ((i < 'a' || i > 'z') && i != '*') - i = lgetchar(); + i = ttgetch(); if (i == '*') for (i = 0; i < 26; i++) { if (gemvalue[i]) { @@ -691,18 +694,18 @@ obanksub() return; }; cursor(40, 17); - lprintf("%8d", (long) c[BANKACCOUNT]); + lprintf("%8ld", (long) c[BANKACCOUNT]); cursor(49, 18); - lprintf("%8d", (long) c[GOLD]); + lprintf("%8ld", (long) c[GOLD]); } } +#if 0 /* XXX: apparently unused */ /* subroutine to appraise any stone for the bank */ -void -appraise(gemstone) - int gemstone; +static void +appraise(int gemstone) { int j, amt; for (j = 0; j < 26; j++) @@ -721,7 +724,7 @@ appraise(gemstone) amt = 50000; } else amt = (255 & ivenarg[j]) * 100; - lprintf("\nI can see this is an excellent stone, It is worth %d", (long) amt); + lprintf("\nI can see this is an excellent stone, It is worth %ld", (long) amt); lprcat("\nWould you like to sell it to us? "); yrepcount = 0; if (getyn() == 'y') { @@ -736,11 +739,13 @@ appraise(gemstone) lprcat("no\nO. K.\n"); } } +#endif /* 0 - unused */ + /* function for the trading post */ static void -otradhead() +otradhead(void) { clear(); lprcat("Welcome to the Larn Trading Post. We buy items that explorers no longer find\n"); @@ -751,7 +756,7 @@ otradhead() } void -otradepost() +otradepost(void) { int i, j, value, isub, izarg; dnditm = dndcount = 0; @@ -766,7 +771,7 @@ otradepost() lprcat("] ? "); i = 0; while (i > 'z' || (i < 'a' && i != '*' && i != '\33' && i != '.')) - i = lgetchar(); + i = ttgetch(); if (i == '\33') { setscroll(); recalc(); @@ -794,7 +799,7 @@ otradepost() } else if (iven[isub] == 0) lprintf("\nYou don't have item %c!", isub + 'a'); else { - for (j = 0; j < maxitm; j++) + for (j = 0; j < MAXITM; j++) if ((itm[j].obj == iven[isub]) || (iven[isub] == ODIAMOND) || (iven[isub] == ORUBY) || (iven[isub] == OEMERALD) || (iven[isub] == OSAPPHIRE)) { srcount = 0; show3(isub); /* show what the item @@ -812,7 +817,7 @@ otradepost() value *= 2; while ((izarg-- > 0) && ((value = 14 * (67 + value) / 10) < 500000)); } - lprintf("\nItem (%c) is worth %d gold pieces to us. Do you want to sell it? ", i, (long) value); + lprintf("\nItem (%c) is worth %ld gold pieces to us. Do you want to sell it? ", i, (long) value); yrepcount = 0; if (getyn() == 'y') { lprcat("yes\n"); @@ -827,18 +832,18 @@ otradepost() iven[isub] = 0; } else lprcat("no thanks.\n"); - j = maxitm + 100; /* get out of the inner + j = MAXITM + 100; /* get out of the inner * loop */ } - if (j <= maxitm + 2) + if (j <= MAXITM + 2) lprcat("\nSo sorry, but we are not authorized to accept that item."); } } } } -void -cnsitm() +static void +cnsitm(void) { lprcat("\nSorry, we can't accept unidentified objects."); } @@ -847,10 +852,10 @@ cnsitm() * for the Larn Revenue Service */ void -olrs() +olrs(void) { int i, first; - unsigned long amt; + long amt; first = nosignal = 1; /* disable signals */ clear(); resetscroll(); @@ -870,7 +875,7 @@ olrs() yrepcount = 0; i = 0; while (i != 'p' && i != '\33') - i = lgetchar(); + i = ttgetch(); switch (i) { case 'p': lprcat("pay taxes\nHow much? "); @@ -881,7 +886,7 @@ olrs() } else if (amt > c[GOLD]) lprcat(" You don't have that much.\n"); else - c[GOLD] -= paytaxes((long) amt); + c[GOLD] -= paytaxes(amt); break; case '\33': @@ -893,12 +898,12 @@ olrs() nxt: cursor(1, 6); if (outstanding_taxes > 0) - lprintf("You presently owe %d gp in taxes. ", (long) outstanding_taxes); + lprintf("You presently owe %ld gp in taxes. ", (long) outstanding_taxes); else lprcat("You do not owe us any taxes. "); cursor(1, 8); if (c[GOLD] > 0) - lprintf("You have %6d gp. ", (long) c[GOLD]); + lprintf("You have %6ld gp. ", (long) c[GOLD]); else lprcat("You have no gold pieces. "); }