summaryrefslogtreecommitdiffstats
path: root/larn
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2008-01-28 05:38:53 +0000
committerdholland <dholland@NetBSD.org>2008-01-28 05:38:53 +0000
commite30950ccc7c7c31c69f1d31c16b0212bbf168ceb (patch)
tree2db2120a69bedac57d95d284e878f9975b6a17ed /larn
parent9005237a04850abb22afe099ef07649b4115ed3f (diff)
downloadbsdgames-darwin-e30950ccc7c7c31c69f1d31c16b0212bbf168ceb.tar.gz
bsdgames-darwin-e30950ccc7c7c31c69f1d31c16b0212bbf168ceb.tar.zst
bsdgames-darwin-e30950ccc7c7c31c69f1d31c16b0212bbf168ceb.zip
Larn now builds with WARNS=4.
Diffstat (limited to 'larn')
-rw-r--r--larn/Makefile8
-rw-r--r--larn/bill.c8
-rw-r--r--larn/config.c6
-rw-r--r--larn/create.c10
-rw-r--r--larn/data.c26
-rw-r--r--larn/diag.c33
-rw-r--r--larn/display.c130
-rw-r--r--larn/extern.h18
-rw-r--r--larn/fortune.c10
-rw-r--r--larn/global.c27
-rw-r--r--larn/header.h23
-rw-r--r--larn/io.c90
-rw-r--r--larn/main.c43
-rw-r--r--larn/monster.c59
-rw-r--r--larn/moreobj.c14
-rw-r--r--larn/movem.c7
-rw-r--r--larn/object.c18
-rw-r--r--larn/savelev.c8
-rw-r--r--larn/scores.c28
-rw-r--r--larn/store.c16
-rw-r--r--larn/tok.c20
21 files changed, 296 insertions, 306 deletions
diff --git a/larn/Makefile b/larn/Makefile
index b67dd8d3..8008499f 100644
--- a/larn/Makefile
+++ b/larn/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.17 2006/05/11 23:16:28 mrg Exp $
+# $NetBSD: Makefile,v 1.18 2008/01/28 05:38:53 dholland Exp $
# @(#)Makefile 5.12 (Berkeley) 5/30/93
# EXTRA
@@ -74,10 +74,4 @@ FILES=${DAT:S@^@${.CURDIR}/datfiles/@g}
FILESDIR=/usr/share/games/larn
.endif
-.if ${HAVE_GCC} == 4
-.for f in main display data io monster savelev
-COPTS.${f}.c+= -Wno-pointer-sign
-.endfor
-.endif
-
.include <bsd.prog.mk>
diff --git a/larn/bill.c b/larn/bill.c
index 6bcaa3b7..0006482f 100644
--- a/larn/bill.c
+++ b/larn/bill.c
@@ -1,4 +1,4 @@
-/* $NetBSD: bill.c,v 1.7 2003/08/07 09:37:22 agc Exp $ */
+/* $NetBSD: bill.c,v 1.8 2008/01/28 05:38:53 dholland Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)bill.c 5.2 (Berkeley) 5/28/91";
#else
-__RCSID("$NetBSD: bill.c,v 1.7 2003/08/07 09:37:22 agc Exp $");
+__RCSID("$NetBSD: bill.c,v 1.8 2008/01/28 05:38:53 dholland Exp $");
#endif
#endif /* not lint */
@@ -49,7 +49,7 @@ __RCSID("$NetBSD: bill.c,v 1.7 2003/08/07 09:37:22 agc Exp $");
/* bill.c Larn is copyrighted 1986 by Noah Morgan. */
-char *mail[] = {
+const char *mail[] = {
"From: the LRS (Larn Revenue Service)\n",
"~s undeclared income\n",
"\n We have heard you survived the caverns of Larn. Let me be the",
@@ -123,7 +123,7 @@ mailbill()
int i;
char fname[32];
char buf[128];
- char **cp;
+ const char **cp;
int fd;
wait(0);
diff --git a/larn/config.c b/larn/config.c
index 30b64cfd..47aa03ac 100644
--- a/larn/config.c
+++ b/larn/config.c
@@ -1,4 +1,4 @@
-/* $NetBSD: config.c,v 1.5 1997/10/18 20:03:08 christos Exp $ */
+/* $NetBSD: config.c,v 1.6 2008/01/28 05:38:53 dholland Exp $ */
/*
* config.c -- This defines the installation dependent variables.
@@ -10,7 +10,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: config.c,v 1.5 1997/10/18 20:03:08 christos Exp $");
+__RCSID("$NetBSD: config.c,v 1.6 2008/01/28 05:38:53 dholland Exp $");
#endif /* not lint */
#include "header.h"
@@ -43,7 +43,7 @@ char playerids[] = _PATH_PLAYERIDS;
char diagfile[] = "Diagfile"; /* the diagnostic filename */
char ckpfile[] = "Larn12.0.ckp"; /* the checkpoint filename */
-char *password = "pvnert(x)"; /* the wizards password <=32 */
+const char *password = "pvnert(x)"; /* the wizards password <=32 */
char psname[PSNAMESIZE] = "larn"; /* the process name */
#define WIZID 1
diff --git a/larn/create.c b/larn/create.c
index 941f8caa..36bea724 100644
--- a/larn/create.c
+++ b/larn/create.c
@@ -1,10 +1,10 @@
-/* $NetBSD: create.c,v 1.8 2005/02/25 15:04:43 simonb Exp $ */
+/* $NetBSD: create.c,v 1.9 2008/01/28 05:38:53 dholland Exp $ */
/* create.c Larn is copyrighted 1986 by Noah Morgan. */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: create.c,v 1.8 2005/02/25 15:04:43 simonb Exp $");
+__RCSID("$NetBSD: create.c,v 1.9 2008/01/28 05:38:53 dholland Exp $");
#endif /* not lint */
#include "header.h"
@@ -490,12 +490,10 @@ fillmroom(n, what, arg)
fillroom(what, arg);
}
void
-froom(n, itm, arg)
- int n, arg;
- char itm;
+froom(int n, int theitem, int arg)
{
if (rnd(151) < n)
- fillroom(itm, arg);
+ fillroom(theitem, arg);
}
/*
diff --git a/larn/data.c b/larn/data.c
index 81bef8d0..a62eaf5c 100644
--- a/larn/data.c
+++ b/larn/data.c
@@ -1,4 +1,4 @@
-/* $NetBSD: data.c,v 1.11 2007/04/22 02:09:02 mouse Exp $ */
+/* $NetBSD: data.c,v 1.12 2008/01/28 05:38:53 dholland Exp $ */
/*-
* Copyright (c) 1988 The Regents of the University of California.
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)data.c 5.3 (Berkeley) 5/13/91";
#else
-__RCSID("$NetBSD: data.c,v 1.11 2007/04/22 02:09:02 mouse Exp $");
+__RCSID("$NetBSD: data.c,v 1.12 2008/01/28 05:38:53 dholland Exp $");
#endif
#endif /* not lint */
@@ -55,7 +55,7 @@ static char aa6[] = " major deity ";
static char aa7[] = " novice guardian ";
static char aa8[] = "apprentice guardian";
static char aa9[] = " The Creator ";
-u_char *class[] =
+const char *class[] =
{
" novice explorer ", "apprentice explorer", " practiced explorer", /* -3 */
" expert explorer ", " novice adventurer", " adventurer ", /* -6 */
@@ -173,12 +173,12 @@ int enable_scroll = 0; /* constant for enabled/disabled
char aborted[] = " aborted";
struct sphere *spheres = 0; /* pointer to linked list for spheres of
* annihilation */
-char *levelname[] =
+const char *levelname[] =
{" H", " 1", " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10", "V1", "V2", "V3"};
char objnamelist[] = " ATOP%^F&^+M=%^$$f*OD#~][[)))(((||||||||{?!BC}o:@.<<<<EVV))([[]]](^ [H*** ^^ S tsTLc............................................";
char monstnamelist[] = " BGHJKOScjtAELNQRZabhiCTYdegmvzFWflorXV pqsyUkMwDDPxnDDuD ...............................................................";
-char *objectname[] =
+const char *objectname[] =
{0, "a holy altar", "a handsome jewel encrusted throne", "the orb", "a pit",
"a staircase leading upwards", "an elevator going up", "a bubbling fountain",
"a great marble statue", "a teleport trap", "the college of Larn",
@@ -333,10 +333,10 @@ struct monst monster[] = {
/* name array for scrolls */
-char *scrollname[] = {"", "", "", "", "", "", "", "", "", "", "", "", "", "",
+const char *scrollname[] = {"", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", ""};
-char *scrollhide[] = {
+const char *scrollhide[] = {
" enchant armor",
" enchant weapon",
" enlightenment",
@@ -367,12 +367,12 @@ char *scrollhide[] = {
" "
};
-char *potionname[] = {"", "", "", "", "", "", "", "", "", "", "", "", "", "",
+const char *potionname[] = {"", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", ""};
/* name array for magic potions */
-char *potionhide[] = {
+const char *potionhide[] = {
" sleep",
" healing",
" raise level",
@@ -418,7 +418,7 @@ char *potionhide[] = {
u_char spelknow[SPNUM] = {0};
u_char splev[] = {1, 4, 9, 14, 18, 22, 26, 29, 32, 35, 37, 37, 37, 37, 37};
-char *spelcode[] = {
+const char *spelcode[] = {
"pro", "mle", "dex", "sle", "chm", "ssp",
"web", "str", "enl", "hel", "cbl", "cre", "pha", "inv",
"bal", "cld", "ply", "can", "has", "ckl", "vpr",
@@ -427,7 +427,7 @@ char *spelcode[] = {
"sph", "gen", "sum", "wtw", "alt", "per"
};
-char *spelname[] = {
+const char *spelname[] = {
"protection", "magic missile", "dexterity",
"sleep", "charm monster", "sonic spear",
@@ -450,7 +450,7 @@ char *spelname[] = {
""
};
-char *speldescript[] = {
+const char *speldescript[] = {
/* 1 */
"generates a +2 protection field",
"creates and hurls a magic missile equivalent to a +1 magic arrow",
@@ -604,7 +604,7 @@ char spelweird[MAXMONST + 8][SPNUM] = {
};
-char *spelmes[] = {"",
+const char *spelmes[] = {"",
/* 1 */ "the web had no effect on the %s",
/* 2 */ "the %s changed shape to avoid the web",
/* 3 */ "the %s isn't afraid of you",
diff --git a/larn/diag.c b/larn/diag.c
index 486b2ee3..4f8ea899 100644
--- a/larn/diag.c
+++ b/larn/diag.c
@@ -1,9 +1,9 @@
-/* $NetBSD: diag.c,v 1.10 2006/05/11 10:23:24 mrg Exp $ */
+/* $NetBSD: diag.c,v 1.11 2008/01/28 05:38:53 dholland Exp $ */
/* diag.c Larn is copyrighted 1986 by Noah Morgan. */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: diag.c,v 1.10 2006/05/11 10:23:24 mrg Exp $");
+__RCSID("$NetBSD: diag.c,v 1.11 2008/01/28 05:38:53 dholland Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -41,10 +41,10 @@ diag()
/* for the character attributes */
- lprintf("\n\nPlayer attributes:\n\nHit points: %2d(%2d)", (long) c[HP], (long) c[HPMAX]);
- lprintf("\ngold: %d Experience: %d Character level: %d Level in caverns: %d",
+ lprintf("\n\nPlayer attributes:\n\nHit points: %2ld(%2ld)", (long) c[HP], (long) c[HPMAX]);
+ lprintf("\ngold: %ld Experience: %ld Character level: %ld Level in caverns: %ld",
(long) c[GOLD], (long) c[EXPERIENCE], (long) c[LEVEL], (long) level);
- lprintf("\nTotal types of monsters: %d", (long) MAXMONST + 8);
+ lprintf("\nTotal types of monsters: %ld", (long) MAXMONST + 8);
lprcat("\f\nHere's the dungeon:\n\n");
@@ -60,9 +60,9 @@ diag()
lprcat(" Monster Name LEV AC DAM ATT DEF GOLD HP EXP \n");
lprcat("--------------------------------------------------------------------------\n");
for (i = 0; i <= MAXMONST + 8; i++) {
- lprintf("%19s %2d %3d ", monster[i].name, (long) monster[i].level, (long) monster[i].armorclass);
- lprintf(" %3d %3d %3d ", (long) monster[i].damage, (long) monster[i].attack, (long) monster[i].defense);
- lprintf("%6d %3d %6d\n", (long) monster[i].gold, (long) monster[i].hitpoints, (long) monster[i].experience);
+ lprintf("%19s %2ld %3ld ", monster[i].name, (long) monster[i].level, (long) monster[i].armorclass);
+ lprintf(" %3ld %3ld %3ld ", (long) monster[i].damage, (long) monster[i].attack, (long) monster[i].defense);
+ lprintf("%6ld %3ld %6ld\n", (long) monster[i].gold, (long) monster[i].hitpoints, (long) monster[i].experience);
}
lprcat("\n\nHere's a Table for the to hit percentages\n");
@@ -77,7 +77,7 @@ diag()
for (i = 0; i <= MAXMONST + 8; i++) {
hit = 2 * monster[i].armorclass + 2 * monster[i].level + 16;
dam = 16 - c[HARDGAME];
- lprintf("\n%20s %2d/%2d/%2d %2d/%2d/%2d %2d/%2d/%2d",
+ lprintf("\n%20s %2ld/%2ld/%2ld %2ld/%2ld/%2ld %2ld/%2ld/%2ld",
monster[i].name,
(long) (hit / 2), (long) max(0, dam + 2), (long) (monster[i].hitpoints / (dam + 2) + 1),
(long) ((hit + 2) / 2), (long) max(0, dam + 10), (long) (monster[i].hitpoints / (dam + 10) + 1),
@@ -101,9 +101,9 @@ diag()
lprcat("\n\nFor the c[] array:\n");
for (j = 0; j < 100; j += 10) {
- lprintf("\nc[%2d] = ", (long) j);
+ lprintf("\nc[%2ld] = ", (long) j);
for (i = 0; i < 9; i++)
- lprintf("%5d ", (long) c[i + j]);
+ lprintf("%5ld ", (long) c[i + j]);
}
lprcat("\n\nTest of random number generator ----------------");
@@ -114,7 +114,7 @@ diag()
for (i = 0; i < 25000; i++)
rndcount[rund(16)]++;
for (i = 0; i < 16; i++) {
- lprintf(" %5d", (long) rndcount[i]);
+ lprintf(" %5ld", (long) rndcount[i]);
if (i == 7)
lprc('\n');
}
@@ -221,7 +221,7 @@ savegame(fname)
time(&zzz);
lprint((long) (zzz - initialtime));
lwrite((char *) &zzz, sizeof(long));
- if (fstat(lfd, &statbuf) < 0)
+ if (fstat(io_outfd, &statbuf) < 0)
lprint(0L);
else
lprint((long) statbuf.st_ino); /* inode # */
@@ -305,8 +305,8 @@ restoregame(fname)
time(&zzz);
initialtime = zzz - larn_lrint();
- fstat(fd, &filetimes); /* get the creation and modification time of
- * file */
+ /* get the creation and modification time of file */
+ fstat(io_infd, &filetimes);
lrfill((char *) &zzz, sizeof(long));
zzz += 6;
if (filetimes.st_ctime > zzz)
@@ -318,8 +318,9 @@ restoregame(fname)
return;
} /* died a post mortem death */
oldx = oldy = 0;
+ /* XXX the following will break on 64-bit inode numbers */
i = larn_lrint(); /* inode # */
- if (i && (filetimes.st_ino != i))
+ if (i && (filetimes.st_ino != (ino_t) i))
fsorry();
lrclose();
if (strcmp(fname, ckpfile) == 0) {
diff --git a/larn/display.c b/larn/display.c
index 54dd70cc..cb7ef552 100644
--- a/larn/display.c
+++ b/larn/display.c
@@ -1,16 +1,16 @@
-/* $NetBSD: display.c,v 1.6 2008/01/28 03:39:30 dholland Exp $ */
+/* $NetBSD: display.c,v 1.7 2008/01/28 05:38:53 dholland Exp $ */
/* display.c Larn is copyrighted 1986 by Noah Morgan. */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: display.c,v 1.6 2008/01/28 03:39:30 dholland Exp $");
+__RCSID("$NetBSD: display.c,v 1.7 2008/01/28 05:38:53 dholland Exp $");
#endif /* not lint */
#include "header.h"
#include "extern.h"
#define makecode(_a,_b,_c) (((_a)<<16) + ((_b)<<8) + (_c))
-static void botsub(int, char *);
+static void botsub(int, const char *);
static int minx, maxx, miny, maxy, k, m;
static char bot1f = 0, bot2f = 0, bot3f = 0;
@@ -92,31 +92,31 @@ bot_linex()
cbak[i] = c[i];
return;
}
- botsub(makecode(SPELLS, 8, 18), "%3d");
+ botsub(makecode(SPELLS, 8, 18), "%3ld");
if (c[SPELLMAX] > 99)
- botsub(makecode(SPELLMAX, 12, 18), "%3d)");
+ botsub(makecode(SPELLMAX, 12, 18), "%3ld)");
else
- botsub(makecode(SPELLMAX, 12, 18), "%2d) ");
- botsub(makecode(HP, 5, 19), "%3d");
- botsub(makecode(HPMAX, 9, 19), "%3d");
- botsub(makecode(AC, 21, 18), "%-3d");
- botsub(makecode(WCLASS, 30, 18), "%-3d");
- botsub(makecode(EXPERIENCE, 49, 18), "%-9d");
+ botsub(makecode(SPELLMAX, 12, 18), "%2ld) ");
+ botsub(makecode(HP, 5, 19), "%3ld");
+ botsub(makecode(HPMAX, 9, 19), "%3ld");
+ botsub(makecode(AC, 21, 18), "%-3ld");
+ botsub(makecode(WCLASS, 30, 18), "%-3ld");
+ botsub(makecode(EXPERIENCE, 49, 18), "%-9ld");
if (c[LEVEL] != cbak[LEVEL]) {
cursor(59, 18);
lprcat(class[c[LEVEL] - 1]);
}
if (c[LEVEL] > 99)
- botsub(makecode(LEVEL, 40, 18), "%3d");
+ botsub(makecode(LEVEL, 40, 18), "%3ld");
else
- botsub(makecode(LEVEL, 40, 18), " %-2d");
+ botsub(makecode(LEVEL, 40, 18), " %-2ld");
c[TMP] = c[STRENGTH] + c[STREXTRA];
- botsub(makecode(TMP, 18, 19), "%-2d");
- botsub(makecode(INTELLIGENCE, 25, 19), "%-2d");
- botsub(makecode(WISDOM, 32, 19), "%-2d");
- botsub(makecode(CONSTITUTION, 39, 19), "%-2d");
- botsub(makecode(DEXTERITY, 46, 19), "%-2d");
- botsub(makecode(CHARISMA, 53, 19), "%-2d");
+ botsub(makecode(TMP, 18, 19), "%-2ld");
+ botsub(makecode(INTELLIGENCE, 25, 19), "%-2ld");
+ botsub(makecode(WISDOM, 32, 19), "%-2ld");
+ botsub(makecode(CONSTITUTION, 39, 19), "%-2ld");
+ botsub(makecode(DEXTERITY, 46, 19), "%-2ld");
+ botsub(makecode(CHARISMA, 53, 19), "%-2ld");
if ((level != cbak[CAVELEVEL]) || (c[TELEFLAG] != cbak[TELEFLAG])) {
if ((level == 0) || (wizard))
c[TELEFLAG] = 0;
@@ -128,7 +128,7 @@ bot_linex()
else
lprcat(levelname[level]);
}
- botsub(makecode(GOLD, 69, 19), "%-6d");
+ botsub(makecode(GOLD, 69, 19), "%-6ld");
botside();
}
@@ -139,8 +139,8 @@ bot_linex()
void
bottomgold()
{
- botsub(makecode(GOLD, 69, 19), "%-6d");
- /* botsub(GOLD,"%-6d",69,19); */
+ botsub(makecode(GOLD, 69, 19), "%-6ld");
+ /* botsub(GOLD,"%-6ld",69,19); */
}
/*
@@ -154,7 +154,7 @@ bot_hpx()
recalc();
bot_linex();
} else
- botsub(makecode(HP, 5, 19), "%3d");
+ botsub(makecode(HP, 5, 19), "%3ld");
}
/*
@@ -163,7 +163,7 @@ bot_hpx()
void
bot_spellx()
{
- botsub(makecode(SPELLS, 9, 18), "%2d");
+ botsub(makecode(SPELLS, 9, 18), "%2ld");
}
/*
@@ -171,7 +171,7 @@ bot_spellx()
*/
static struct bot_side_def {
int typ;
- char *string;
+ const char *string;
}
bot_data[] =
{
@@ -217,9 +217,7 @@ botside()
}
static void
-botsub(idx, str)
- int idx;
- char *str;
+botsub(int idx, const char *str)
{
int x, y;
y = idx & 0xff;
@@ -281,7 +279,7 @@ u_char screen[MAXX][MAXY], d_flag; /* template for the screen */
void
drawscreen()
{
- int i, j, k;
+ int i, j, kk;
int lastx, lasty; /* variables used to optimize the
* object printing */
if (d_xmin == 0 && d_xmax == MAXX && d_ymin == 0 && d_ymax == MAXY) {
@@ -299,9 +297,9 @@ drawscreen()
for (j = d_xmin; j < d_xmax; j++)
if (know[j][i] == 0)
screen[j][i] = ' ';
- else if ((k = mitem[j][i]) != 0)
- screen[j][i] = monstnamelist[k];
- else if ((k = item[j][i]) == OWALL)
+ else if ((kk = mitem[j][i]) != 0)
+ screen[j][i] = monstnamelist[kk];
+ else if ((kk = item[j][i]) == OWALL)
screen[j][i] = '#';
else
screen[j][i] = ' ';
@@ -325,10 +323,10 @@ drawscreen()
}
while (j <= m) {
if (j <= m - 3) {
- for (k = j; k <= j + 3; k++)
- if (screen[k][i] != ' ')
- k = 1000;
- if (k < 1000) {
+ for (kk = j; kk <= j + 3; kk++)
+ if (screen[kk][i] != ' ')
+ kk = 1000;
+ if (kk < 1000) {
while (screen[j][i] == ' ' && j <= m)
j++;
cursor(j + 1, i + 1);
@@ -341,15 +339,15 @@ drawscreen()
for (lastx = lasty = 127, i = d_ymin; i < d_ymax; i++)
for (j = d_xmin; j < d_xmax; j++) {
- if ((k = item[j][i]) != 0)
- if (k != OWALL)
+ if ((kk = item[j][i]) != 0)
+ if (kk != OWALL)
if ((know[j][i]) && (mitem[j][i] == 0))
- if (objnamelist[k] != ' ') {
+ if (objnamelist[kk] != ' ') {
if (lasty != i + 1 || lastx != j)
cursor(lastx = j + 1, lasty = i + 1);
else
lastx++;
- lprc(objnamelist[k]);
+ lprc(objnamelist[kk]);
}
}
@@ -375,7 +373,7 @@ void
showcell(x, y)
int x, y;
{
- int i, j, k, m;
+ int i, j, kk, mm;
if (c[BLINDCOUNT])
return; /* see nothing if blind */
if (c[AWARENESS]) {
@@ -400,34 +398,34 @@ showcell(x, y)
maxy = MAXY - 1;
for (j = miny; j <= maxy; j++)
- for (m = minx; m <= maxx; m++)
- if (know[m][j] == 0) {
- cursor(m + 1, j + 1);
+ for (mm = minx; mm <= maxx; mm++)
+ if (know[mm][j] == 0) {
+ cursor(mm + 1, j + 1);
x = maxx;
while (know[x][j])
--x;
- for (i = m; i <= x; i++) {
- if ((k = mitem[i][j]) != 0)
- lprc(monstnamelist[k]);
+ for (i = mm; i <= x; i++) {
+ if ((kk = mitem[i][j]) != 0)
+ lprc(monstnamelist[kk]);
else
- switch (k = item[i][j]) {
+ switch (kk = item[i][j]) {
case OWALL:
case 0:
case OIVTELETRAP:
case OTRAPARROWIV:
case OIVDARTRAP:
case OIVTRAPDOOR:
- lprc(objnamelist[k]);
+ lprc(objnamelist[kk]);
break;
default:
setbold();
- lprc(objnamelist[k]);
+ lprc(objnamelist[kk]);
resetbold();
};
know[i][j] = 1;
}
- m = maxx;
+ mm = maxx;
}
}
@@ -497,42 +495,42 @@ moveplayer(dir)
* [8-southwest] if direction=0, don't
* move--just show where he is */
{
- int k, m, i, j;
+ int kk, mm, i, j;
if (c[CONFUSE])
if (c[LEVEL] < rnd(30))
dir = rund(9); /* if confused any dir */
- k = playerx + diroffx[dir];
- m = playery + diroffy[dir];
- if (k < 0 || k >= MAXX || m < 0 || m >= MAXY) {
+ kk = playerx + diroffx[dir];
+ mm = playery + diroffy[dir];
+ if (kk < 0 || kk >= MAXX || mm < 0 || mm >= MAXY) {
nomove = 1;
return (yrepcount = 0);
}
- i = item[k][m];
- j = mitem[k][m];
+ i = item[kk][mm];
+ j = mitem[kk][mm];
if (i == OWALL && c[WTW] == 0) {
nomove = 1;
return (yrepcount = 0);
} /* hit a wall */
- if (k == 33 && m == MAXY - 1 && level == 1) {
+ if (kk == 33 && mm == MAXY - 1 && level == 1) {
newcavelevel(0);
- for (k = 0; k < MAXX; k++)
- for (m = 0; m < MAXY; m++)
- if (item[k][m] == OENTRANCE) {
- playerx = k;
- playery = m;
+ for (kk = 0; kk < MAXX; kk++)
+ for (mm = 0; mm < MAXY; mm++)
+ if (item[kk][mm] == OENTRANCE) {
+ playerx = kk;
+ playery = mm;
positionplayer();
drawscreen();
return (0);
}
}
if (j > 0) {
- hitmonster(k, m);
+ hitmonster(kk, mm);
return (yrepcount = 0);
} /* hit a monster */
lastpx = playerx;
lastpy = playery;
- playerx = k;
- playery = m;
+ playerx = kk;
+ playery = mm;
if (i && i != OTRAPARROWIV && i != OIVTELETRAP && i != OIVDARTRAP && i != OIVTRAPDOOR)
return (yrepcount = 0);
else
diff --git a/larn/extern.h b/larn/extern.h
index b32ccaa4..ea767e6a 100644
--- a/larn/extern.h
+++ b/larn/extern.h
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.6 2008/01/28 03:39:30 dholland Exp $ */
+/* $NetBSD: extern.h,v 1.7 2008/01/28 05:38:53 dholland Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@@ -81,7 +81,7 @@ void seemagic(int);
void seepage(void);
/* fortune.c */
-char *fortune(void);
+const char *fortune(void);
/* global.c */
void raiselevel(void);
@@ -144,14 +144,14 @@ int lopen(char *);
int lappend(char *);
void lrclose(void);
void lwclose(void);
-void lprcat(char *);
+void lprcat(const char *);
void cursor(int, int);
void cursors(void);
void init_term(void);
void cl_line(int, int);
void cl_up(int, int);
void cl_dn(int, int);
-void standout(char *);
+void standout(const char *);
void set_score_output(void);
void lflush(void);
int xputchar(int);
@@ -170,7 +170,7 @@ void showwield(void);
void showread(void);
void showeat(void);
void showquaff(void);
-void show1(int, char *[]);
+void show1(int, const char *[]);
void show3(int);
void randmonst(void);
void parse(void);
@@ -184,7 +184,7 @@ void dropobj(void);
void readscr(void);
void eatcookie(void);
void quaff(void);
-int whatitem(char *);
+int whatitem(const char *);
unsigned long readnum(long);
void szero(char *);
@@ -198,11 +198,11 @@ void loseint(void);
int isconfuse(void);
int nospell(int, int);
int fullhit(int);
-void direct(int, int, char *, int);
-void godirect(int, int, char *, int, int);
+void direct(int, int, const char *, int);
+void godirect(int, int, const char *, int, int);
void ifblind(int, int);
void tdirect(int);
-void omnidirect(int, int, char *);
+void omnidirect(int, int, const char *);
int vxy(int *, int *);
void dirpoly(int);
void hitmonster(int, int);
diff --git a/larn/fortune.c b/larn/fortune.c
index 0140c05b..84cca6bd 100644
--- a/larn/fortune.c
+++ b/larn/fortune.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fortune.c,v 1.5 2003/08/07 09:37:23 agc Exp $ */
+/* $NetBSD: fortune.c,v 1.6 2008/01/28 05:38:53 dholland Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)fortune.c 5.5 (Berkeley) 6/10/91";
#else
-__RCSID("$NetBSD: fortune.c,v 1.5 2003/08/07 09:37:23 agc Exp $");
+__RCSID("$NetBSD: fortune.c,v 1.6 2008/01/28 05:38:53 dholland Exp $");
#endif
#endif /* not lint */
@@ -48,7 +48,7 @@ __RCSID("$NetBSD: fortune.c,v 1.5 2003/08/07 09:37:23 agc Exp $");
* function to return a random fortune from the fortune file
*/
-char *flines[] = {
+const char *flines[] = {
"gem value = gem * 2 ^ perfection",
"sitting down can have unexpected results",
"don't pry into the affairs of others",
@@ -87,8 +87,8 @@ char *flines[] = {
#define NFORTUNES 34
-char *
-fortune()
+const char *
+fortune(void)
{
return (flines[random() % NFORTUNES]);
}
diff --git a/larn/global.c b/larn/global.c
index 7f03c8b6..28d24b5a 100644
--- a/larn/global.c
+++ b/larn/global.c
@@ -1,4 +1,4 @@
-/* $NetBSD: global.c,v 1.8 2008/01/28 03:39:31 dholland Exp $ */
+/* $NetBSD: global.c,v 1.9 2008/01/28 05:38:53 dholland Exp $ */
/*
* global.c Larn is copyrighted 1986 by Noah Morgan.
@@ -23,7 +23,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: global.c,v 1.8 2008/01/28 03:39:31 dholland Exp $");
+__RCSID("$NetBSD: global.c,v 1.9 2008/01/28 05:38:53 dholland Exp $");
#endif /* not lint */
#include <string.h>
@@ -31,7 +31,6 @@ __RCSID("$NetBSD: global.c,v 1.8 2008/01/28 03:39:31 dholland Exp $");
#include "header.h"
#include "extern.h"
extern int score[], dropflag;
-extern int random; /* the random number seed */
extern char *what[], *who[];
extern char winner[];
extern char sciv[SCORESIZE + 1][26][2];
@@ -472,8 +471,7 @@ more()
returns 0 if success, 1 if a failure
*/
int
-take(itm, arg)
- int itm, arg;
+take(int theitem, int arg)
{
int i, limit;
/* cursors(); */
@@ -481,10 +479,10 @@ take(itm, arg)
limit = 26;
for (i = 0; i < limit; i++)
if (iven[i] == 0) {
- iven[i] = itm;
+ iven[i] = theitem;
ivenarg[i] = arg;
limit = 0;
- switch (itm) {
+ switch (theitem) {
case OPROTRING:
case ODAMRING:
case OBELT:
@@ -545,12 +543,12 @@ int
drop_object(k)
int k;
{
- int itm;
+ int theitem;
if ((k < 0) || (k > 25))
return (0);
- itm = iven[k];
+ theitem = iven[k];
cursors();
- if (itm == 0) {
+ if (theitem == 0) {
lprintf("\nYou don't have item %c! ", k + 'a');
return (1);
}
@@ -561,7 +559,7 @@ drop_object(k)
}
if (playery == MAXY - 1 && playerx == 33)
return (1); /* not in entrance */
- item[playerx][playery] = itm;
+ item[playerx][playery] = theitem;
iarg[playerx][playery] = ivenarg[k];
srcount = 0;
lprcat("\n You drop:");
@@ -574,7 +572,7 @@ drop_object(k)
c[WEAR] = -1;
if (c[SHIELD] == k)
c[SHIELD] = -1;
- adjustcvalues(itm, ivenarg[k]);
+ adjustcvalues(theitem, ivenarg[k]);
dropflag = 1; /* say dropped an item so wont ask to pick it
* up right away */
return (0);
@@ -742,12 +740,11 @@ creategem()
that affects these characteristics
*/
void
-adjustcvalues(itm, arg)
- int itm, arg;
+adjustcvalues(int theitem, int arg)
{
int flag;
flag = 0;
- switch (itm) {
+ switch (theitem) {
case ODEXRING:
c[DEXTERITY] -= arg + 1;
flag = 1;
diff --git a/larn/header.h b/larn/header.h
index cae25fed..d8025583 100644
--- a/larn/header.h
+++ b/larn/header.h
@@ -1,4 +1,4 @@
-/* $NetBSD: header.h,v 1.16 2006/11/24 22:52:16 wiz Exp $ */
+/* $NetBSD: header.h,v 1.17 2008/01/28 05:38:53 dholland Exp $ */
/* header.h Larn is copyrighted 1986 by Noah Morgan. */
@@ -32,7 +32,7 @@
/* this is the structure definition of the monster data */
struct monst {
- char *name;
+ const char *name;
char level;
short armorclass;
char damage;
@@ -332,26 +332,29 @@ struct sphere {
#ifndef NODEFS
extern char VERSION, SUBVERSION;
extern u_char alpha[], beenhere[], boldon, cheat, ckpflag;
-extern u_char *class[], course[];
+extern const char *class[];
+extern u_char course[];
extern char diagfile[], helpfile[], ckpfile[], larnlevels[],
playerids[], optsfile[1024], psname[], savefilename[],
scorefile[];
extern u_char *inbuffer, is_alpha[], is_digit[];
extern u_char item[MAXX][MAXY], iven[], know[MAXX][MAXY];
-extern char *levelname[], logfile[], loginname[], logname[],
- lastmonst[];
+extern const char *levelname[];
+extern char logfile[], loginname[], logname[], lastmonst[];
extern u_char *lpbuf, *lpend;
extern u_char *lpnt, moved[MAXX][MAXY], mitem[MAXX][MAXY], monstlevel[];
extern char monstnamelist[], objnamelist[];
extern u_char nch[], ndgg[], nlpts[], nomove, nosignal, nowelcome;
extern u_char nplt[], nsw[];
-extern char *objectname[], *potionhide[], *potionname[],
- *spelcode[], *spelname[], *spelmes[], aborted[],
- spelweird[MAXMONST + 8][SPNUM];
+extern const char *objectname[];
+extern const char *potionhide[], *potionname[];
+extern const char *spelcode[], *spelname[], *spelmes[];
+extern char aborted[], spelweird[MAXMONST + 8][SPNUM];
extern u_char potprob[];
extern u_char predostuff, restorflag, scprob[];
extern u_char screen[MAXX][MAXY], sex;
-extern char *speldescript[], *scrollhide[], *scrollname[];
+extern const char *speldescript[];
+extern const char *scrollhide[], *scrollname[];
extern u_char spelknow[];
extern u_char splev[], stealth[MAXX][MAXY], to_lower[], to_upper[], wizard;
extern short diroffx[], diroffy[], hitflag, hit2flag, hit3flag, hitp[MAXX][MAXY];
@@ -359,7 +362,7 @@ extern short iarg[MAXX][MAXY], ivenarg[], lasthx, lasthy, lastnum, lastpx,
lastpy;
extern short nobeep, oldx, oldy, playerx, playery, level;
extern int dayplay, enable_scroll, srcount, yrepcount, userid, wisid,
- lfd, fd;
+ io_outfd, io_infd;
extern uid_t uid, euid;
extern long outstanding_taxes, skill[], gltime, c[], cbak[];
extern time_t initialtime;
diff --git a/larn/io.c b/larn/io.c
index 57a1c19b..23ba9969 100644
--- a/larn/io.c
+++ b/larn/io.c
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.18 2008/01/28 04:04:17 dholland Exp $ */
+/* $NetBSD: io.c,v 1.19 2008/01/28 05:38:54 dholland Exp $ */
/*
* io.c Larn is copyrighted 1986 by Noah Morgan.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: io.c,v 1.18 2008/01/28 04:04:17 dholland Exp $");
+__RCSID("$NetBSD: io.c,v 1.19 2008/01/28 05:38:54 dholland Exp $");
#endif /* not lint */
#include "header.h"
@@ -127,8 +127,8 @@ typedef char *va_list;
#endif /* NOVARARGS */
#define LINBUFSIZE 128 /* size of the lgetw() and lgetl() buffer */
-int lfd; /* output file numbers */
-int fd; /* input file numbers */
+int io_outfd; /* output file numbers */
+int io_infd; /* input file numbers */
static struct sgttyb ttx;/* storage for the tty modes */
static int ipoint = MAXIBUF, iepoint = MAXIBUF; /* input buffering
* pointers */
@@ -284,19 +284,21 @@ lwrite(buf, len)
char *buf;
int len;
{
- char *str;
- int num2;
+ char *s;
+ u_char *t;
+ int num2;
+
if (len > 399) { /* don't copy data if can just write it */
#ifdef EXTRA
c[BYTESOUT] += len;
#endif
#ifndef VT100
- for (str = buf; len > 0; --len)
- lprc(*str++);
+ for (s = buf; len > 0; --len)
+ lprc(*s++);
#else /* VT100 */
lflush();
- write(lfd, buf, len);
+ write(io_outfd, buf, len);
#endif /* VT100 */
} else
while (len) {
@@ -306,11 +308,11 @@ lwrite(buf, len)
* output buffer */
if (num2 > len)
num2 = len;
- str = lpnt;
+ t = lpnt;
len -= num2;
while (num2--)
- *str++ = *buf++; /* copy in the bytes */
- lpnt = str;
+ *t++ = *buf++; /* copy in the bytes */
+ lpnt = t;
}
}
@@ -327,7 +329,7 @@ lgetc()
return (inbuffer[ipoint++]);
if (iepoint != MAXIBUF)
return (0);
- if ((i = read(fd, inbuffer, MAXIBUF)) <= 0) {
+ if ((i = read(io_infd, inbuffer, MAXIBUF)) <= 0) {
if (i != 0)
write(1, "error reading from input file\n", 30);
iepoint = ipoint = 0;
@@ -375,12 +377,13 @@ lrfill(adr, num)
char *adr;
int num;
{
- char *pnt;
+ u_char *pnt;
int num2;
+
while (num) {
if (iepoint == ipoint) {
if (num > 5) { /* fast way */
- if (read(fd, adr, num) != num)
+ if (read(io_infd, adr, num) != num)
write(2, "error reading from input file\n", 30);
num = 0;
} else {
@@ -466,15 +469,15 @@ lcreat(str)
lpnt = lpbuf;
lpend = lpbuf + BUFBIG;
if (str == NULL)
- return (lfd = 1);
- if ((lfd = creat(str, 0644)) < 0) {
- lfd = 1;
+ return (io_outfd = 1);
+ if ((io_outfd = creat(str, 0644)) < 0) {
+ io_outfd = 1;
lprintf("error creating file <%s>: %s\n", str,
strerror(errno));
lflush();
return (-1);
}
- return (lfd);
+ return (io_outfd);
}
/*
@@ -490,14 +493,14 @@ lopen(str)
{
ipoint = iepoint = MAXIBUF;
if (str == NULL)
- return (fd = 0);
- if ((fd = open(str, 0)) < 0) {
+ return (io_infd = 0);
+ if ((io_infd = open(str, O_RDONLY)) < 0) {
lwclose();
- lfd = 1;
+ io_outfd = 1;
lpnt = lpbuf;
return (-1);
}
- return (fd);
+ return (io_infd);
}
/*
@@ -514,13 +517,13 @@ lappend(str)
lpnt = lpbuf;
lpend = lpbuf + BUFBIG;
if (str == NULL)
- return (lfd = 1);
- if ((lfd = open(str, 2)) < 0) {
- lfd = 1;
+ return (io_outfd = 1);
+ if ((io_outfd = open(str, 2)) < 0) {
+ io_outfd = 1;
return (-1);
}
- lseek(lfd, 0, 2); /* seek to end of file */
- return (lfd);
+ lseek(io_outfd, 0, SEEK_END); /* seek to end of file */
+ return (io_outfd);
}
/*
@@ -531,8 +534,10 @@ lappend(str)
void
lrclose()
{
- if (fd > 0)
- close(fd);
+ if (io_infd > 0) {
+ close(io_infd);
+ io_infd = 0;
+ }
}
/*
@@ -544,8 +549,10 @@ void
lwclose()
{
lflush();
- if (lfd > 2)
- close(lfd);
+ if (io_outfd > 2) {
+ close(io_outfd);
+ io_outfd = 1;
+ }
}
/*
@@ -553,10 +560,9 @@ lwclose()
* avoids calls to lprintf (time consuming)
*/
void
-lprcat(str)
- char *str;
+lprcat(const char *str)
{
- char *str2;
+ u_char *str2;
if (lpnt >= lpend)
lflush();
str2 = lpnt;
@@ -768,8 +774,7 @@ cl_dn(x, y)
* standout(str) Print the argument string in inverse video (standout mode).
*/
void
-standout(str)
- char *str;
+standout(const char *str)
{
#ifdef VT100
setbold();
@@ -818,7 +823,7 @@ lflush()
#endif
if (enable_scroll <= -1) {
flush_buf();
- if (write(lfd, lpbuf, lpoint) != lpoint)
+ if (write(io_outfd, lpbuf, lpoint) != lpoint)
write(2, "error writing to output file\n", 29);
lpnt = lpbuf; /* point back to beginning of buffer */
return;
@@ -936,7 +941,7 @@ lflush()
#ifdef EXTRA
c[BYTESOUT] += lpoint;
#endif
- if (write(lfd, lpbuf, lpoint) != lpoint)
+ if (write(io_outfd, lpbuf, lpoint) != lpoint)
write(2, "error writing to output file\n", 29);
}
lpnt = lpbuf; /* point back to beginning of buffer */
@@ -949,10 +954,9 @@ static int vindex = 0;
* xputchar(ch) Print one character in decoded output buffer.
*/
int
-xputchar(c)
- int c;
+xputchar(int ch)
{
- outbuf[vindex++] = c;
+ outbuf[vindex++] = ch;
if (vindex >= BUFBIG)
flush_buf();
return (0);
@@ -965,7 +969,7 @@ void
flush_buf()
{
if (vindex)
- write(lfd, outbuf, vindex);
+ write(io_outfd, outbuf, vindex);
vindex = 0;
}
diff --git a/larn/main.c b/larn/main.c
index 0a9592bb..a7027b70 100644
--- a/larn/main.c
+++ b/larn/main.c
@@ -1,9 +1,9 @@
-/* $NetBSD: main.c,v 1.19 2008/01/28 03:39:31 dholland Exp $ */
+/* $NetBSD: main.c,v 1.20 2008/01/28 05:38:54 dholland Exp $ */
/* main.c */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: main.c,v 1.19 2008/01/28 03:39:31 dholland Exp $");
+__RCSID("$NetBSD: main.c,v 1.20 2008/01/28 05:38:54 dholland Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -576,7 +576,7 @@ showquaff()
void
show1(idx, str2)
int idx;
- char *str2[];
+ const char *str2[];
{
lprintf("\n%c) %s", idx + 'a', objectname[iven[idx]]);
if (str2 != 0 && str2[ivenarg[idx]][0] != 0)
@@ -584,15 +584,14 @@ show1(idx, str2)
}
void
-show3(index)
- int index;
+show3(int indx)
{
- switch (iven[index]) {
+ switch (iven[indx]) {
case OPOTION:
- show1(index, potionname);
+ show1(indx, potionname);
break;
case OSCROLL:
- show1(index, scrollname);
+ show1(indx, scrollname);
break;
case OLARNEYE:
@@ -606,20 +605,20 @@ show3(index)
case OCOOKIE:
case OSAPPHIRE:
case ONOTHEFT:
- show1(index, (char **) 0);
+ show1(indx, NULL);
break;
default:
- lprintf("\n%c) %s", index + 'a', objectname[iven[index]]);
- if (ivenarg[index] > 0)
- lprintf(" + %ld", (long) ivenarg[index]);
- else if (ivenarg[index] < 0)
- lprintf(" %ld", (long) ivenarg[index]);
+ lprintf("\n%c) %s", indx + 'a', objectname[iven[indx]]);
+ if (ivenarg[indx] > 0)
+ lprintf(" + %ld", (long) ivenarg[indx]);
+ else if (ivenarg[indx] < 0)
+ lprintf(" %ld", (long) ivenarg[indx]);
break;
}
- if (c[WIELD] == index)
+ if (c[WIELD] == indx)
lprcat(" (weapon in hand)");
- if ((c[WEAR] == index) || (c[SHIELD] == index))
+ if ((c[WEAR] == indx) || (c[SHIELD] == indx))
lprcat(" (being worn)");
if (++srcount >= 22) {
srcount = 0;
@@ -1105,7 +1104,7 @@ void
dropobj()
{
int i;
- char *p;
+ unsigned char *p;
long amt;
p = &item[playerx][playery];
while (1) {
@@ -1201,10 +1200,11 @@ readscr()
* subroutine to eat a cookie one is carrying
*/
void
-eatcookie()
+eatcookie(void)
{
- int i;
- char *p;
+ const char *p;
+ int i;
+
while (1) {
if ((i = whatitem("eat")) == '\33')
return;
@@ -1268,8 +1268,7 @@ quaff()
function to ask what player wants to do
*/
int
-whatitem(str)
- char *str;
+whatitem(const char *str)
{
int i;
cursors();
diff --git a/larn/monster.c b/larn/monster.c
index ab78b91e..fd5c942d 100644
--- a/larn/monster.c
+++ b/larn/monster.c
@@ -1,4 +1,4 @@
-/* $NetBSD: monster.c,v 1.12 2008/01/28 03:39:31 dholland Exp $ */
+/* $NetBSD: monster.c,v 1.13 2008/01/28 05:38:54 dholland Exp $ */
/*
* monster.c Larn is copyrighted 1986 by Noah Morgan.
@@ -100,7 +100,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: monster.c,v 1.12 2008/01/28 03:39:31 dholland Exp $");
+__RCSID("$NetBSD: monster.c,v 1.13 2008/01/28 05:38:54 dholland Exp $");
#endif /* not lint */
#include <string.h>
@@ -169,15 +169,14 @@ createmonster(mon)
* This routine will return FALSE if at a wall or the dungeon exit on level 1
*/
int
-cgood(x, y, itm, monst)
- int x, y;
- int itm, monst;
+cgood(int x, int y, int theitem, int monst)
{
+#define itm __lose
if ((y >= 0) && (y <= MAXY - 1) && (x >= 0) && (x <= MAXX - 1))
/* within bounds? */
if (item[x][y] != OWALL) /* can't make anything on walls */
/* is it free of items? */
- if (itm == 0 || (item[x][y] == 0))
+ if (theitem == 0 || (item[x][y] == 0))
/* is it free of monsters? */
if (monst == 0 || (mitem[x][y] == 0))
if ((level != 1) || (x != 33) ||
@@ -271,12 +270,12 @@ over: lprcat(aborted);
* Please insure that there are 2 spaces before all messages here
*/
void
-speldamage(x)
- int x;
+speldamage(int x)
{
int i, j, clev;
int xl, xh, yl, yh;
- char *p, *kn, *pm;
+ u_char *p, *kn, *pm;
+
if (x >= SPNUM)
return; /* no such spell */
if (c[TIMESTOP]) {
@@ -313,10 +312,10 @@ speldamage(x)
c[DEXCOUNT] += 400;
return;
- case 3:
+ case 3: /* sleep */
i = rnd(3) + 1;
- p = " While the %s slept, you smashed it %d times";
-ws: direct(x, fullhit(i), p, i); /* sleep */
+ direct(x, fullhit(i),
+ " While the %s slept, you smashed it %ld times", i);
return;
case 4: /* charm monster */
@@ -329,10 +328,11 @@ ws: direct(x, fullhit(i), p, i); /* sleep */
/* ----- LEVEL 2 SPELLS ----- */
- case 6:
+ case 6: /* web */
i = rnd(3) + 2;
- p = " While the %s is entangled, you hit %d times";
- goto ws; /* web */
+ direct(x, fullhit(i),
+ " While the %s is entangled, you hit %ld times", i);
+ return;
case 7:
if (c[STRCOUNT] == 0)
@@ -713,7 +713,7 @@ fullhit(xx)
void
direct(spnum, dam, str, arg)
int spnum, dam, arg;
- char *str;
+ const char *str;
{
int x, y;
int m;
@@ -775,9 +775,9 @@ direct(spnum, dam, str, arg)
void
godirect(spnum, dam, str, delay, cshow)
int spnum, dam, delay;
- char *str, cshow;
+ const char *str, cshow;
{
- char *p;
+ u_char *p;
int x, y, m;
int dx, dy;
if (spnum < 0 || spnum >= SPNUM || str == 0 || delay < 0)
@@ -897,10 +897,10 @@ godirect(spnum, dam, str, delay, cshow)
* Returns no value.
*/
void
-ifblind(x, y)
- int x, y;
+ifblind(int x, int y)
{
- char *p;
+ const char *p;
+
vxy(&x, &y); /* verify correct x,y coordinates */
if (c[BLINDCOUNT]) {
lastnum = 279;
@@ -956,11 +956,10 @@ tdirect(spnum)
* Returns no value.
*/
void
-omnidirect(spnum, dam, str)
- int spnum, dam;
- char *str;
+omnidirect(int spnum, int dam, const char *str)
{
int x, y, m;
+
if (spnum < 0 || spnum >= SPNUM || str == 0)
return; /* bad args */
for (x = playerx - 1; x < playerx + 2; x++)
@@ -1337,16 +1336,15 @@ dropgold(amount)
* Returns nothing of value.
*/
void
-something(level)
- int level;
+something(int cavelevel)
{
int j;
int i;
- if (level < 0 || level > MAXLEVEL + MAXVLEVEL)
+ if (cavelevel < 0 || cavelevel > MAXLEVEL + MAXVLEVEL)
return; /* correct level? */
if (rnd(101) < 8)
- something(level); /* possibly more than one item */
- j = newobject(level, &i);
+ something(cavelevel); /* possibly more than one item */
+ j = newobject(cavelevel, &i);
createitem(j, i);
}
@@ -1506,7 +1504,8 @@ spattack(x, xx, yy)
int x, xx, yy;
{
int i, j = 0, k, m;
- char *p = 0;
+ const char *p = NULL;
+
if (c[CANCELLATION])
return (0);
vxy(&xx, &yy); /* verify x & y coordinates */
diff --git a/larn/moreobj.c b/larn/moreobj.c
index b9ace546..70853acb 100644
--- a/larn/moreobj.c
+++ b/larn/moreobj.c
@@ -1,4 +1,4 @@
-/* $NetBSD: moreobj.c,v 1.7 2008/01/28 03:39:31 dholland Exp $ */
+/* $NetBSD: moreobj.c,v 1.8 2008/01/28 05:38:54 dholland Exp $ */
/*
* moreobj.c Larn is copyrighted 1986 by Noah Morgan.
@@ -9,7 +9,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: moreobj.c,v 1.7 2008/01/28 03:39:31 dholland Exp $");
+__RCSID("$NetBSD: moreobj.c,v 1.8 2008/01/28 05:38:54 dholland Exp $");
#endif /* not lint */
#include <stdlib.h>
#include <unistd.h>
@@ -29,7 +29,7 @@ static void fch(int, long *);
void
oaltar()
{
- unsigned long k;
+ long amt;
lprcat("\nDo you (p) pray (d) desecrate");
iopts();
@@ -66,13 +66,13 @@ oaltar()
cursor(1, 23);
cltoeoln();
lprcat("how much do you donate? ");
- k = readnum((long) c[GOLD]);
- if (c[GOLD] < k) {
+ amt = readnum((long) c[GOLD]);
+ if (amt < 0 || c[GOLD] < amt) {
lprcat("\nYou don't have that much!");
return;
}
- c[GOLD] -= k;
- if (k < c[GOLD] / 10 || k < rnd(50)) {
+ c[GOLD] -= amt;
+ if (amt < c[GOLD] / 10 || amt < rnd(50)) {
createmonster(makemonst(level + 1));
c[AGGRAVATE] += 200;
} else if (rnd(101) > 50) {
diff --git a/larn/movem.c b/larn/movem.c
index 55a3d27b..99336abe 100644
--- a/larn/movem.c
+++ b/larn/movem.c
@@ -1,4 +1,4 @@
-/* $NetBSD: movem.c,v 1.5 1997/10/18 20:03:34 christos Exp $ */
+/* $NetBSD: movem.c,v 1.6 2008/01/28 05:38:54 dholland Exp $ */
/*
* movem.c (move monster) Larn is copyrighted 1986 by Noah Morgan.
@@ -12,7 +12,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: movem.c,v 1.5 1997/10/18 20:03:34 christos Exp $");
+__RCSID("$NetBSD: movem.c,v 1.6 2008/01/28 05:38:54 dholland Exp $");
#endif /* not lint */
#include "header.h"
@@ -274,7 +274,8 @@ mmove(aa, bb, cc, dd)
int aa, bb, cc, dd;
{
int tmp, i, flag;
- char *who = NULL, *p;
+ const char *who = NULL, *p;
+
flag = 0; /* set to 1 if monster hit by arrow trap */
if ((cc == playerx) && (dd == playery)) {
hitplayer(aa, bb);
diff --git a/larn/object.c b/larn/object.c
index 43889b8b..a5564723 100644
--- a/larn/object.c
+++ b/larn/object.c
@@ -1,10 +1,10 @@
-/* $NetBSD: object.c,v 1.11 2008/01/28 03:39:31 dholland Exp $ */
+/* $NetBSD: object.c,v 1.12 2008/01/28 05:38:54 dholland Exp $ */
/* object.c Larn is copyrighted 1986 by Noah Morgan. */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: object.c,v 1.11 2008/01/28 03:39:31 dholland Exp $");
+__RCSID("$NetBSD: object.c,v 1.12 2008/01/28 05:38:54 dholland Exp $");
#endif /* not lint */
#include "header.h"
#include "extern.h"
@@ -498,13 +498,12 @@ lookforobject()
function to say what object we found and ask if player wants to take it
*/
void
-finditem(itm)
- int itm;
+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:
@@ -528,7 +527,7 @@ finditem(itm)
i = lgetchar();
if (i == 't') {
lprcat("take");
- if (take(itm, tmp) == 0)
+ if (take(theitem, tmp) == 0)
forget();
return;
}
@@ -1217,9 +1216,10 @@ readbook(lev)
}
void
-ocookie()
+ocookie(void)
{
- char *p;
+ const char *p;
+
lprcat("\nDo you (e) eat it, (t) take it");
iopts();
while (1)
diff --git a/larn/savelev.c b/larn/savelev.c
index 88c4849f..06e77d9a 100644
--- a/larn/savelev.c
+++ b/larn/savelev.c
@@ -1,9 +1,9 @@
-/* $NetBSD: savelev.c,v 1.4 1997/10/18 20:03:45 christos Exp $ */
+/* $NetBSD: savelev.c,v 1.5 2008/01/28 05:38:54 dholland Exp $ */
/* savelev.c Larn is copyrighted 1986 by Noah Morgan. */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: savelev.c,v 1.4 1997/10/18 20:03:45 christos Exp $");
+__RCSID("$NetBSD: savelev.c,v 1.5 2008/01/28 05:38:54 dholland Exp $");
#endif /* not lint */
#include "header.h"
#include "extern.h"
@@ -15,7 +15,7 @@ void
savelevel()
{
struct cel *pcel;
- char *pitem, *pknow, *pmitem;
+ u_char *pitem, *pknow, *pmitem;
short *phitp, *piarg;
struct cel *pecel;
pcel = &cell[level * MAXX * MAXY]; /* pointer to this level's
@@ -43,7 +43,7 @@ void
getlevel()
{
struct cel *pcel;
- char *pitem, *pknow, *pmitem;
+ u_char *pitem, *pknow, *pmitem;
short *phitp, *piarg;
struct cel *pecel;
pcel = &cell[level * MAXX * MAXY]; /* pointer to this level's
diff --git a/larn/scores.c b/larn/scores.c
index ccddeb8a..27b9a13f 100644
--- a/larn/scores.c
+++ b/larn/scores.c
@@ -1,4 +1,4 @@
-/* $NetBSD: scores.c,v 1.14 2008/01/28 03:39:31 dholland Exp $ */
+/* $NetBSD: scores.c,v 1.15 2008/01/28 05:38:54 dholland Exp $ */
/*
* scores.c Larn is copyrighted 1986 by Noah Morgan.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: scores.c,v 1.14 2008/01/28 03:39:31 dholland Exp $");
+__RCSID("$NetBSD: scores.c,v 1.15 2008/01/28 05:38:54 dholland Exp $");
#endif /* not lint */
#include <sys/types.h>
#include <sys/times.h>
@@ -86,7 +86,7 @@ struct log_fmt { /* 102 bytes struct for the log file */
static struct scofmt sco[SCORESIZE]; /* the structure for the scoreboard */
static struct wscofmt winr[SCORESIZE]; /* struct for the winning scoreboard */
static struct log_fmt logg; /* structure for the log file */
-static char *whydead[] = {
+static const char *whydead[] = {
"quit", "suspended", "self - annihilated", "shot by an arrow",
"hit by a dart", "fell into a pit", "fell into a bottomless pit",
"a winner", "trapped in solid rock", "killed by a missing save file",
@@ -595,7 +595,8 @@ died(x)
int x;
{
int f, win;
- char ch, *mod;
+ char ch;
+ const char *mod;
time_t zzz;
if (c[LIFEPROT] > 0) { /* if life protection */
switch ((x > 0) ? x : -x) {
@@ -732,10 +733,11 @@ invalid:
* int x;
*/
void
-diedsub(x)
- int x;
+diedsub(int x)
{
- char ch, *mod;
+ char ch;
+ const char *mod;
+
lprintf("Score: %ld, Diff: %ld, %s ", (long) c[GOLD], (long) c[HARDGAME], logname);
if (x < 256) {
ch = *monster[x].name;
@@ -766,7 +768,7 @@ diedlog()
lprintf("Can't locate log file <%s>\n", logfile);
return;
}
- if (fstat(fd, &stbuf) < 0) {
+ if (fstat(io_infd, &stbuf) < 0) {
lprintf("Can't stat log file <%s>\n", logfile);
return;
}
@@ -779,10 +781,10 @@ diedlog()
#ifdef EXTRA
if (logg.moves <= 0)
logg.moves = 1;
- lprintf(" Experience Level: %d, AC: %d, HP: %d/%d, Elapsed Time: %d minutes\n", (long) (logg.lev), (long) (logg.ac), (long) (logg.hp), (long) (logg.hpmax), (long) (logg.elapsedtime));
- lprintf(" CPU time used: %d seconds, Machine usage: %d.%02d%%\n", (long) (logg.cputime), (long) (logg.usage / 100), (long) (logg.usage % 100));
- lprintf(" BYTES in: %d, out: %d, moves: %d, deaths: %d, spells cast: %d\n", (long) (logg.bytin), (long) (logg.bytout), (long) (logg.moves), (long) (logg.killed), (long) (logg.spused));
- lprintf(" out bytes per move: %d, time per move: %d ms\n", (long) (logg.bytout / logg.moves), (long) ((logg.cputime * 1000) / logg.moves));
+ lprintf(" Experience Level: %ld, AC: %ld, HP: %ld/%ld, Elapsed Time: %ld minutes\n", (long) (logg.lev), (long) (logg.ac), (long) (logg.hp), (long) (logg.hpmax), (long) (logg.elapsedtime));
+ lprintf(" CPU time used: %ld seconds, Machine usage: %ld.%02ld%%\n", (long) (logg.cputime), (long) (logg.usage / 100), (long) (logg.usage % 100));
+ lprintf(" BYTES in: %ld, out: %ld, moves: %ld, deaths: %ld, spells cast: %ld\n", (long) (logg.bytin), (long) (logg.bytout), (long) (logg.moves), (long) (logg.killed), (long) (logg.spused));
+ lprintf(" out bytes per move: %ld, time per move: %ld ms\n", (long) (logg.bytout / logg.moves), (long) ((logg.cputime * 1000) / logg.moves));
#endif
}
lflush();
@@ -840,7 +842,7 @@ getplid(nam)
addone:
if (lappend(playerids) < 0)
return (-1); /* can't open file for append */
- lprintf("%d\n%s", (long) ++high, name); /* new id # and name */
+ lprintf("%ld\n%s", (long) ++high, name); /* new id # and name */
lwclose();
lcreat((char *) 0); /* re-open terminal channel */
return (high);
diff --git a/larn/store.c b/larn/store.c
index c598cd39..a3c6abf9 100644
--- a/larn/store.c
+++ b/larn/store.c
@@ -1,4 +1,4 @@
-/* $NetBSD: store.c,v 1.11 2008/01/28 03:39:31 dholland Exp $ */
+/* $NetBSD: store.c,v 1.12 2008/01/28 05:38:54 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.11 2008/01/28 03:39:31 dholland Exp $");
+__RCSID("$NetBSD: store.c,v 1.12 2008/01/28 05:38:54 dholland Exp $");
#endif
#endif /* not lint */
@@ -46,7 +46,7 @@ static void handsfull(void);
static void outofstock(void);
static void nogold(void);
static void dnditem(int);
-static void banktitle(char *);
+static void banktitle(const char *);
static void otradhead(void);
static int dndcount = 0, dnditm = 0;
@@ -520,9 +520,9 @@ obank2()
{
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();
@@ -577,7 +577,7 @@ static long gemvalue[26] = {0}; /* the appraisal of the gems */
void
obanksub()
{
- unsigned long amt;
+ long amt;
int i, k;
ointerest(); /* credit any needed interest */
@@ -850,7 +850,7 @@ void
olrs()
{
int i, first;
- unsigned long amt;
+ long amt;
first = nosignal = 1; /* disable signals */
clear();
resetscroll();
@@ -881,7 +881,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':
diff --git a/larn/tok.c b/larn/tok.c
index a713a0c5..f76d5268 100644
--- a/larn/tok.c
+++ b/larn/tok.c
@@ -1,9 +1,9 @@
-/* $NetBSD: tok.c,v 1.6 2006/05/11 00:22:52 mrg Exp $ */
+/* $NetBSD: tok.c,v 1.7 2008/01/28 05:38:54 dholland Exp $ */
/* tok.c Larn is copyrighted 1986 by Noah Morgan. */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: tok.c,v 1.6 2006/05/11 00:22:52 mrg Exp $");
+__RCSID("$NetBSD: tok.c,v 1.7 2008/01/28 05:38:54 dholland Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -178,7 +178,7 @@ sethard(hard)
void
readopts()
{
- char *i;
+ const char *i;
int j, k;
int flag;
flag = 1; /* set to 0 if he specifies a name for his
@@ -189,7 +189,7 @@ readopts()
}
i = " ";
while (*i) {
- if ((i = (char *) lgetw()) == 0)
+ if ((i = lgetw()) == NULL)
break; /* check for EOF */
while ((*i == ' ') || (*i == '\t'))
i++; /* eat leading whitespace */
@@ -218,9 +218,7 @@ readopts()
if (strcmp(i, "monster:") == 0) { /* name favorite monster */
if ((i = lgetw()) == 0)
break;
- if (strlen(i) >= MAXMNAME)
- i[MAXMNAME - 1] = 0;
- strcpy(usermonster[usermpoint], i);
+ strlcpy(usermonster[usermpoint], i, MAXMNAME);
if (usermpoint >= MAXUM)
break; /* defined all of em */
if (isalpha(j = usermonster[usermpoint][0])) {
@@ -238,9 +236,7 @@ readopts()
if (strcmp(i, "name:") == 0) { /* defining players name */
if ((i = lgetw()) == 0)
break;
- if (strlen(i) >= LOGNAMESIZE)
- i[LOGNAMESIZE - 1] = 0;
- strcpy(logname, i);
+ strlcpy(logname, i, LOGNAMESIZE);
flag = 0;
} else if (strcmp(i, "no-introduction") == 0)
nowelcome = 1;
@@ -252,9 +248,7 @@ readopts()
if (strcmp(i, "process-name:") == 0) {
if ((i = lgetw()) == 0)
break;
- if (strlen(i) >= PSNAMESIZE)
- i[PSNAMESIZE - 1] = 0;
- strcpy(psname, i);
+ strlcpy(psname, i, PSNAMESIZE);
} else if (strcmp(i, "play-day-play") == 0)
dayplay = 1;
break;