-+-+-+-+-+-+-+-+ START OF PART 37 -+-+-+-+-+-+-+-+
X c`5BHARDGAME`5D=winr`5Bi`5D.hardlev+1; outstanding_taxes=winr`5
VBi`5D.taxes;
X return(1);
X `7D
X return(0);
X `7D
X
X# ifndef MAIL /* dgk */
Xcheckmail()
X`7B
X register int i;
X long gold, taxes;
X
X if (readboard() < 0)
X return; /* can't find scoreboard */
X for (i = 0; i < SCORESIZE; i++) /* search through winners scoreboard */
X if (winr`5Bi`5D.suid == userid
X && winr`5Bi`5D.score > 0
X && winr`5Bi`5D.hasmail) `7B
X winr`5Bi`5D.hasmail = 0;
X gold = taxes = winr`5Bi`5D.taxes;
X writeboard();
X
X /* Intuit the amount of gold -- should have changed
X * the score file, but ... TAXRATE is an fraction.
X */
X while ((gold * TAXRATE) < taxes)
X gold += taxes;
X readmail(gold);
X `7D
X`7D
X# endif
X
X
X/*
X * long paytaxes(x) Function to pay taxes if any are due
X *
X * Enter with the amount (in gp) to pay on the taxes.
X * Returns amount actually paid.
X */
Xlong paytaxes(x)
X long x;
X `7B
X register int i;
X register long amt;
X if (x<0) return(0L);
X if (readboard()<0) return(0L);
X for (i=0; i0) /* search for a winning entry for the p
Vlayer */
X `7B
X amt = winr`5Bi`5D.taxes;
X if (x < amt) amt=x; /* don't overpay taxes (Ughhhhh) */
X winr`5Bi`5D.taxes -= amt;
X outstanding_taxes -= amt;
X if (writeboard()<0) return(0);
X return(amt);
X `7D
X return(0L); /* couldn't find user on winning scoreboard */
X `7D
X
X/*
X * winshou() Subroutine to print out the winning scoreboard
X *
X * Returns the number of players on scoreboard that were shown`20
X */
Xstatic winshou()
X `7B
X register struct wscofmt *p;
X register int i,j,count;
X for (count=j=i=0; iorder == i)
X `7B
X if (p->score)
X `7B
X count++;
X lprintf("%10d %2d %5d Mobuls %s \n",
X (long)p->score,(long)p->hardlev,(long)p->timeused,p->who
V);
X `7D
X break;
X `7D
X `7D
X `7D
X return(count); /* return number of people on scoreboard */
X `7D
X
X/*
X * shou(x) Subroutine to print out the non-winners scoreboard
X * int x;
X *
X * Enter with 0 to list the scores, enter with 1 to list inventories too
X * Returns the number of players on scoreboard that were shown`20
X */
Xstatic shou(x)
X int x;
X `7B
X register int i,j,n,k;
X int count;
X for (count=j=i=0; i= jdat))
X `7B j=i; jdat=sco`5Bi`5D.score; `7D
X sco`5Bj`5D.order = pos++;
X `7D
X pos=0; while (pos < SCORESIZE)
X `7B
X jdat=0;
X for (i=0; i= jdat))
X `7B j=i; jdat=winr`5Bi`5D.score; `7D
X winr`5Bj`5D.order = pos++;
X `7D
X return(1);
X `7D
X
X/*
X * newscore(score, whoo, whyded, winner) Function to add entry to scorebo
Vard
X * int score, winner, whyded;
X * char *whoo;
X *
X * Enter with the total score in gp in score, players name in whoo,
X * died() reason # in whyded, and TRUE/FALSE in winner if a winner
X * ex. newscore(1000, "player 1", 32, 0);
X */
Xstatic newscore(score, whoo, whyded, winner)
X long score;
X int winner, whyded;
X char *whoo;
X `7B
X register int i;
X long taxes;
X if (readboard() < 0) return; /* do the scoreboard */
X /* if a winner then delete all non-winning scores */
X if (cheat) winner=0; /* if he cheated, don't let him win */
X if (winner)
X `7B
X for (i=0; itaxes += taxes;
X if ((score >= p->score) `7C`7C (c`5BHARDGAME`5D > p->hardlev))
X `7B
X strcpy(p->who,whoo); p->score=score;
X p->hardlev=c`5BHARDGAME`5D; p->suid=userid;
X p->timeused=gtime/100;
X# ifndef MAIL /* dgk */
X p->hasmail = 1;
X# endif
X `7D
X `7D
X
X/*
X * new2sub(score,i,whoo,whyded) Subroutine to put player into a`20
X * int score,i,whyded,taxes; non-winning scoreboard entry if hi
Vs
X * char *whoo; score is high enough
X *
X * Enter with the total score in gp in score, players name in whoo,
X * died() reason # in whyded, and slot in scoreboard in i.
X * Returns nothing of value
X */
Xstatic new2sub(score,i,whoo,whyded)
X long score;
X int i,whyded;
X char *whoo;
X `7B
X register int j;
X register struct scofmt *p;
X p = &sco`5Bi`5D;
X if ((score >= p->score) `7C`7C (c`5BHARDGAME`5D > p->hardlev))
X `7B
X strcpy(p->who,whoo); p->score=score;
X p->what=whyded; p->hardlev=c`5BHARDGAME`5D;
X p->suid=userid; p->level=level;
X for (j=0; j<26; j++)
X `7B p->sciv`5Bj`5D`5B0`5D=iven`5Bj`5D; p->sciv`5Bj`5D`5B1`5D=ive
Vnarg`5Bj`5D; `7D
X `7D
X `7D
X
X/*
X * died(x) Subroutine to record who played larn, and what the score was
X * int x;
X *
X * if x < 0 then don't show scores
X * died() never returns! (unless c`5BLIFEPROT`5D and a reincarnatable death
V!)
X *
X * < 256 killed by the monster number
X * 256 quit
X * 257 suspended
X * 258 self - annihilated
X * 259 shot by an arrow
X * 260 hit by a dart
X * 261 fell into a pit
X * 262 fell into a bottomless pit
X * 263 a winner
X * 264 trapped in solid rock
X * 265 killed by a missing save file
X * 266 killed by an old save file
X * 267 caught by the greedy cheater checker trap
X * 268 killed by a protected save file
X * 269 killed his family and killed himself
X * 270 erased by a wayward finger
X * 271 fell through a bottomless trap door
X * 272 fell through a trap door
X * 273 drank some poisonous water
X * 274 fried by an electric shock
X * 275 slipped on a volcano shaft
X * 276 killed by a stupid act of frustration
X * 277 attacked by a revolting demon
X * 278 hit by his own magic
X * 279 demolished by an unseen attacker
X * 280 fell into the dreadful sleep
X * 281 killed by an exploding chest
X * 282 killed by a missing maze data file
X * 283 killed by a sphere of annihilation
X * 284 died a post mortem death
X * 285 malloc() failure
X * 300 quick quit -- don't put on scoreboard
X */
X
Xstatic int scorerror;
Xdied(x)
X int x;
X `7B
X register int f,win;
X char ch,*mod;
X long zzz,i;
X#ifndef MSDOS
X# ifdef EXTRA
X struct tms cputime;
X# endif
X#endif
X if (c`5BLIFEPROT`5D>0) /* if life protection */
X `7B
X switch((x>0) ? x : -x)
X `7B
X case 256: case 257: case 262: case 263: case 265: case 266:
X case 267: case 268: case 269: case 271: case 282: case 284:
X case 285: case 300: goto invalid; /* can't be saved */
X `7D;
X --c`5BLIFEPROT`5D; c`5BHP`5D=1; --c`5BCONSTITUTION`5D;
X cursors(); lprcat("\nYou feel wiiieeeeerrrrrd all over! "); beep();
X lflush(); sleep(4);
X return; /* only case where died() returns */
X `7D
Xinvalid:
X clearvt100(); lflush(); f=0;
X if (ckpflag) unlink(ckpfile); /* remove checkpoint file if used */
X# ifdef MSDOS
X if (swapfd) `7B
X close(swapfd);
X (void) unlink(swapfile);/* Remove swapfile */
X `7D
X unsetraw();
X# endif
X if (x<0) `7B f++; x = -x; `7D /* if we are not to display the scores *
V/
X if ((x == 300) `7C`7C (x == 257)) exit(); /* for quick exit or saved g
Vame */
X if (x == 263) win = 1; else win = 0;
X c`5BGOLD`5D += c`5BBANKACCOUNT`5D; c`5BBANKACCOUNT`5D = 0;
X /* now enter the player at the end of the scoreboard */
X newscore(c`5BGOLD`5D, logname, x, win);
X diedsub(x); /* print out the score line */ lflush();
X
X set_score_output();
X if ((wizard == 0) && (c`5BGOLD`5D > 0)) /* wizards can't score
V */
X `7B
X if (lappend(logfile)<0) /* append to file */
X `7B
X if (lcreat(logfile)<0) /* and can't create new log file */
X `7B
X lcreat((char*)0);
X lprcat("\nCan't open record file: I can't post your score.\
Vn");
X sncbr(); resetscroll(); lflush(); exit();
X `7D
X chmod(logfile,0666);
X `7D
X strcpy(logg.who,loginname);
X logg.score = c`5BGOLD`5D; logg.diff = c`5BHARDGAME`5D;
X if (x < 256)
X `7B
+-+-+-+-+-+-+-+- END OF PART 37 +-+-+-+-+-+-+-+-