-+-+-+-+-+-+-+-+ START OF PART 36 -+-+-+-+-+-+-+-+ X if (d`5BSTEALTH`5D) if ((--d`5BSTEALTH`5D) <= 0) flag=1;`20 X if (d`5BAWARENESS`5D) --d`5BAWARENESS`5D; X if (d`5BHOLDMONST`5D) if ((--d`5BHOLDMONST`5D) <= 0) flag=1; X if (d`5BHASTEMONST`5D) --d`5BHASTEMONST`5D; X if (d`5BFIRERESISTANCE`5D) if ((--d`5BFIRERESISTANCE`5D) <= 0) flag=1; X if (d`5BGLOBE`5D) if (--d`5BGLOBE`5D<=0) `7B d`5BMOREDEFENSES` V5D-=10; flag=1; `7D X if (d`5BSPIRITPRO`5D) if (--d`5BSPIRITPRO`5D <= 0) flag=1; X if (d`5BUNDEADPRO`5D) if (--d`5BUNDEADPRO`5D <= 0) flag=1; X if (d`5BHALFDAM`5D) if (--d`5BHALFDAM`5D<=0) `7B cursors(); lp Vrcat("\nYou now feel better "); beep(); `7D X if (d`5BSEEINVISIBLE`5D) X if (--d`5BSEEINVISIBLE`5D<=0) X `7B monstnamelist`5BINVISIBLESTALKER`5D = floorc; X if (!d`5BBLINDCOUNT`5D) `7B X cursors(); X lprcat("\nYou feel your vision return to normal"); X beep(); X `7D X `7D X if (d`5BITCHING`5D) X `7B X if (d`5BITCHING`5D>1) X if ((d`5BWEAR`5D!= -1) `7C`7C (d`5BSHIELD`5D!= -1)) X if (rnd(100)<50) X `7B X d`5BWEAR`5D=d`5BSHIELD`5D= -1; cursors(); X lprcat("\nThe hysteria of itching forces you to remove y Vour armor!");`20 X beep(); recalc(); bottomline(); X `7D X if (--d`5BITCHING`5D<=0) `7B cursors(); lprcat("\nYou now feel the V irritation subside!"); beep(); `7D X `7D X if (d`5BCLUMSINESS`5D) X `7B X if (d`5BWIELD`5D != -1) X if (d`5BCLUMSINESS`5D>1) X if (item`5Bplayerx`5D`5Bplayery`5D==0) /* only if nothing t Vhere */ X if (rnd(100)<33) /* drop your weapon due to clumsiness */ X drop_object((int)d`5BWIELD`5D); X if (--d`5BCLUMSINESS`5D<=0) `7B cursors(); lprcat("\nYou now feel l Vess awkward!"); beep(); `7D X `7D X if (flag) bottomline(); X `7D $ CALL UNPACK REGEN.C;1 1782344230 $ create 'f' X/* savelev.c */ X#include "header.h" X#include "larndefs.h" X X# ifdef MSDOS X Xextern int swapfd; /* swap file file descriptor */ X XDISKBLOCK * Xgetfreediskblk() X`7B X DISKBLOCK *dp; X X for (dp = diskblks; dp; dp = dp->next) X if (dp->level == FREEBLOCK) X return dp; X levelinfo(); X error("Can't find a free disk block ?\n"); X`7D X XRAMBLOCK * Xgetramblk(lev) X`7B X RAMBLOCK *rp, *orp; X DISKBLOCK *dp; X long otime; X unsigned int bytes; X X /* Check if the level is in memory already. X */ X for (rp = ramblks; rp; rp = rp->next) X if (rp->level == lev) X return rp; X X /* Else grab the first available one. X */ X for (rp = ramblks; rp; rp = rp->next) X if (rp->level == FREEBLOCK) X return rp; X X /* No ramblocks free, so swap out the oldest level X */ X dp = getfreediskblk(); X X# ifdef ndef Xwarn("\nTrying to swap\n"); X# endif X X /* Find the oldest level for swapping out. X */ X otime = ramblks->gtime; X orp = ramblks; X for (rp = ramblks->next; rp; rp = rp->next) `7B X if (rp->gtime < otime) `7B X otime = rp->gtime; X orp = rp; X `7D X `7D X X /* Send the oldest level out to disk. X */ X if (lseek(swapfd, dp->fpos, 0) < 0) X error("Can't seek to %ld\n", dp->fpos); X X bytes = sizeof rp->cell; X if (write(swapfd, (char *) orp->cell, bytes) != bytes) X error("Out of space writing swap file !\n"); X X /* Update the level information X */ X dp->level = orp->level; X dp->gtime = orp->gtime; X orp->level = FREEBLOCK; X# ifdef ndef Xwarn("Successful swap\n"); X# endif X return orp; X`7D X X X# endif X X/* X * routine to save the present level into storage X */ Xsavelevel() X `7B X register struct cel *pcel; X register char *pitem,*pknow,*pmitem; X register short *phitp,*piarg; X register struct cel *pecel; X X# ifdef MSDOS X RAMBLOCK *rp; X X rp = getramblk(level); X pcel = rp->cell; X rp->gtime = gtime; X rp->level = level; X# else X pcel = &cell`5Blevel*MAXX*MAXY`5D; /* pointer to this level's cells */ X# endif X pecel = pcel + MAXX*MAXY; /* pointer to past end of this level's cells V */ X pitem=item`5B0`5D; piarg=iarg`5B0`5D; pknow=know`5B0`5D; pmitem=mitem`5B V0`5D; phitp=hitp`5B0`5D; X while (pcel < pecel) X `7B X pcel->mitem = *pmitem++; X pcel->hitp = *phitp++; X pcel->item = *pitem++; X pcel->know = *pknow++; X pcel->iarg = *piarg++; X pcel++; X `7D X `7D X X X/* X * routine to restore a level from storage X */ Xgetlevel() X `7B X register struct cel *pcel; X register char *pitem,*pknow,*pmitem; X register short *phitp,*piarg; X register struct cel *pecel; X X# ifdef MSDOS X RAMBLOCK *rp; X DISKBLOCK *dp; X unsigned int bytes; X X /* Is the level in memory already ? X */ X for (rp = ramblks; rp; rp = rp->next) X if (rp->level == level) X goto haverp; X X /* Is it on disk ? X */ X for (dp = diskblks; dp; dp = dp->next) X if (dp->level == level) X break; X if (dp == NULL) `7B X levelinfo(); X error("Level %d is neither in memory nor on disk\n", level); X `7D X X /* Make room for it and read it in. X */ X rp = getramblk(level); X if (lseek(swapfd, dp->fpos, 0) < 0) X error("Can't seek to %ld\n", dp->fpos); X bytes = sizeof rp->cell; X if (read(swapfd, (char *) rp->cell, bytes) != bytes) X error("Didn't read %u bytes\n", bytes); X X /* The disk space is available for future swaps. X */ X dp->level = FREEBLOCK; Xhaverp: X pcel = rp->cell; X rp->level = FREEBLOCK; X# else X pcel = &cell`5Blevel*MAXX*MAXY`5D; /* pointer to this level's cells */ X# endif X pecel = pcel + MAXX*MAXY; /* pointer to past end of this level's cells V */ X pitem=item`5B0`5D; piarg=iarg`5B0`5D; pknow=know`5B0`5D; pmitem=mitem`5B V0`5D; phitp=hitp`5B0`5D; X while (pcel < pecel) X `7B X *pmitem++ = pcel->mitem; X *phitp++ = pcel->hitp; X *pitem++ = pcel->item; X *pknow++ = pcel->know; X *piarg++ = pcel->iarg; X pcel++; X `7D X `7D $ CALL UNPACK SAVELEV.C;1 809994499 $ create 'f' X/* scores.c X * X * readboard() Function to read in the scoreboard into a static buffer X * writeboard() Function to write the scoreboard from readboard()'s buff Ver X * makeboard() Function to create a new scoreboard (wipe out old one) X * hashewon() Function to return 1 if player has won a game before, else V 0 X * long paytaxes(x) Function to pay taxes if any are due X * winshou() Subroutine to print out the winning scoreboard X * shou(x) Subroutine to print out the non-winners scoreboard X * showscores() Function to show the scoreboard on the terminal X * showallscores() Function to show scores and the iven lists that go with V them X * sortboard() Function to sort the scoreboard X * newscore(score, whoo, whyded, winner) Function to add entry to scorebo Vard X * new1sub(score,i,whoo,taxes) Subroutine to put player into a X * new2sub(score,i,whoo,whyded) Subroutine to put player into a X * died(x) Subroutine to record who played larn, and what the score was X * diedsub(x) Subroutine to print out a line showing player when he is kill Ved X * diedlog() Subroutine to read a log file and print it out in ascii form Vat X * getplid(name) Function to get players id # from id file X */ X#ifdef VMS X# include X# include X#else X# include X# ifndef MSDOS X# include X# endif X# include X#endif X#include "header.h" X#include "larndefs.h" X#include "monsters.h" X#include "objects.h" X#include "player.h" X Xstruct scofmt /* This is the structure for the scoreboard V */ X `7B X long score; /* the score of the player V */ X long suid; /* the user id number of the player V */ X short what; /* the number of the monster that killed player V */ X short level; /* the level player was on when he died V */ X short hardlev; /* the level of difficulty player played at V */ X short order; /* the relative ordering place of this entry V */ X char who`5B40`5D; /* the name of the character V */ X char sciv`5B26`5D`5B2`5D; /* this is the inventory list of the charact Ver */ X `7D; Xstruct wscofmt /* This is the structure for the winning scoreboard V */ X `7B X long score; /* the score of the player V */ X long timeused; /* the time used in mobuls to win the game V */ X long taxes; /* taxes he owes to LRS V */ X long suid; /* the user id number of the player V */ X short hardlev; /* the level of difficulty player played at V */ X short order; /* the relative ordering place of this entry V */ X# ifndef MAIL /* dgk */ X char hasmail; /* 1 if mail is to be read, 0 otherwise */ X# endif X char who`5B40`5D; /* the name of the character V */ X `7D; X Xstruct log_fmt /* 102 bytes struct for the log file V */ X `7B X long score; /* the players score V */ X long diedtime; /* time when game was over V */ X short cavelev; /* level in caves V */ X short diff; /* difficulty player played at V */ X#ifdef EXTRA X long elapsedtime; /* real time of game in seconds V */ X long bytout; /* bytes input and output V */ X long bytin; X long moves; /* number of moves made by player V */ X short ac; /* armor class of player V */ X short hp,hpmax; /* players hitpoints V */ X# ifndef MSDOS X short cputime; /* cpu time needed in seconds V */ X# endif X short killed,spused;/* monsters killed and spells cast V */ X short usage; /* usage of the cpu in % V */ X short lev; /* player level V */ X#endif X char who`5B12`5D; /* player name V */ X char what`5B46`5D; /* what happened to player V */ X `7D; X Xstatic struct scofmt sco`5BSCORESIZE`5D; /* the structure for the scorebo Vard */ Xstatic struct wscofmt winr`5BSCORESIZE`5D; /* struct for the winning scoreb Voard */ Xstatic struct log_fmt logg; /* structure for the log file V */ Xstatic char *whydead`5B`5D = `7B X "quit", "suspended", "self - annihilated", "shot by an arrow", X "hit by a dart", "fell into a pit", "fell into a bottomless pit", X "a winner", "trapped in solid rock", "killed by a missing save file", X "killed by an old save file", "caught by the greedy cheater checker trap V", X "killed by a protected save file","killed his family and committed suici Vde", X "erased by a wayward finger", "fell through a bottomless trap door", X "fell through a trap door", "drank some poisonous water", X "fried by an electric shock", "slipped on a volcano shaft", X "killed by a stupid act of frustration", "attacked by a revolting demon" V, X "hit by his own magic", "demolished by an unseen attacker", X "fell into the dreadful sleep", "killed by an exploding chest", X/*26*/ "killed by a missing maze data file", "annihilated in a sphere", X "died a post mortem death","wasted by a malloc() failure" X `7D; X X X/* X * readboard() Function to read in the scoreboard into a static buffer X * X * returns -1 if unable to read in the scoreboard, returns 0 if all is OK X */ Xstatic readboard() X `7B X if (lopen(scorefile)<0) X `7B lprcat("Can't read scoreboard\n"); lflush(); return(-1); `7D X lrfill((char*)sco,sizeof(sco)); lrfill((char*)winr,sizeof(winr)); X lrclose(); lcreat((char*)0); return(0); X `7D X X/* X * writeboard() Function to write the scoreboard from readboard()'s buff Ver X * X * returns -1 if unable to write the scoreboard, returns 0 if all is OK X */ Xstatic writeboard() X `7B X set_score_output(); X if (lcreat(scorefile)<0) X `7B lprcat("Can't write scoreboard\n"); lflush(); return(-1); `7D X lwrite((char*)sco,sizeof(sco)); lwrite((char*)winr,sizeof(winr)); X lwclose(); lcreat((char*)0); return(0); X `7D X X/* X * makeboard() Function to create a new scoreboard (wipe out old on Ve) X * X * returns -1 if unable to write the scoreboard, returns 0 if all is OK X */ Xmakeboard() X `7B X register int i; X for (i=0; i 0) X `7B +-+-+-+-+-+-+-+- END OF PART 36 +-+-+-+-+-+-+-+-