billr@saab.CNA.TEK.COM (Bill Randle) (07/19/89)
Submitted-by: "Scott S. Snyder" <ssnyder@tybalt.caltech.edu>
Posting-number: Volume 7, Issue 43
Archive-name: ularn/Patch2b
Patch-To: ularn: Volume 7, Issue 1-9
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# patch02.2
# This archive created: Sun Jul 16 07:21:36 1989
export PATH; PATH=/bin:$PATH
echo shar: extracting "'patch02.2'" '(55551 characters)'
if test -f 'patch02.2'
then
echo shar: will not over-write existing file "'patch02.2'"
else
sed 's/^X//' << \SHAR_EOF > 'patch02.2'
Xdiff -c orig/main.c new/main.c
X*** orig/main.c Sun Jul 16 01:07:05 1989
X--- new/main.c Sun Jul 16 04:51:44 1989
X***************
X*** 19,25 ****
X--- 19,42 ----
X don't showcell in the main loop */
X
X char restorflag=0; /* 1 means restore has been done */
X+ #ifdef __MSDOS__
X+
X static char cmdhelp[] = "\
X+ Cmd line format: Ularn [-slicnh] [-o<optsfile>] [-##] [++] name\n\
X+ -s show the scoreboard\n\
X+ -i show scoreboard with inventories\n\
X+ -c create new scoreboard (wizard only)\n\
X+ -n suppress welcome message on starting game\n\
X+ -h print this help text\n\
X+ -o<optsfile> specify options file to be used instead of \".Ularnopts\"\n\
X+ -## specify level of difficulty (example: Ularn -5)\n\
X+ ++ restore game checkpoint file\n";
X+
X+ char larnpath[SAVEFILENAMESIZE];
X+
X+ #else /* __MSDOS__ */
X+
X+ static char cmdhelp[] = "\
X Cmd line format: Ularn [-slicnh] [-o<optsfile>] [-##] [++]\n\
X -s show the scoreboard\n\
X -i show scoreboard with inventories\n\
X***************
X*** 28,35 ****
X -h print this help text\n\
X -o<optsfile> specify .Ularnopts file to be used instead of \"~/.Ularnopts\"\n\
X -## specify level of difficulty (example: Ularn -5)\n\
X! -++ restore game checkpoint file\n";
X
X /*
X ************
X MAIN PROGRAM
X--- 45,54 ----
X -h print this help text\n\
X -o<optsfile> specify .Ularnopts file to be used instead of \"~/.Ularnopts\"\n\
X -## specify level of difficulty (example: Ularn -5)\n\
X! ++ restore game checkpoint file\n";
X
X+ #endif /* __MSDOS__ */
X+
X /*
X ************
X MAIN PROGRAM
X***************
X*** 42,55 ****
X {
X register int i;
X int hard;
X char *ptr=0;
X struct passwd *pwe,*getpwuid();
X
X- init_term(); /*setup the terminal (find out what type) for termcap */
X-
X /*
X * first task is to identify the player
X */
X if ((ptr = getlogin()) == NULL)
X if (pwe=getpwuid(geteuid()))
X ptr = pwe->pw_name;
X--- 61,77 ----
X {
X register int i;
X int hard;
X+ #ifdef __MSDOS__
X+ char *p;
X+ #else
X char *ptr=0;
X struct passwd *pwe,*getpwuid();
X+ #endif
X
X /*
X * first task is to identify the player
X */
X+ #ifndef __MSDOS__
X if ((ptr = getlogin()) == NULL)
X if (pwe=getpwuid(geteuid()))
X ptr = pwe->pw_name;
X***************
X*** 60,68 ****
X--- 82,201 ----
X }
X if (ptr==NULL) goto noone;
X if (strlen(ptr)==0) goto noone;
X+ #endif /* __MSDOS__ */
X+
X /*
X+ * allocate the memory for the I/O routines
X+ */
X+
X+ if ( ( lpbuf = malloc ((5* BUFBIG)>>2) ) == (char *)NULL)
X+ died(-285);
X+
X+ if ( ( inbuffer = malloc( (5*MAXIBUF) >>2) ) == (char *)NULL)
X+ died(-285);
X+
X+ /*
X * second task is to prepare the pathnames the player will need
X */
X+
X+ #ifdef __MSDOS__
X+
X+ /*
X+ * try to figure out where our data files are...
X+ *
X+ * first try to find the path where ularn.exe resides.
X+ */
X+
X+ logname[0] = loginname[0] = '\0';
X+
X+ if (strlen(argv[0])+1 > sizeof(larnpath)-12)
X+ argv[0][sizeof(larnpath)-1] = '\0';
X+ strcpy(larnpath, argv[0]);
X+
X+ p = larnpath + strlen(larnpath);
X+ while (--p >= larnpath)
X+ if (*p == '/' || *p == '\\' || *p == ':') break;
X+ *(p + 1) = '\0';
X+
X+ /*
X+ * if an option file name was specified on the command line, try to open it.
X+ */
X+
X+ for (i=1; i<argc; i++)
X+ if (argv[i][0] == '-' && argv[i][1] == 'o') {
X+ strncpy(optsfile, argv[i]+2, SAVEFILENAMESIZE-1);
X+ if (readopts() < 0) {
X+ fprintf(stderr, "Can't open options file %s\n.", optsfile);
X+ exit(1);
X+ }
X+ goto gotopts;
X+ }
X+
X+ /* now look for an option file in the current directory */
X+
X+ strcpy(optsfile, "ularnopt");
X+ if (readopts() < 0) {
X+
X+ /* then look for it in the larn exe directory */
X+
X+ strcpy(optsfile, larnpath);
X+ strcat(optsfile, "ularnopt");
X+ readopts();
X+ }
X+
X+ gotopts:
X+
X+ /*
X+ * if the player game a name on the command line, let it override one
X+ * given in the options file
X+ */
X+
X+ if (argc > 1 && argv[argc-1][0] != '-' && argv[argc-1][0] != '+') {
X+ --argc;
X+ strcpy(logname, argv[argc]);
X+ }
X+
X+ /* if the player didn't specify a name, ask now */
X+
X+ while (logname[0] == '\0') {
X+ char tmp[LOGNAMESIZE];
X+ printf("Who are you: ");
X+ fgets(tmp, sizeof(tmp), stdin);
X+ p = tmp + strlen(tmp);
X+ while (--p >= tmp)
X+ if (*p == '\n' || isspace(*p)) *p = '\0';
X+ else break;
X+ for (p=tmp; *p && isspace(*p); p++)
X+ ;
X+ strcpy(logname, p);
X+ }
X+
X+ /*
X+ * if the save file name wasn't specified in the options file, use the player's
X+ * name in the current directory.
X+ */
X+
X+ if (savefilename[0] == '\0') {
X+ strcpy(savefilename, logname);
X+ savefilename[8] = '\0';
X+ for (p=savefilename; *p; p++)
X+ if (isspace(*p) || *p == '.' || *p == '\\' || *p == '/') {
X+ *p = '\0';
X+ break;
X+ }
X+ strcat(savefilename, ".sav");
X+ }
X+
X+ /* set the paths for the data files */
X+
X+ strcpy(scorefile, larnpath);
X+ strcpy(logfile, larnpath);
X+ strcpy(helpfile, larnpath);
X+ strcpy(larnlevels, larnpath);
X+ strcpy(fortfile, larnpath);
X+
X+ #else /* __MSDOS__ */
X+
X strcpy(loginname,ptr);
X
X /* save loginname of the user for logging purposes */
X***************
X*** 76,83 ****
X /* save file name in home directory */
X strcpy(savefilename, ptr);
X strcat(savefilename, "/Ularn.sav");
X-
X sprintf(optsfile, "%s/.Ularnopts",ptr); /* the .Ularnopts filename */
X strcat(scorefile, SCORENAME); /* the Ularn scoreboard filename */
X strcat(logfile, LOGFNAME);
X
X--- 209,218 ----
X /* save file name in home directory */
X strcpy(savefilename, ptr);
X strcat(savefilename, "/Ularn.sav");
X sprintf(optsfile, "%s/.Ularnopts",ptr); /* the .Ularnopts filename */
X+
X+ #endif /* __MSDOS__ */
X+
X strcat(scorefile, SCORENAME); /* the Ularn scoreboard filename */
X strcat(logfile, LOGFNAME);
X
X***************
X*** 85,104 ****
X strcat(helpfile, HELPNAME); /* the Ularn on-line help file */
X strcat(larnlevels, LEVELSNAME); /* the pre-made cave level data file */
X strcat(fortfile, FORTSNAME); /* the fortune data file name */
X /*
X * now malloc the memory for the dungeon
X */
X- cell = (struct cel *)malloc(sizeof(struct cel)*(MAXLEVEL+MAXVLEVEL)*MAXX*MAXY);
X
X! if (cell == (struct cel *)NULL)
X! died(-285); /* malloc failure */
X
X- if ( ( lpbuf = malloc ((5* BUFBIG)>>2) ) == (char *)NULL)
X- died(-285);
X-
X- if ( ( inbuffer = malloc( (5*MAXIBUF) >>2) ) == (char *)NULL)
X- died(-285);
X-
X lcreat((char*)0);
X newgame(); /* set the initial clock */
X hard= -1;
X--- 220,235 ----
X strcat(helpfile, HELPNAME); /* the Ularn on-line help file */
X strcat(larnlevels, LEVELSNAME); /* the pre-made cave level data file */
X strcat(fortfile, FORTSNAME); /* the fortune data file name */
X+
X+
X+ init_term(); /*setup the terminal (find out what type) for termcap */
X+
X /*
X * now malloc the memory for the dungeon
X */
X
X! init_cells();
X
X lcreat((char*)0);
X newgame(); /* set the initial clock */
X hard= -1;
X***************
X*** 112,117 ****
X--- 243,249 ----
X /*
X * now process the command line arguments
X */
X+
X for (i=1; i<argc; i++) {
X if (argv[i][0] == '-')
X switch(argv[i][1]) {
X***************
X*** 165,176 ****
X }
X
X
X userid = geteuid(); /* obtain the user's effective id number */
X
X sigsetup(); /* trap all needed signals */
X sethard(hard); /* set up the desired difficulty */
X! setupvt100(); /* setup the terminal special mode */
X readopts(); /* read the options file if there is one */
X
X /* restore game if need to */
X if (access(savefilename,0)==0) {
X--- 297,314 ----
X }
X
X
X+ #ifndef __MSDOS__
X userid = geteuid(); /* obtain the user's effective id number */
X+ #else
X+ userid = 42;
X+ #endif
X
X sigsetup(); /* trap all needed signals */
X sethard(hard); /* set up the desired difficulty */
X! #ifndef __MSDOS__ /* if __MSDOS__, we've already done this */
X readopts(); /* read the options file if there is one */
X+ #endif
X+ setupvt100(); /* setup the terminal special mode */
X
X /* restore game if need to */
X if (access(savefilename,0)==0) {
X***************
X*** 321,327 ****
X
X /* count number of items we will display */
X for (count=2,j=0; j<26; j++)
X! if (i=iven[j])
X switch(i) {
X case OLEATHER:
X case OPLATE:
X--- 459,465 ----
X
X /* count number of items we will display */
X for (count=2,j=0; j<26; j++)
X! if ((i=iven[j])!=0)
X switch(i) {
X case OLEATHER:
X case OPLATE:
X***************
X*** 369,375 ****
X srcount=0;
X
X for (count=2,j=0; j<26; j++) /* count how many items */
X! if (i=iven[j])
X switch(i) {
X case ODIAMOND: case ORUBY: case OEMERALD:
X case OSAPPHIRE:
X--- 507,513 ----
X srcount=0;
X
X for (count=2,j=0; j<26; j++) /* count how many items */
X! if ((i=iven[j])!=0)
X switch(i) {
X case ODIAMOND: case ORUBY: case OEMERALD:
X case OSAPPHIRE:
X***************
X*** 1018,1034 ****
X else if (amt<=327670L) {
X *p=ODGOLD;
X i=amt/10;
X! amt = 10*i;
X }
X else if (amt<=3276700L) {
X *p=OMAXGOLD;
X i=amt/100;
X! amt = 100*i;
X }
X else if (amt<=32767000L) {
X *p=OKGOLD;
X i=amt/1000;
X! amt = 1000*i;
X }
X else {
X *p=OKGOLD;
X--- 1156,1172 ----
X else if (amt<=327670L) {
X *p=ODGOLD;
X i=amt/10;
X! amt = 10L*i;
X }
X else if (amt<=3276700L) {
X *p=OMAXGOLD;
X i=amt/100;
X! amt = 100L*i;
X }
X else if (amt<=32767000L) {
X *p=OKGOLD;
X i=amt/1000;
X! amt = 1000L*i;
X }
X else {
X *p=OKGOLD;
X***************
X*** 1085,1091 ****
X lprcat("\nThe cookie was delicious.");
X iven[i-'a']=0;
X if (!c[BLINDCOUNT]) {
X! if (p=fortune(fortfile)) {
X lprcat(" Inside you find a scrap of paper that says:\n");
X lprcat(p);
X }
X--- 1223,1229 ----
X lprcat("\nThe cookie was delicious.");
X iven[i-'a']=0;
X if (!c[BLINDCOUNT]) {
X! if ((p=fortune(fortfile))!=0) {
X lprcat(" Inside you find a scrap of paper that says:\n");
X lprcat(p);
X }
Xdiff -c orig/makehelp.bat new/makehelp.bat
X*** orig/makehelp.bat Sun Jul 16 05:19:23 1989
X--- new/makehelp.bat Sun Jul 16 04:59:03 1989
X***************
X*** 0 ****
X--- 1 ----
X+ to_ansi <uhelp.no_ >uhelp
Xdiff -c orig/monster.c new/monster.c
X*** orig/monster.c Sun Jul 16 01:00:30 1989
X--- new/monster.c Sun Jul 16 04:57:39 1989
X***************
X*** 216,238 ****
X return;
X }
X case ODGOLD :
X! if ( (10 * iarg[x][y] + arg) < 327670L) {
X i = iarg[x][y] ;
X! iarg[x][y] = (10 * i + arg) / 10;
X item[x][y] = ODGOLD;
X return;
X }
X case OMAXGOLD :
X! if ( (100 * iarg[x][y] + arg) < 3276700L) {
X! i = (100 * iarg[x][y]) + arg;
X! iarg[x][y] = i / 100;
X item[x][y] = OMAXGOLD;
X return;
X }
X case OKGOLD :
X! if ( (1000 * iarg[x][y] + arg) < 32767000L) {
X i = iarg[x][y];
X! iarg[x][y] = (1000 * i + arg) / 1000;
X item[x][y] = OKGOLD;
X return;
X }
X--- 216,238 ----
X return;
X }
X case ODGOLD :
X! if ( (10L * iarg[x][y] + arg) < 327670L) {
X i = iarg[x][y] ;
X! iarg[x][y] = (10L * i + arg) / 10;
X item[x][y] = ODGOLD;
X return;
X }
X case OMAXGOLD :
X! if ( (100L * iarg[x][y] + arg) < 3276700L) {
X! i = ((100L * iarg[x][y]) + arg)/100;
X! iarg[x][y] = i;
X item[x][y] = OMAXGOLD;
X return;
X }
X case OKGOLD :
X! if ( (1000L * iarg[x][y] + arg) < 32767000L) {
X i = iarg[x][y];
X! iarg[x][y] = (1000L * i + arg) / 1000;
X item[x][y] = OKGOLD;
X return;
X }
X***************
X*** 401,406 ****
X--- 401,413 ----
X return; /* cure blindness */
X
X case 11:
X+ if (wizard) {
X+ lprintf("Number: ");
X+ if ((i = readnum((long)-1)) != -1) {
X+ createmonster(i);
X+ return;
X+ }
X+ }
X createmonster(makemonst(level+1)+8);
X return;
X
X***************
X*** 885,891 ****
X nap(delay);
X show1cell(x,y);
X }
X! if ((m=mitem[x][y])) /* is there a monster there? */
X {
X ifblind(x,y);
X if (m == LUCIFER || (m>=DEMONLORD && rnd(100)<10) ) {
X--- 892,898 ----
X nap(delay);
X show1cell(x,y);
X }
X! if ((m=mitem[x][y])!=0) /* is there a monster there? */
X {
X ifblind(x,y);
X if (m == LUCIFER || (m>=DEMONLORD && rnd(100)<10) ) {
X***************
X*** 1081,1087 ****
X for (x=playerx-1; x<playerx+2; x++)
X for (y=playery-1; y<playery+2; y++)
X {
X! if (m=mitem[x][y])
X if (nospell(spnum,m) == 0)
X {
X ifblind(x,y);
X--- 1088,1094 ----
X for (x=playerx-1; x<playerx+2; x++)
X for (y=playery-1; y<playery+2; y++)
X {
X! if ((m=mitem[x][y])!=0)
X if (nospell(spnum,m) == 0)
X {
X ifblind(x,y);
X***************
X*** 1227,1233 ****
X hit3flag=1;
X ifblind(x,y);
X
X! tmp = monster[monst].armorclass + c[LEVEL] + c[DEXTERITY] + c[WCLASS/4] -12
X - c[HARDGAME];
X
X cursors();
X--- 1234,1242 ----
X hit3flag=1;
X ifblind(x,y);
X
X! /* this couldn't have been right, could it? */
X! /*tmp = monster[monst].armorclass + c[LEVEL] + c[DEXTERITY] + c[WCLASS/4] -12*/
X! tmp = monster[monst].armorclass + c[LEVEL] + c[DEXTERITY] + c[WCLASS]/4 -12
X - c[HARDGAME];
X
X cursors();
X***************
X*** 1487,1494 ****
X dropgold(amount)
X register int amount;
X {
X! if (amount > 250) createitem(OMAXGOLD, amount);
X! else createitem(OGOLDPILE,amount);
X }
X
X /*
X--- 1496,1503 ----
X dropgold(amount)
X register int amount;
X {
X! if (amount > 250) createitem(OMAXGOLD, (long)amount);
X! else createitem(OGOLDPILE,(long)amount);
X }
X
X /*
X***************
X*** 1510,1516 ****
X if (rnd(101)<8)
X something(lev); /* possibly more than one item */
X j = newobject(lev,&i);
X! createitem(j,i);
X }
X
X /*
X--- 1519,1525 ----
X if (rnd(101)<8)
X something(lev); /* possibly more than one item */
X j = newobject(lev,&i);
X! createitem(j,(long)i);
X }
X
X /*
X***************
X*** 1570,1581 ****
X case 17:
X case 18:
X case 19:
X! if (!(*i=newdagger())) return(0);
X break;
X case 20:
X case 21:
X case 22:
X! if (!(*i=newleather())) return(0);
X break;
X case 23:
X case 32:
X--- 1579,1590 ----
X case 17:
X case 18:
X case 19:
X! if ((*i=newdagger())==0) return(0);
X break;
X case 20:
X case 21:
X case 22:
X! if ((*i=newleather())==0) return(0);
X break;
X case 23:
X case 32:
X***************
X*** 1694,1703 ****
X switch(x) {
X case 1: /* rust your armor, j=1 when rusting has occurred */
X m = k = c[WEAR];
X! if ((i=c[SHIELD]) != -1)
X! if (--ivenarg[i] < -1)
X ivenarg[i]= -1;
X else j=1;
X if ((j==0) && (k != -1)) {
X m = iven[k];
X for (i=0; i<ARMORTYPES; i++)
X--- 1703,1714 ----
X switch(x) {
X case 1: /* rust your armor, j=1 when rusting has occurred */
X m = k = c[WEAR];
X! if ((i=c[SHIELD]) != -1) {
X! --ivenarg[i]; /* avoid TC bug again... */
X! if (ivenarg[i] < -1)
X ivenarg[i]= -1;
X else j=1;
X+ }
X if ((j==0) && (k != -1)) {
X m = iven[k];
X for (i=0; i<ARMORTYPES; i++)
X***************
X*** 1704,1710 ****
X if (m == rustarm[i][0])
X /* find his armor in table */
X {
X! if (--ivenarg[k]< rustarm[i][1])
X ivenarg[k]= rustarm[i][1];
X else j=1;
X break;
X--- 1715,1722 ----
X if (m == rustarm[i][0])
X /* find his armor in table */
X {
X! --ivenarg[k];
X! if (ivenarg[k]< rustarm[i][1])
X ivenarg[k]= rustarm[i][1];
X else j=1;
X break;
Xdiff -c orig/nap.c new/nap.c
X*** orig/nap.c Sun Jul 16 01:07:09 1989
X--- new/nap.c Sun Jul 16 04:37:49 1989
X***************
X*** 2,7 ****
X--- 2,11 ----
X
X #include "header.h"
X
X+ #ifdef __MSDOS__
X+ # include <dos.h>
X+ #endif
X+
X /*
X * routine to take a nap for n milliseconds
X */
X***************
X*** 96,105 ****
X }
X }
X # endif /* SIGVTALARAM */
X! # else /* not BSD */
X napms(time)
X int time;
X {
X } /* do nothing, forget it */
X # endif /* BSD */
X #endif /* SYSV */
X--- 100,139 ----
X }
X }
X # endif /* SIGVTALARAM */
X! # else
X! # ifdef __MSDOS__
X!
X! napms(zzz)
X! int zzz;
X! {
X! time_t targ_time, t;
X! int targ_hund;
X! struct time tm;
X!
X! time(&targ_time);
X! gettime(&tm);
X! targ_hund = tm.ti_hund + zzz/10;
X!
X! while (targ_hund >= 100) {
X! targ_hund -= 100;
X! ++targ_time;
X! }
X!
X! do {
X! time(&t);
X! } while (t < targ_time);
X!
X! do {
X! gettime(&tm);
X! } while (tm.ti_hund < targ_hund);
X! }
X!
X! # else
X!
X napms(time)
X int time;
X {
X } /* do nothing, forget it */
X+ # endif /* __MSDOS__ */
X # endif /* BSD */
X #endif /* SYSV */
Xdiff -c orig/object.c new/object.c
X*** orig/object.c Sun Jul 16 01:00:05 1989
X--- new/object.c Sun Jul 16 04:53:56 1989
X***************
X*** 1131,1138 ****
X {
X register int j;
X for (j=0; j<26; j++) /* adjust time related parameters */
X! if (c[time_change[j]])
X! if ((c[time_change[j]] -= tim) < 1) c[time_change[j]]=1;
X regen();
X }
X
X--- 1131,1144 ----
X {
X register int j;
X for (j=0; j<26; j++) /* adjust time related parameters */
X! if (c[time_change[j]]) {
X! /* this next line rearranged to avoid TC bug */
X! /* if ((c[time_change[j]] -= tim) < 1) c[time_change[j]]=1;*/
X! if (c[time_change[j]] < tim+1)
X! c[time_change[j]] = 1;
X! else
X! c[time_change[j]] -= tim;
X! }
X regen();
X }
X
X***************
X*** 1404,1414 ****
X register int i,tmp;
X
X if (arg<=3)
X! i = rund((tmp=splev[arg])?tmp:1);
X else {
X if (arg >= 21)
X arg = 20; /* # entries in splev = 21 */
X! i = rnd( (tmp=splev[arg]-9) ?tmp:1 ) + 9;
X }
X spelknow[i]=1;
X lprintf("\nSpell \"%s\": %s\n%s",
X--- 1410,1420 ----
X register int i,tmp;
X
X if (arg<=3)
X! i = rund(((tmp=splev[arg])!=0)?tmp:1);
X else {
X if (arg >= 21)
X arg = 20; /* # entries in splev = 21 */
X! i = rnd( ((tmp=splev[arg]-9)!=0) ?tmp:1 ) + 9;
X }
X spelknow[i]=1;
X lprintf("\nSpell \"%s\": %s\n%s",
X***************
X*** 1436,1442 ****
X lprcat("eat\nThe cookie tasted good.");
X forget(); /* no more cookie */
X if (c[BLINDCOUNT]) return;
X! if (!(p=fortune(fortfile))) return;
X lprcat(" A message inside the cookie reads:\n");
X lprcat(p);
X return;
X--- 1442,1448 ----
X lprcat("eat\nThe cookie tasted good.");
X forget(); /* no more cookie */
X if (c[BLINDCOUNT]) return;
X! if ((p=fortune(fortfile)) == NULL) return;
X lprcat(" A message inside the cookie reads:\n");
X lprcat(p);
X return;
Xdiff -c orig/patchlevel.h new/patchlevel.h
X*** orig/patchlevel.h Sun Jul 16 01:07:17 1989
X--- new/patchlevel.h Sun Jul 16 04:58:57 1989
X***************
X*** 1 ****
X! #define PATCHLEVEL 1
X--- 1 ----
X! #define PATCHLEVEL 2
Xdiff -c orig/regen.c new/regen.c
X*** orig/regen.c Sun Jul 16 01:02:38 1989
X--- new/regen.c Sun Jul 16 04:57:57 1989
X***************
X*** 143,149 ****
X }
X if (i!=999)
X if (--d[SEEINVISIBLE]<=0) {
X! monstnamelist[INVISIBLESTALKER] = ' ';
X cursors();
X lprcat("\nYou feel your vision return to normal");
X beep();
X--- 143,150 ----
X }
X if (i!=999)
X if (--d[SEEINVISIBLE]<=0) {
X! monstnamelist[INVISIBLESTALKER] =
X! objnamelist[0];
X cursors();
X lprcat("\nYou feel your vision return to normal");
X beep();
Xdiff -c orig/savelev.c new/savelev.c
X*** orig/savelev.c Sun Jul 16 01:03:14 1989
X--- new/savelev.c Sun Jul 16 06:14:05 1989
X***************
X*** 1,62 ****
X /* savelev.c */
X #include "header.h"
X
X! extern struct cel *cell;
X
X /*
X! * routine to save the present level into storage
X */
X! savelevel()
X {
X! struct cel *pcel;
X! char *pitem,*pknow,*pmitem;
X! short *phitp,*piarg;
X! struct cel *pecel;
X
X! pcel = &cell[level*MAXX*MAXY]; /* pointer to this level's cells */
X
X! /* pointer to past end of this level's cells */
X! pecel = pcel + MAXX*MAXY;
X
X! pitem=item[0];
X! piarg=iarg[0];
X! pknow=know[0];
X! pmitem=mitem[0];
X! phitp=hitp[0];
X! while (pcel < pecel) {
X! pcel->mitem = *pmitem++;
X! pcel->hitp = *phitp++;
X! pcel->item = *pitem++;
X! pcel->know = *pknow++;
X! pcel++->iarg = *piarg++;
X! }
X }
X
X /*
X * routine to restore a level from storage
X */
X getlevel()
X {
X! struct cel *pcel;
X! char *pitem,*pknow,*pmitem;
X! short *phitp,*piarg;
X! struct cel *pecel;
X
X! pcel = &cell[level*MAXX*MAXY]; /* pointer to this level's cells */
X
X! /* pointer to past end of this level's cells */
X! pecel = pcel + MAXX*MAXY;
X
X! pitem=item[0];
X! piarg=iarg[0];
X! pknow=know[0];
X! pmitem=mitem[0];
X! phitp=hitp[0];
X! while (pcel < pecel) {
X! *pmitem++ = pcel->mitem;
X! *phitp++ = pcel->hitp;
X! *pitem++ = pcel->item;
X! *pknow++ = pcel->know;
X! *piarg++ = pcel++->iarg;
X }
X }
X--- 1,626 ----
X /* savelev.c */
X #include "header.h"
X
X! #ifdef __MSDOS__
X
X+ # define SWAPPING
X+
X+ extern unsigned long coreleft(void);
X+
X /*
X! * how much memory must we leave after allocating space for all the
X! * levels? we need memory for the fortune file and for spheres.
X */
X!
X! # define LEFTOVERS 20000
X!
X! #endif
X!
X! /*
X! * When a player leaves a level, the arrays describing that level are
X! * concatenated and placed in a Saved_Level structure. Memory space for
X! * these structures is pointed to by saved_levels[]. For each entry in
X! * saved_levels[], the corresponding entry in slot_in_use[] is 1 if
X! * that entry is currently holding a level, -1 if that level couldn't
X! * be malloc'd, and 0 if it is free. For each level, its entry in
X! * level_locs[] is the index into saved_levels[] where it is stored, or
X! * -1 if it isn't stored there (it is the current level, or it hasn't
X! * been visited yet). If the level is stored in the swapfile, level_loc
X! * is (-2 - swap_slot). slot_time holds the time when the level
X! * in that slot was saved, for implementing LRU swapping. An entry in
X! * swap_slot_in_use is 1 if the slot is in use, 0 if it is free, and -1 if
X! * it hasn't been allocated yet. If swap_slot_in_use[0] == -1, the swapfile
X! * hasn't been opened yet.
X! */
X!
X! typedef char Char_Ary[MAXX][MAXY];
X! typedef short Short_Ary[MAXX][MAXY];
X!
X! /* this is the structure that holds the entire dungeon specifications */
X! typedef struct {
X! Short_Ary hitp;
X! Char_Ary mitem;
X! Char_Ary item;
X! Short_Ary iarg;
X! Char_Ary know;
X! } Saved_Level;
X!
X! #define NLEVELS (MAXLEVEL + MAXVLEVEL)
X!
X! static Saved_Level *saved_levels[NLEVELS];
X!
X! #ifdef SWAPPING
X!
X! static int slot_in_use[NLEVELS], level_locs[NLEVELS];
X! static long slot_time[NLEVELS];
X! static int swap_slot_in_use[NLEVELS];
X! static char swap_file_name[] = "lrnswpxxxxxx";
X! static FILE *swap_fp = NULL;
X!
X! /*
X! * open and close the swap file...
X! */
X!
X! close_swap_file()
X {
X! fclose(swap_fp);
X! unlink(swap_file_name);
X! }
X
X! open_swap_file()
X! {
X! mktemp(swap_file_name);
X! if ((swap_fp = fopen(swap_file_name, "w+b")) == NULL) {
X! perror("Can't open swap file");
X! abort();
X! }
X! lprintf("(Opened swap file)\n");
X
X! atexit(close_swap_file);
X! }
X
X! #define SWAP_SEEK(slot) fseek(swap_fp, (long)(slot)*sizeof(Saved_Level), 0)
X!
X! /*
X! * swap_write: write a level out to the swap file
X! */
X!
X! swap_write(storage, slot)
X! Saved_Level *storage;
X! int slot;
X! {
X! if (swap_fp == NULL || slot < 0 || slot >= NLEVELS || storage == NULL) {
X! puts("swap_write: bogus arguments");
X! abort();
X! }
X!
X! if (SWAP_SEEK(slot) ||
X! fwrite((char *)storage, sizeof(Saved_Level), 1, swap_fp) != 1) {
X! perror("Can't write to swap file");
X! abort();
X! }
X }
X
X /*
X+ * swap_read: read a level in from the swap file
X+ */
X+
X+ swap_read(storage, slot)
X+ Saved_Level *storage;
X+ int slot;
X+ {
X+ if (swap_fp == NULL || slot < 0 || slot >= NLEVELS || storage == NULL) {
X+ puts("swap_read: bogus arguments");
X+ abort();
X+ }
X+
X+ if (SWAP_SEEK(slot) ||
X+ fread((char *)storage, sizeof(Saved_Level), 1, swap_fp) != 1) {
X+ perror("Can't read from swap file");
X+ abort();
X+ }
X+ }
X+
X+ /*
X+ * swap_out_level: swap the least-recently saved level out.
X+ */
X+
X+ swap_out_level()
X+ {
X+ int lru_slot = -1;
X+ long lru_time;
X+ int swap_slot = -1;
X+ int i, level;
X+
X+ time(&lru_time);
X+
X+ for (i=0; i<NLEVELS; i++)
X+ if (slot_in_use[i] == 1 && slot_time[i] < lru_time) {
X+ lru_time = slot_time[i];
X+ lru_slot = i;
X+ }
X+
X+ if (lru_slot == -1) {
X+ puts("swap_out_level: couldn't find a level to swap out!");
X+ abort();
X+ }
X+
X+ for (i=0; i<NLEVELS; i++)
X+ if (swap_slot_in_use[i] != 1) {
X+ if (swap_slot_in_use[i] == -1 && i == 0) open_swap_file();
X+ swap_slot = i;
X+ break;
X+ }
X+
X+ if (swap_slot == -1) {
X+ puts("swap_out_level: couldn't find a free swap slot!");
X+ abort();
X+ }
X+
X+ swap_write(saved_levels[lru_slot], swap_slot);
X+
X+ level=-1;
X+ for (i=0; i<NLEVELS; i++)
X+ if (level_locs[i] == lru_slot) {
X+ level = i;
X+ break;
X+ }
X+
X+ if (level == -1) {
X+ puts("swap_out_level: i couldn't figure out what level i was outswapping");
X+ abort();
X+ }
X+
X+ level_locs[level] = -2-swap_slot;
X+ slot_in_use[lru_slot] = 0;
X+ swap_slot_in_use[swap_slot] = 1;
X+ }
X+
X+ /*
X+ * alloc_level allocates a slot for a new level and returns a pointer to the
X+ * Saved_Level structure. note: this pointer may be invalidated by any
X+ * future calls to get_level or alloc_level.
X+ */
X+
X+ static Saved_Level *alloc_level(level)
X+ int level;
X+ {
X+ int i;
X+ int tried_to_swap = 0;
X+
X+ try_again:
X+ for (i=0; i<NLEVELS; i++)
X+ if (slot_in_use[i] == 0) {
X+ slot_in_use[i] = 1;
X+ level_locs[level] = i;
X+ time(&slot_time[i]);
X+ if (saved_levels[i] == NULL) {
X+ printf("bug in alloc_level!");
X+ abort();
X+ }
X+ return saved_levels[i];
X+ }
X+
X+ if (tried_to_swap) {
X+ puts("Can't find a place to put a level!");
X+ abort();
X+ }
X+ else {
X+ tried_to_swap = 1;
X+ swap_out_level();
X+ goto try_again;
X+ }
X+ }
X+
X+ /*
X+ * get_level returns a pointer to the Saved_Level structure for the indicated
X+ * level. note: this pointer may be invalidated by any future calls to
X+ * get_level or alloc_level.
X+ */
X+
X+ static Saved_Level *get_level(level)
X+ int level;
X+ {
X+ int slot = level_locs[level];
X+ Saved_Level *storage = saved_levels[slot];
X+
X+ if (slot == -1 || slot >= NLEVELS || slot <= -2 - NLEVELS) {
X+ puts("bug in get_level!");
X+ abort();
X+ }
X+
X+ if (slot >= 0)
X+ storage = saved_levels[slot];
X+ else {
X+
X+ /* swap in the level */
X+
X+ slot = -2 - slot;
X+ if (swap_slot_in_use[slot] != 1) {
X+ puts("bogus swapped level_loc in get_level!");
X+ abort();
X+ }
X+ storage = alloc_level(level);
X+
X+ swap_read(storage, slot);
X+
X+ swap_slot_in_use[slot] = 0;
X+ }
X+
X+ if (storage == NULL) {
X+ puts("bogus storage pointer in get_level!");
X+ abort();
X+ }
X+ return storage;
X+ }
X+
X+ /*
X+ * free the storage for a level
X+ */
X+
X+ static free_level(level)
X+ int level;
X+ {
X+ int slot = level_locs[level];
X+
X+ if (slot < -2-NLEVELS || slot == -1 || slot >= NLEVELS) {
X+ printf("bug in free_level!\n");
X+ abort();
X+ }
X+
X+ if (slot >= 0)
X+ slot_in_use[slot] = 0;
X+ else
X+ swap_slot_in_use[-2-slot] = 0;
X+
X+ level_locs[level] = -1;
X+ }
X+
X+ #endif /* SWAPPING */
X+
X+
X+ /*
X+ * routine to save the present level into storage
X+ */
X+ savelevel()
X+ {
X+ #ifdef SWAPPING
X+ Saved_Level *storage = alloc_level(level);
X+ #else
X+ Saved_Level *storage = saved_levels[level];
X+ #endif
X+
X+ memcpy(storage->hitp, hitp, sizeof(Short_Ary));
X+ memcpy(storage->mitem, mitem, sizeof(Char_Ary));
X+ memcpy(storage->item, item, sizeof(Char_Ary));
X+ memcpy(storage->iarg, iarg, sizeof(Short_Ary));
X+ memcpy(storage->know, know, sizeof(Char_Ary));
X+ }
X+
X+ /*
X * routine to restore a level from storage
X */
X getlevel()
X {
X! #ifdef SWAPPING
X! Saved_Level *storage = get_level(level);
X! #else
X! Saved_Level *storage = saved_levels[level];
X! #endif
X
X! memcpy(hitp, storage->hitp, sizeof(Short_Ary));
X! memcpy(mitem, storage->mitem, sizeof(Char_Ary));
X! memcpy(item, storage->item, sizeof(Char_Ary));
X! memcpy(iarg, storage->iarg, sizeof(Short_Ary));
X! memcpy(know, storage->know, sizeof(Char_Ary));
X
X! #ifdef SWAPPING
X! free_level(level);
X! #endif
X! }
X
X! /*
X! to save the game in a file
X! */
X! static long int zzz=0;
X! extern int rmst;
X! extern long lasttime;
X! savegame(fname)
X! char *fname;
X! {
X! register int i,k;
X! register struct sphere *sp;
X! struct stat statbuf;
X! Saved_Level *storage;
X!
X! nosignal=1;
X! lflush();
X! savelevel();
X! ointerest();
X! if (lcreat(fname, 1) < 0) {
X! lcreat((char*)0);
X! lprintf("\nCan't open file <%s> to save game\n",fname);
X! nosignal=0;
X! return(-1);
X }
X+
X+ set_score_output();
X+ lwrite((char*)beenhere,MAXLEVEL+MAXVLEVEL);
X+ for (k=0; k<MAXLEVEL+MAXVLEVEL; k++)
X+ if (beenhere[k]) {
X+ #ifdef SWAPPING
X+ storage = get_level(k);
X+ #else
X+ storage = saved_levels[k];
X+ #endif
X+ lwrite((char*)storage, sizeof(Saved_Level));
X+ }
X+ lwrite((char*)&c[0],100*sizeof(long));
X+ lprint((long)gtime);
X+ lprc(level);
X+ lprc(playerx);
X+ lprc(playery);
X+ lwrite((char*)iven,26);
X+ lwrite((char*)ivenarg,26*sizeof(short));
X+ lwrite((char*)char_class,20);
X+ for (k=0; k<MAXSCROLL; k++) lprc(scrollname[k][0]);
X+ for (k=0; k<MAXPOTION; k++) lprc(potionname[k][0]);
X+ lwrite((char*)spelknow,SPNUM);
X+ lprc(wizard);
X+ lprc(rmst); /* random monster generation counter */
X+ for (i=0; i<90; i++) lprc(itm[i].qty);
X+ lwrite((char*)course,25);
X+ lprc(cheat);
X+
X+ /* genocide info */
X+ for (i=0; i<MAXMONST; i++) lprc(monster[i].genocided);
X+
X+ /* save spheres of annihilation */
X+ for (sp=spheres; sp; sp=sp->p)
X+ lwrite((char*)sp,sizeof(struct sphere));
X+
X+ time(&zzz);
X+ lprint((long)(zzz-initialtime));
X+ lwrite((char*)&zzz,sizeof(long));
X+
X+ if (fstat(lfd,&statbuf)< 0) lprint(0L);
X+ else
X+ lprint((long)statbuf.st_ino); /* inode # */
X+
X+ lwclose();
X+ lastmonst[0] = 0;
X+ lcreat((char*)0);
X+ nosignal=0;
X+ return(0);
X+ }
X+
X+ restoregame(fname)
X+ char *fname;
X+ {
X+ register int i,k;
X+ register struct sphere *sp,*sp2;
X+ struct stat filetimes;
X+ Saved_Level *storage;
X+
X+
X+ cursors();
X+ lprcat("\nRestoring . . .");
X+ lflush();
X+ if (lopen(fname, 1) <= 0) {
X+ lcreat((char*)0);
X+ lprintf("\nCan't open file <%s> to restore game\n",fname);
X+ nap(2000);
X+ c[GOLD]=c[BANKACCOUNT]=0;
X+ died(-265);
X+ return;
X+ }
X+
X+ lrfill((char*)beenhere,MAXLEVEL+MAXVLEVEL);
X+ for (k=0; k<MAXLEVEL+MAXVLEVEL; k++)
X+ if (beenhere[k]) {
X+ #ifdef SWAPPING
X+ storage = alloc_level(k);
X+ #else
X+ storage = saved_levels[k];
X+ #endif
X+ lrfill((char*)storage, sizeof(Saved_Level));
X+ }
X+
X+ lrfill((char*)&c[0],100*sizeof(long));
X+ gtime = lrint();
X+ level = c[CAVELEVEL] = lgetc();
X+
X+ playerx = lgetc();
X+ playery = lgetc();
X+
X+ lrfill((char*)iven,26);
X+ lrfill((char*)ivenarg,26*sizeof(short));
X+ lrfill((char*)char_class,20);
X+
X+ for (k=0; k<MAXSCROLL; k++) scrollname[k][0] = lgetc();
X+ for (k=0; k<MAXPOTION; k++) potionname[k][0] = lgetc();
X+
X+ lrfill((char*)spelknow,SPNUM);
X+
X+ wizard = lgetc();
X+ rmst = lgetc(); /* random monster creation flag */
X+
X+ for (i=0; i<90; i++)
X+ itm[i].qty = lgetc();
X+
X+ lrfill((char*)course,25);
X+ cheat = lgetc();
X+
X+ /* genocide info */
X+ for (i=0; i<MAXMONST; i++) monster[i].genocided=lgetc();
X+
X+ for (sp=0,i=0; i<c[SPHCAST]; i++) {
X+ sp2 = sp;
X+ sp = (struct sphere *)malloc(sizeof(struct sphere));
X+ if (sp==0) {
X+ fprintf(stderr, "Can't malloc() for sphere space\n");
X+ break;
X+ }
X+ /* get spheres of annihilation */
X+ lrfill((char*)sp,sizeof(struct sphere));
X+ sp->p=0; /* null out pointer */
X+ if (i==0) spheres=sp; /* beginning of list */
X+ else sp2->p = sp;
X+ }
X+
X+
X+ time(&zzz);
X+ initialtime = zzz-lrint();
X+
X+ fstat(fd,&filetimes);/*get the creation and modification time of file*/
X+
X+ lrfill((char*)&zzz,sizeof(long));
X+
X+ zzz += 6;
X+ #ifndef __TURBOC__
X+ if (filetimes.st_ctime > zzz)
X+ fsorry(); /*file create time */
X+ else if (filetimes.st_mtime > zzz)
X+ fsorry(); /* file modify time*/
X+ #endif
X+
X+
X+ if (c[HP]<0) {
X+ died(284);
X+ return;
X+ } /* died a post mortem death */
X+
X+ oldx = oldy = 0;
X+
X+ i = lrint(); /* inode # */
X+ #ifndef __TURBOC__
X+ if (i && (filetimes.st_ino!=i))
X+ fsorry(); /* different inode number, file was copied */
X+ #endif
X+
X+ lrclose();
X+
X+ if (strcmp(fname,ckpfile) == 0) {
X+ if (lappend(fname, 1) < 0)
X+ fcheat();
X+ else {
X+ lprc(' ');
X+ lwclose();
X+ }
X+ lcreat((char*)0);
X+ }
X+ else if (unlink(fname) < 0)
X+ fcheat(); /* can't unlink save file */
X+
X+ /* for the greedy cheater checker */
X+ /* for (k=0; k<6; k++) if (c[k]>99) greedy();
X+ if (c[HPMAX]>999 || c[SPELLMAX]>125) greedy(); */
X+ if (c[LEVEL]==25 && c[EXPERIENCE]>skill[24]) {
X+ long tmp = c[EXPERIENCE]-skill[24]; /* amount to go up */
X+ c[EXPERIENCE] = skill[24];
X+ raiseexperience((long)tmp);
X+ }
X+ getlevel();
X+ lasttime=gtime;
X+
X+ for (k=0; k<26; k++)
X+ if (iven[k] == OLARNEYE) {
X+ monstnamelist[DEMONLORD] = '1';
X+ monstnamelist[DEMONLORD+1] = '2';
X+ monstnamelist[DEMONLORD+2] = '3';
X+ monstnamelist[DEMONLORD+3] = '4';
X+ monstnamelist[DEMONLORD+4] = '5';
X+ monstnamelist[DEMONLORD+5] = '6';
X+ monstnamelist[DEMONLORD+6] = '7';
X+ monstnamelist[DEMONPRINCE] = '9';
X+ monstnamelist[LUCIFER] = '0';
X+ break;
X+ }
X+ }
X+
X+ /*
X+ subroutine to not allow greedy cheaters
X+ */
X+ greedy()
X+ {
X+ if (wizard) return;
X+
X+ lprcat("\n\nI am so sorry, but your character is a little TOO good! Since this\n");
X+ lprcat("cannot normally happen from an honest game, I must assume that you cheated.\n");
X+ lprcat("In that you are GREEDY as well as a CHEATER, I cannot allow this game\n");
X+ lprcat("to continue.\n");
X+ nap(5000);
X+ c[GOLD]=c[BANKACCOUNT]=0;
X+ died(-267);
X+ return;
X+ }
X+
X+ /*
X+ subroutine to not allow altered save files and terminate the attempted
X+ restart
X+ */
X+ fsorry()
X+ {
X+ if(cheat) return;
X+ lprcat("\nSorry, but your savefile has been altered.\n");
X+ lprcat("However, seeing as I am a good sport, I will let you play.\n");
X+ lprcat("Be advised though, you won't be placed on the scoreboard.");
X+ cheat = 1;
X+ nap(4000);
X+ }
X+
X+ /*
X+ subroutine to not allow game if save file can't be deleted
X+ */
X+ fcheat()
X+ {
X+ if (wizard) return;
X+ if(cheat) return;
X+
X+ lprcat("\nSorry, but your savefile can't be deleted. This can only mean\n");
X+ lprcat("that you tried to CHEAT by protecting the directory the savefile\n");
X+ lprcat("is in. Since this is unfair to the rest of the Ularn community, I\n");
X+ lprcat("cannot let you play this game.\n");
X+ nap(5000);
X+ c[GOLD]=c[BANKACCOUNT]=0;
X+ died(-268);
X+ return;
X+ }
X+
X+ init_cells()
X+ {
X+ int i, missing=0;
X+
X+ for (i=0; i<NLEVELS; i++) {
X+ #ifdef __MSDOS__
X+ if (coreleft() <= LEFTOVERS)
X+ saved_levels[i] = NULL;
X+ else
X+ #endif
X+ saved_levels[i] = (Saved_Level *)malloc(sizeof(Saved_Level));
X+ #ifdef SWAPPING
X+ if (saved_levels[i] == NULL) {
X+ ++missing;
X+ slot_in_use[i] = -1;
X+ }
X+ else slot_in_use[i] = 0;
X+
X+ level_locs[i] = -1;
X+ slot_time[i] = 0;
X+ swap_slot_in_use[i] = -1;
X+ #else
X+ if (saved_levels[i] == NULL) died(-285);
X+ #endif /* SWAPPING */
X+ }
X+
X+ /* must have at least one save area available */
X+
X+ #ifdef SWAPPING
X+ if (saved_levels[0] == NULL) died(-285);
X+
X+ if (missing) {
X+ printf("Couldn't allocate space for %d levels\n", missing);
X+ nap(2000);
X+ }
X+ #endif
X }
Xdiff -c orig/scores.c new/scores.c
X*** orig/scores.c Sun Jul 16 01:07:15 1989
X--- new/scores.c Sun Jul 16 04:41:43 1989
X***************
X*** 63,68 ****
X--- 63,74 ----
X static struct scofmt sco[SCORESIZE]; /* the structure for the scoreboard */
X static struct wscofmt winr[SCORESIZE]; /* struct for the winning scoreboard */
X
X+ #ifdef __MSDOS__
X+ # define SAMEGUY(rec) (strcmp((rec).who, logname) == 0)
X+ #else
X+ # define SAMEGUY(rec) ((rec).suid == userid)
X+ #endif
X+
X static char *whydead[] = {
X "quit", /* 0 */
X "suspended",
X***************
X*** 106,112 ****
X--- 112,122 ----
X {
X FILE *fp;
X
X+ #ifdef __MSDOS__
X+ if ((fp = fopen(scorefile, "rb")) == (FILE *)NULL) {
X+ #else
X if ((fp = fopen(scorefile, "r")) == (FILE *)NULL) {
X+ #endif
X fprintf(stderr, "Can't open scorefile for reading\n");
X fflush(stderr);
X return(-1);
X***************
X*** 139,145 ****
X--- 149,159 ----
X {
X FILE *fp;
X
X+ #ifdef __MSDOS__
X+ if ((fp = fopen(scorefile, "wb")) == (FILE *)NULL) {
X+ #else
X if ((fp = fopen(scorefile, "w")) == (FILE *)NULL) {
X+ #endif
X lprcat("Can't open scorefile for writing\n");
X lflush();
X return(-1);
X***************
X*** 203,209 ****
X return(0); /* can't find scoreboard */
X
X for (i = 0; i < SCORESIZE; i++) /* search through winners scoreboard */
X! if (winr[i].suid == userid)
X if (winr[i].score > 0) {
X c[HARDGAME] = winr[i].hardlev + 1;
X outstanding_taxes = winr[i].taxes;
X--- 217,223 ----
X return(0); /* can't find scoreboard */
X
X for (i = 0; i < SCORESIZE; i++) /* search through winners scoreboard */
X! if (SAMEGUY(winr[i]))
X if (winr[i].score > 0) {
X c[HARDGAME] = winr[i].hardlev + 1;
X outstanding_taxes = winr[i].taxes;
X***************
X*** 234,240 ****
X for (i = 0; i < SCORESIZE; i++)
X
X /* look for players winning entry */
X! if (winr[i].suid == userid)
X
X /* search for a winning entry for the player */ {
X if (winr[i].score > 0)
X--- 248,254 ----
X for (i = 0; i < SCORESIZE; i++)
X
X /* look for players winning entry */
X! if (SAMEGUY(winr[i]))
X
X /* search for a winning entry for the player */ {
X if (winr[i].score > 0)
X***************
X*** 281,287 ****
X if (p->order == i) {
X if (p->score) {
X count++;
X! printf("%-10ld%8d%8d Mobuls (%s) %s\n",
X (long)p->score,
X p->hardlev,
X p->timeused,
X--- 295,301 ----
X if (p->order == i) {
X if (p->score) {
X count++;
X! printf("%-10ld%8d%8ld Mobuls (%s) %s\n",
X (long)p->score,
X p->hardlev,
X p->timeused,
X***************
X*** 490,496 ****
X
X if (winner) {
X for (i = 0; i < SCORESIZE; i++)
X! if (sco[i].suid == userid)
X sco[i].score = 0;
X taxes = score * TAXRATE;
X score += 100000 * c[HARDGAME]; /* bonus for winning */
X--- 504,510 ----
X
X if (winner) {
X for (i = 0; i < SCORESIZE; i++)
X! if (SAMEGUY(sco[i]))
X sco[i].score = 0;
X taxes = score * TAXRATE;
X score += 100000 * c[HARDGAME]; /* bonus for winning */
X***************
X*** 497,503 ****
X
X /* if he has a slot on the winning scoreboard update it if greater score*/
X for (i = 0; i < SCORESIZE; i++)
X! if (winr[i].suid == userid) {
X new1sub(score, i, whoo, taxes);
X return;
X }
X--- 511,517 ----
X
X /* if he has a slot on the winning scoreboard update it if greater score*/
X for (i = 0; i < SCORESIZE; i++)
X! if (SAMEGUY(winr[i])) {
X new1sub(score, i, whoo, taxes);
X return;
X }
X***************
X*** 511,517 ****
X } else if (!cheat) /* for not winning scoreboard */ {
X /* if he has a slot on the scoreboard update it if greater score */
X for (i = 0; i < SCORESIZE; i++)
X! if (sco[i].suid == userid) {
X new2sub(score, i, whoo, whyded);
X return;
X }
X--- 525,531 ----
X } else if (!cheat) /* for not winning scoreboard */ {
X /* if he has a slot on the scoreboard update it if greater score */
X for (i = 0; i < SCORESIZE; i++)
X! if (SAMEGUY(sco[i])) {
X new2sub(score, i, whoo, whyded);
X return;
X }
Xdiff -c orig/signal.c new/signal.c
X*** orig/signal.c Sun Jul 16 01:00:34 1989
X--- new/signal.c Sun Jul 16 04:38:11 1989
X***************
X*** 5,10 ****
X--- 5,16 ----
X #define BIT(a) (1<<((a)-1))
X extern char savefilename[],wizard,predostuff,nosignal;
X
X+ #ifdef __MSDOS__
X+ # define VOID void
X+ #else
X+ # define VOID
X+ #endif
X+
X s2choose() /* text to be displayed if ^C during intro screen */
X {
X cursor(1,24);
X***************
X*** 16,22 ****
X lflush();
X }
X
X! cntlc() /* what to do for a ^C */
X {
X if (nosignal)
X return; /* don't do anything if inhibited */
X--- 22,28 ----
X lflush();
X }
X
X! VOID cntlc() /* what to do for a ^C */
X {
X if (nosignal)
X return; /* don't do anything if inhibited */
X***************
X*** 27,33 ****
X--- 33,41 ----
X else
X showplayer();
X lflush();
X+ #ifndef __MSDOS__
X signal(SIGQUIT,cntlc);
X+ #endif
X signal(SIGINT,cntlc);
X }
X
X***************
X*** 70,106 ****
X /*
X * subroutine to issue the needed signal traps called from main()
X */
X! sigill() { sigpanic(SIGILL); }
X sigtrap() { sigpanic(SIGTRAP); }
X sigiot() { sigpanic(SIGIOT); }
X sigemt() { sigpanic(SIGEMT); }
X- sigfpe() { sigpanic(SIGFPE); }
X sigbus() { sigpanic(SIGBUS); }
X- sigsegv() { sigpanic(SIGSEGV); }
X sigsys() { sigpanic(SIGSYS); }
X sigpipe() { sigpanic(SIGPIPE); }
X! sigterm() { sigpanic(SIGTERM); }
X
X sigsetup()
X {
X- signal(SIGQUIT, cntlc);
X signal(SIGINT, cntlc);
X signal(SIGKILL, SIG_IGN);
X signal(SIGHUP, sgam);
X- signal(SIGILL, sigill);
X signal(SIGTRAP, sigtrap);
X signal(SIGIOT, sigiot);
X signal(SIGEMT, sigemt);
X- signal(SIGFPE, sigfpe);
X signal(SIGBUS, sigbus);
X- signal(SIGSEGV, sigsegv);
X signal(SIGSYS, sigsys);
X signal(SIGPIPE, sigpipe);
X- signal(SIGTERM, sigterm);
X #ifdef SIGTSTP
X signal(SIGTSTP,tstop);
X signal(SIGSTOP,tstop);
X #endif /* SIGTSTP */
X }
X
X #ifdef BSD /* for BSD UNIX? */
X--- 78,120 ----
X /*
X * subroutine to issue the needed signal traps called from main()
X */
X! VOID sigill() { sigpanic(SIGILL); }
X! VOID sigfpe() { sigpanic(SIGFPE); }
X! VOID sigsegv() { sigpanic(SIGSEGV); }
X! VOID sigterm() { sigpanic(SIGTERM); }
X!
X! #ifndef __MSDOS__
X sigtrap() { sigpanic(SIGTRAP); }
X sigiot() { sigpanic(SIGIOT); }
X sigemt() { sigpanic(SIGEMT); }
X sigbus() { sigpanic(SIGBUS); }
X sigsys() { sigpanic(SIGSYS); }
X sigpipe() { sigpanic(SIGPIPE); }
X! #endif
X
X sigsetup()
X {
X signal(SIGINT, cntlc);
X+ signal(SIGILL, sigill);
X+ signal(SIGFPE, sigfpe);
X+ signal(SIGSEGV, sigsegv);
X+ signal(SIGTERM, sigterm);
X+
X+ #ifndef __MSDOS__
X+ signal(SIGQUIT, cntlc);
X signal(SIGKILL, SIG_IGN);
X signal(SIGHUP, sgam);
X signal(SIGTRAP, sigtrap);
X signal(SIGIOT, sigiot);
X signal(SIGEMT, sigemt);
X signal(SIGBUS, sigbus);
X signal(SIGSYS, sigsys);
X signal(SIGPIPE, sigpipe);
X #ifdef SIGTSTP
X signal(SIGTSTP,tstop);
X signal(SIGSTOP,tstop);
X #endif /* SIGTSTP */
X+ #endif /* __MSDOS__ */
X }
X
X #ifdef BSD /* for BSD UNIX? */
X***************
X*** 137,142 ****
X--- 151,157 ----
X "","","","" };
X
X #else /* SYSV */
X+ # ifndef __MSDOS__
X static char *signame[NSIG] = {
X "",
X "SIGHUP", /* 1 hangup */
X***************
X*** 159,164 ****
X--- 174,207 ----
X "SIGCLD", /* 18 child death */
X "SIGPWR" /* 19 power fail */
X };
X+ # else /* __MSDOS__ */
X+ static char *signame[] = {
X+ "", /* 0 */
X+ "", /* 1 */
X+ "SIGINT", /* 2 */
X+ "", /* 3 */
X+ "SIGILL", /* 4 */
X+ "", /* 5 */
X+ "", /* 6 */
X+ "", /* 7 */
X+ "SIGFPE", /* 8 */
X+ "", /* 9 */
X+ "", /* 10 */
X+ "SIGSEGV", /* 11 */
X+ "", /* 12 */
X+ "", /* 13 */
X+ "", /* 14 */
X+ "SIGTERM", /* 15 */
X+ "SIGUSR1", /* 16 */
X+ "SIGUSR2", /* 17 */
X+ "", /* 18 */
X+ "", /* 19 */
X+ "SIGUSR3", /* 20 */
X+ "SIGBREAK", /* 21 */
X+ "SIGABRT", /* 22 */
X+ };
X+ # endif /* __MSDOS__ */
X+
X #endif /* BSD */
X
X /*
X***************
X*** 173,177 ****
X--- 216,224 ----
X sleep(2);
X sncbr();
X savegame(savefilename);
X+ #ifdef __MSDOS__
X+ exit(10);
X+ #else
X kill(getpid(),sig); /* this will terminate us */
X+ #endif
X }
Xdiff -c orig/store.c new/store.c
X*** orig/store.c Sun Jul 16 01:07:20 1989
X--- new/store.c Sun Jul 16 04:43:41 1989
X***************
X*** 216,227 ****
X outofstock();
X else if (pocketfull())
X handsfull();
X! else if (c[GOLD] < itm[i].price*10)
X nogold();
X else {
X if (itm[i].mem != 0)
X *itm[i].mem[itm[i].arg] = ' ';
X! c[GOLD] -= itm[i].price*10;
X itm[i].qty--;
X take(itm[i].obj,itm[i].arg);
X if (itm[i].qty==0)
X--- 216,227 ----
X outofstock();
X else if (pocketfull())
X handsfull();
X! else if (c[GOLD] < itm[i].price*10L)
X nogold();
X else {
X if (itm[i].mem != 0)
X *itm[i].mem[itm[i].arg] = ' ';
X! c[GOLD] -= itm[i].price*10L;
X itm[i].qty--;
X take(itm[i].obj,itm[i].arg);
X if (itm[i].qty==0)
X***************
X*** 284,290 ****
X }
X else lprintf("%s",objectname[itm[i].obj]);
X cursor( j+31,k );
X! lprintf("%6d",(long)(itm[i].price*10));
X }
X
X
X--- 284,290 ----
X }
X else lprintf("%s",objectname[itm[i].obj]);
X cursor( j+31,k );
X! lprintf("%6d",((long)itm[i].price*10));
X }
X
X
X***************
X*** 464,470 ****
X /*
X * for the first national bank of Ularn
X */
X! int lasttime=0; /* last time he was in bank */
X obank()
X {
X banktitle(" Welcome to the First National Bank of Ularn.");
X--- 464,470 ----
X /*
X * for the first national bank of Ularn
X */
X! long lasttime=0; /* last time he was in bank */
X obank()
X {
X banktitle(" Welcome to the First National Bank of Ularn.");
X***************
X*** 626,640 ****
X for (i=0; i<26; i++) {
X if (gemvalue[i]) {
X if (iven[i]==OLARNEYE) {
X! monstnamelist[DEMONLORD]=' ';
X! monstnamelist[DEMONLORD+1]=' ';
X! monstnamelist[DEMONLORD+2]= ' ';
X! monstnamelist[DEMONLORD+3]= ' ';
X! monstnamelist[DEMONLORD+4]= ' ';
X! monstnamelist[DEMONLORD+5]= ' ';
X! monstnamelist[DEMONLORD+6]= ' ';
X! monstnamelist[DEMONPRINCE]= ' ';
X! monstnamelist[LUCIFER] = ' ';
X }
X c[GOLD]+=gemvalue[i];
X iven[i]=0;
X--- 626,641 ----
X for (i=0; i<26; i++) {
X if (gemvalue[i]) {
X if (iven[i]==OLARNEYE) {
X! char c = objnamelist[0];
X! monstnamelist[DEMONLORD ]=c;
X! monstnamelist[DEMONLORD+1]=c;
X! monstnamelist[DEMONLORD+2]=c;
X! monstnamelist[DEMONLORD+3]=c;
X! monstnamelist[DEMONLORD+4]=c;
X! monstnamelist[DEMONLORD+5]=c;
X! monstnamelist[DEMONLORD+6]=c;
X! monstnamelist[DEMONPRINCE]=c;
X! monstnamelist[LUCIFER] =c;
X }
X c[GOLD]+=gemvalue[i];
X iven[i]=0;
X***************
X*** 651,665 ****
X break;
X }
X if (iven[i]==OLARNEYE) {
X! monstnamelist[DEMONLORD]=' ';
X! monstnamelist[DEMONLORD+1]=' ';
X! monstnamelist[DEMONLORD+2]= ' ';
X! monstnamelist[DEMONLORD+3]= ' ';
X! monstnamelist[DEMONLORD+4]= ' ';
X! monstnamelist[DEMONLORD+5]= ' ';
X! monstnamelist[DEMONLORD+6]= ' ';
X! monstnamelist[DEMONPRINCE]= ' ';
X! monstnamelist[LUCIFER] = ' ';
X }
X c[GOLD]+=gemvalue[i];
X iven[i]=0;
X--- 652,667 ----
X break;
X }
X if (iven[i]==OLARNEYE) {
X! char c = objnamelist[0];
X! monstnamelist[DEMONLORD ] = c;
X! monstnamelist[DEMONLORD+1] = c;
X! monstnamelist[DEMONLORD+2] = c;
X! monstnamelist[DEMONLORD+3] = c;
X! monstnamelist[DEMONLORD+4] = c;
X! monstnamelist[DEMONLORD+5] = c;
X! monstnamelist[DEMONLORD+6] = c;
X! monstnamelist[DEMONPRINCE] = c;
X! monstnamelist[LUCIFER] = c;
X }
X c[GOLD]+=gemvalue[i];
X iven[i]=0;
X***************
X*** 685,691 ****
X appraise(gemstone)
X int gemstone;
X {
X! register int j,amt;
X
X for (j=0; j<26; j++)
X if (iven[j]==gemstone) {
X--- 687,694 ----
X appraise(gemstone)
X int gemstone;
X {
X! register int j;
X! register long amt;
X
X for (j=0; j<26; j++)
X if (iven[j]==gemstone) {
X***************
X*** 731,737 ****
X
X otradepost()
X {
X! int i,j,value,isub,izarg;
X
X dnditm = dndcount = 0;
X nosignal = 1; /* disable signals */
X--- 734,741 ----
X
X otradepost()
X {
X! int i,j,isub,izarg;
X! long value;
X
X dnditm = dndcount = 0;
X nosignal = 1; /* disable signals */
X***************
X*** 1116,1121 ****
X--- 1120,1126 ----
X lprcat("\nSo, what are ya? ");
X lflush();
X
X+ i=0;
X while (i<'a' || i>'h')
X i=getcharacter();
X
Xdiff -c orig/tok.c new/tok.c
X*** orig/tok.c Sun Jul 16 01:07:17 1989
X--- new/tok.c Sun Jul 16 04:49:51 1989
X***************
X*** 43,57 ****
X if (ckpflag)
X /* check for periodic checkpointing */
X if ( c[BYTESIN] == 1 || (c[BYTESIN] % 400) == 0) {
X wait((int *)0);/* wait for other forks to finish */
X if (fork() == 0) {
X savegame(ckpfile);
X exit(0);
X }
X }
X flushall();
X! if (read(0,&cc,1) != 1)
X! return(lastok = -1);
X
X if (cc == '!') /* shell escape */
X {
X--- 43,60 ----
X if (ckpflag)
X /* check for periodic checkpointing */
X if ( c[BYTESIN] == 1 || (c[BYTESIN] % 400) == 0) {
X+ #ifdef __MSDOS__
X+ savegame(ckpfile);
X+ #else
X wait((int *)0);/* wait for other forks to finish */
X if (fork() == 0) {
X savegame(ckpfile);
X exit(0);
X }
X+ #endif /* __MSDOS__ */
X }
X flushall();
X! cc = getcharacter();
X
X if (cc == '!') /* shell escape */
X {
X***************
X*** 60,65 ****
X--- 63,71 ----
X sncbr();
X cl_dn(0,0);
X lflush();
X+ #ifdef __MSDOS__
X+ system("COMMAND");
X+ #else
X if ((ic=fork())==0) {
X execl("/bin/csh", "/bin/csh", (char *)0);
X exit(1);
X***************
X*** 73,78 ****
X--- 79,85 ----
X fflush(stderr);
X sleep(2);
X }
X+ #endif
X setscroll();
X scbr();
X return(lastok = 'L'-64); /* redisplay screen */
X***************
X*** 105,115 ****
X--- 112,126 ----
X } /* gobble up the byte */
X }
X #else /* SYSV */
X+ # ifdef __MSDOS__
X+ while (kbhit()) (void)getch();
X+ # else
X # ifdef TCIFLUSH
X tcflush(0, TCIFLUSH); /* SYSV w/POSIX 1003 tcflush() */
X # else
X ioctl(0, TCFLSH); /* standard ioctl */
X # endif /* TCIFLUSH */
X+ # endif /* __MSDOS__ */
X #endif /* BSD */
X }
X
X***************
X*** 120,126 ****
X sethard(hard)
X int hard;
X {
X! register int j,k,i;
X
X if (restorflag==0) { /* don't set c[HARDGAME] if restoring game */
X if (hashewon() == 0) {
X--- 131,138 ----
X sethard(hard)
X int hard;
X {
X! register int j,k;
X! long i;
X
X if (restorflag==0) { /* don't set c[HARDGAME] if restoring game */
X if (hashewon() == 0) {
X***************
X*** 130,136 ****
X else if (hard > c[HARDGAME]) c[HARDGAME] = hard;
X }
X
X! if (k=c[HARDGAME])
X for (j=0; j<=MAXMONST+8; j++) {
X i = ((6+k)*monster[j].hitpoints+1)/6;
X monster[j].hitpoints = (i<0) ? 32767 : i;
X--- 142,148 ----
X else if (hard > c[HARDGAME]) c[HARDGAME] = hard;
X }
X
X! if ((k=c[HARDGAME])!=0)
X for (j=0; j<=MAXMONST+8; j++) {
X i = ((6+k)*monster[j].hitpoints+1)/6;
X monster[j].hitpoints = (i<0) ? 32767 : i;
X***************
X*** 155,163 ****
X extern int char_picked;
X int flag=1;
X
X! if (lopen(optsfile) < 0) {
X strcpy(logname,loginname);
X! return; /* user name if no character name */
X }
X i = " ";
X while (*i) {
X--- 167,175 ----
X extern int char_picked;
X int flag=1;
X
X! if (lopen(optsfile, 0) < 0) {
X strcpy(logname,loginname);
X! return -1; /* user name if no character name */
X }
X i = " ";
X while (*i) {
X***************
X*** 167,172 ****
X--- 179,191 ----
X case 'b':
X if (strcmp(i,"bold-off") == 0)
X boldon=0;
X+ #ifdef __MSDOS__
X+ else if (strcmp(i, "background:") == 0) {
X+ extern int bg_color;
X+ if ((i = lgetw())==0) break;
X+ bg_color = parse_color(i, bg_color);
X+ }
X+ #endif
X break;
X
X case 'e':
X***************
X*** 177,182 ****
X--- 196,208 ----
X case 'f':
X if (strcmp(i,"female") == 0)
X sex=0; /* male or female */
X+ #ifdef __MSDOS__
X+ else if (strcmp(i, "foreground:") == 0) {
X+ extern int fg_color;
X+ if ((i = lgetw())==0) break;
X+ fg_color = parse_color(i, fg_color);
X+ }
X+ #endif
X break;
X
X /* name favorite monster */
X***************
X*** 210,215 ****
X--- 236,247 ----
X nowelcome=1;
X else if (strcmp(i,"no-beep") == 0)
X nobeep=1;
X+ #ifdef __MSDOS__
X+ else if (strcmp(i, "nansi") == 0) {
X+ extern int nansi;
X+ nansi=1;
X+ }
X+ #endif
X break;
X
X case 'c':
X***************
X*** 247,253 ****
X--- 279,366 ----
X flag=0;
X }
X break;
X+ case 'g':
X+ if (strcmp(i, "graphics:") == 0) {
X+ int c;
X+ if ((i=lgetw())==0) break;
X+ c = atoi(i);
X+ if (c <= 0 || c > 255) break;
X+ objnamelist[0] = c;
X+ monstnamelist[INVISIBLESTALKER] = c;
X+ monstnamelist[DEMONLORD ] = c;
X+ monstnamelist[DEMONLORD+1] = c;
X+ monstnamelist[DEMONLORD+2] = c;
X+ monstnamelist[DEMONLORD+3] = c;
X+ monstnamelist[DEMONLORD+4] = c;
X+ monstnamelist[DEMONLORD+5] = c;
X+ monstnamelist[DEMONLORD+6] = c;
X+ monstnamelist[DEMONPRINCE] = c;
X+ monstnamelist[LUCIFER] = c;
X+ objnamelist[OTRAPARROWIV] = c;
X+ objnamelist[OIVDARTRAP] = c;
X+ objnamelist[OIVTRAPDOOR] = c;
X+ objnamelist[OIVTELETRAP] = c;
X+ if ((i=lgetw())==0) break;
X+ c = atoi(i);
X+ if (c <= 0 || c > 255) break;
X+ objnamelist[OWALL] = c;
X+ }
X+ break;
X+ #ifdef __MSDOS__
X+ case 'k':
X+ if (strcmp(i, "keypad") == 0) {
X+ extern int keypad;
X+ keypad = 1;
X+ }
X+ break;
X+ case 'r':
X+ if (strcmp(i, "rawio") == 0) {
X+ extern int rawio;
X+ rawio = 1;
X+ }
X+ break;
X+ case 'l':
X+ if (strcmp(i, "larn-path:") == 0) {
X+ extern char larnpath[];
X+ if ((i=lgetw())==0) break;
X+ if (strlen(i)>=SAVEFILENAMESIZE-1)
X+ i[SAVEFILENAMESIZE-2]=0;
X+ strcpy(larnpath,i);
X+ i = larnpath + strlen(larnpath) - 1;
X+ if (i >= larnpath &&
X+ !(*i == '/' || *i == '\\')) {
X+ *++i = '\\';
X+ *++i = '\0';
X+ }
X+ i = " ";
X+ }
X+ break;
X+
X+ #endif
X };
X }
X if (flag) strcpy(logname,loginname);
X+ return 0;
X }
X+
X+
X+ #ifdef __MSDOS__
X+
X+ static char *colors[8] = { "bla", "r", "g", "y", "blu", "m", "c", "w" };
X+
X+ int parse_color(name, old)
X+ char *name;
X+ int old;
X+ {
X+ int i;
X+
X+ for (i=0; i<8; i++)
X+ if (strncmp(name, colors[i], strlen(colors[i])) == 0) return i;
X+
X+ printf("Unknown color name %s\n", name);
X+ nap(2000);
X+
X+ return old;
X+ }
X+
X+ #endif /* __MSDOS__ */
Xdiff -c orig/ularn.lnk new/ularn.lnk
X*** orig/ularn.lnk Sun Jul 16 05:19:29 1989
X--- new/ularn.lnk Sun Jul 16 04:59:42 1989
X***************
X*** 0 ****
X--- 1,8 ----
X+ c:\l\tc\lib\c0h.obj +
X+ bill.obj config.obj create.obj data.obj diag.obj display.obj +
X+ fortune.obj global.obj help.obj io.obj main.obj monster.obj +
X+ moreobj.obj movem.obj object.obj regen.obj savelev.obj scores.obj +
X+ signal.obj store.obj tok.obj nap.obj
X+ ularn.exe
X+ ularn.map
X+ c:\l\tc\lib\emu.lib c:\l\tc\lib\mathh.lib c:\l\tc\lib\ch.lib
SHAR_EOF
if test 55551 -ne "`wc -c < 'patch02.2'`"
then
echo shar: error transmitting "'patch02.2'" '(should have been 55551 characters)'
fi
fi # end of overwriting check
# End of shell archive
exit 0