$NetBSD: patch-an,v 1.1.1.1 2001/04/27 15:27:32 agc Exp $ --- main.c.orig Fri Jun 19 13:55:33 1992 +++ main.c Sat Jan 13 21:53:56 2001 @@ -1,5 +1,8 @@ /* main.c */ /* This game is bad for you. It is evil. It will rot your brain. */ +#include +#include +#include #include "header.h" #include "player.h" #include "itm.h" @@ -40,7 +43,7 @@ ************ */ -main (argc, argv) +int main (argc, argv) int argc; char *argv[]; { @@ -55,14 +58,21 @@ /* * first task is to identify the player */ - if ((ptr = getlogin()) == (char *)NULL) { - if (pwe=getpwuid(geteuid())) + ptr = getlogin(); + if (ptr == (char *)NULL) { + pwe = getpwuid(geteuid()); + if (pwe) { ptr = pwe->pw_name; - else if ((ptr = getenv("LOGNAME")) == (char *)NULL) - if ((ptr = getenv("USER")) == (char *)NULL) { -noone: fprintf(stderr,"Who *are* you?\n"); - exit(1); - } + } else { + ptr = getenv("LOGNAME"); + if (ptr == (char *)NULL) { + ptr = getenv("USER"); + if (ptr == (char *)NULL) { +noone: fprintf(stderr,"Who *are* you?\n"); + exit(1); + } + } + } } if (ptr==(char *)NULL) goto noone; @@ -109,6 +119,9 @@ init_cells(); /* initialize dungeon storage */ + memset(potionknown, 0, sizeof(potionknown)); + memset(scrollknown, 0, sizeof(scrollknown)); + lcreat((char*)0); newgame(); /* set the initial clock */ hard= -1; @@ -277,6 +290,7 @@ } } /* end main loop */ /* NOTREACHED */ + exit(0); } /* end main */ @@ -285,7 +299,7 @@ * * get and execute a command */ -parse () +void parse (void) { int i,j; int k,flag; @@ -393,7 +407,7 @@ nomove=1; return; /*give the help screen*/ - case 'S': clear(); + case 'S': ularn_clear(); lprcat("Saving . . ."); lflush(); if (savegame(savefilename) == -1 && compress) { @@ -533,18 +547,18 @@ for (i=0; i2) { + if (strlen(scrollname[i])>1) { item[i][0]=OSCROLL; iarg[i][0]=i; } for (i=MAXX-1; i>MAXX-1-MAXPOTION; i--) /* no null items */ - if (strlen(potionname[i-MAXX+MAXPOTION])>2) { + if (strlen(potionname[i-MAXX+MAXPOTION])>1) { item[i][0]=OPOTION; iarg[i][0]=i-MAXX+MAXPOTION; } @@ -619,7 +633,7 @@ } } -parse2 () +void parse2 (void) { if (c[HASTEMONST]) movemonst();