Path: news.larc.nasa.gov!amiga-request
From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
Subject: v91i154: Larn 12.3 - dungeon type adventure game, Part10/17
Reply-To: Sie <S.Raybould@fulcrum.bt.co.uk>
Newsgroups: comp.sources.amiga
Message-ID: <comp.sources.amiga.v91i154@ab20.larc.nasa.gov>
References: <comp.sources.amiga.v91i145@ab20.larc.nasa.gov>
Date: 29 Aug 91 10:10:40 GMT
Approved: tadguy@uunet.UU.NET (Tad Guy)
X-Mail-Submissions-To: amiga@uunet.uu.net
X-Post-Discussions-To: comp.sys.amiga.misc

Submitted-by: Sie <S.Raybould@fulcrum.bt.co.uk>
Posting-number: Volume 91, Issue 154
Archive-name: games/larn-12.3/part10

#!/bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 10 (of 17)."
# Contents:  scores.c
# Wrapped by tadguy@ab20 on Mon Aug 26 21:51:54 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'scores.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'scores.c'\"
else
echo shar: Extracting \"'scores.c'\" \(26174 characters\)
sed "s/^X//" >'scores.c' <<'END_OF_FILE'
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 buffer
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 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 them
X *  sortboard()     Function to sort the scoreboard
X *  newscore(score, whoo, whyded, winner)   Function to add entry to scoreboard
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 killed
X *  diedlog()   Subroutine to read a log file and print it out in ascii format
X *  getplid(name)       Function to get players id # from id file
X */
X#ifdef VMS
X# include <types.h>
X# include <stat.h>
X#else
X# include <sys/types.h>
X# ifndef MSDOS
X#  ifndef AMIGA
X#   include <sys/times.h>
X#  endif AMIGA
X# endif MSDOS
X# include <sys/stat.h>
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        */
X    {
X    long score;         /* the score of the player                          */
X    long suid;          /* the user id number of the player                 */
X    short what;         /* the number of the monster that killed player     */
X    short level;        /* the level player was on when he died             */
X    short hardlev;      /* the level of difficulty player played at         */
X    short order;        /* the relative ordering place of this entry        */
X    char who[40];       /* the name of the character                        */
X    char sciv[26][2];   /* this is the inventory list of the character      */
X    };
Xstruct wscofmt          /* This is the structure for the winning scoreboard */
X    {
X    long score;         /* the score of the player                          */
X    long timeused;      /* the time used in mobuls to win the game          */
X    long taxes;         /* taxes he owes to LRS                             */
X    long suid;          /* the user id number of the player                 */
X    short hardlev;      /* the level of difficulty player played at         */
X    short order;        /* the relative ordering place of this entry        */
X# ifndef MAIL           /* dgk */
X    char hasmail;       /* 1 if mail is to be read, 0 otherwise */
X# endif
X    char who[40];       /* the name of the character                        */
X    };
X
Xstruct log_fmt          /* 102 bytes struct for the log file                */
X    {
X    long score;         /* the players score                                */
X    long diedtime;      /* time when game was over                          */
X    short cavelev;      /* level in caves                                   */
X    short diff;         /* difficulty player played at                      */
X#ifdef EXTRA
X    long elapsedtime;   /* real time of game in seconds                     */
X    long bytout;        /* bytes input and output                           */
X    long bytin;
X    long moves;         /* number of moves made by player                   */
X    short ac;           /* armor class of player                            */
X    short hp,hpmax;     /* players hitpoints                                */
X    short cputime;      /* cpu time needed in seconds                       */
X    short killed,spused;/* monsters killed and spells cast                  */
X    short usage;        /* usage of the cpu in %                            */
X    short lev;          /* player level                                     */
X#endif
X    char who[12];       /* player name                                      */
X    char what[46];      /* what happened to player                          */
X    };
X
Xstatic struct scofmt sco[SCORESIZE];    /* the structure for the scoreboard  */
Xstatic struct wscofmt winr[SCORESIZE];  /* struct for the winning scoreboard */
Xstatic struct log_fmt logg;             /* structure for the log file        */
Xstatic char *whydead[] = {
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",
X    "killed by a protected save file","killed his family and committed suicide",
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",
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    };
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    {
X    if (lopen(scorefile)<0)
X      { lprcat("Can't read scoreboard\n"); lflush(); return(-1); }
X    lrfill((char*)sco,sizeof(sco));     lrfill((char*)winr,sizeof(winr));
X    lrclose();  lcreat((char*)0);  return(0);
X    }
X
X/*
X *  writeboard()    Function to write the scoreboard from readboard()'s buffer
X *
X *  returns -1 if unable to write the scoreboard, returns 0 if all is OK
X */
Xstatic writeboard()
X    {
X    set_score_output();
X    if (lcreat(scorefile)<0)
X      { lprcat("Can't write scoreboard\n"); lflush(); return(-1); }
X    lwrite((char*)sco,sizeof(sco));     lwrite((char*)winr,sizeof(winr));
X    lwclose();  lcreat((char*)0);  return(0);
X    }
X
X/*
X *  makeboard()         Function to create a new scoreboard (wipe out old one)
X *
X *  returns -1 if unable to write the scoreboard, returns 0 if all is OK
X */
Xmakeboard()
X    {
X    register int i;
X    for (i=0; i<SCORESIZE; i++)
X        {
X        winr[i].taxes = winr[i].score = sco[i].score = 0;
X        winr[i].order = sco[i].order = i;
X        }
X    if (writeboard()) return(-1);
X    chmod(scorefile,0666);
X    return(0);
X    }
X
X/*
X *  hashewon()   Function to return 1 if player has won a game before, else 0
X *
X *  This function also sets c[HARDGAME] to appropriate value -- 0 if not a
X *  winner, otherwise the next level of difficulty listed in the winners
X *  scoreboard.  This function also sets outstanding_taxes to the value in
X *  the winners scoreboard.
X */
Xhashewon()
X    {
X    register int i;
X    c[HARDGAME] = 0;
X    if (readboard() < 0) return(0); /* can't find scoreboard */
X    for (i=0; i<SCORESIZE; i++) /* search through winners scoreboard */
X       if (winr[i].suid == userid)
X          if (winr[i].score > 0)
X            {
X            c[HARDGAME]=winr[i].hardlev+1;  outstanding_taxes=winr[i].taxes;
X            return(1);
X            }
X    return(0);
X    }
X
X# ifndef MAIL           /* dgk */
Xcheckmail()
X{
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[i].suid == userid
X        &&  winr[i].score > 0
X        &&  winr[i].hasmail) {
X            winr[i].hasmail = 0;
X            gold = taxes = winr[i].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        }
X}
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    {
X    register int i;
X    register long amt;
X    if (x<0) return(0L);
X    if (readboard()<0) return(0L);
X    for (i=0; i<SCORESIZE; i++)
X        if (winr[i].suid == userid) /* look for players winning entry */
X            if (winr[i].score>0) /* search for a winning entry for the player */
X                {
X                amt = winr[i].taxes;
X                if (x < amt) amt=x;     /* don't overpay taxes (Ughhhhh) */
X                winr[i].taxes -= amt;
X                outstanding_taxes -= amt;
X                if (writeboard()<0) return(0);
X                return(amt);
X                }
X    return(0L); /* couldn't find user on winning scoreboard */
X    }
X
X/*
X *  winshou()       Subroutine to print out the winning scoreboard
X *
X *  Returns the number of players on scoreboard that were shown 
X */
Xstatic winshou()
X    {
X    register struct wscofmt *p;
X    register int i,j,count;
X    for (count=j=i=0; i<SCORESIZE; i++) /* is there anyone on the scoreboard? */
X        if (winr[i].score != 0)
X            { j++; break; }
X    if (j)
X        {
X        lprcat("\n  Score    Difficulty   Time Needed   Larn Winners List\n");
X
X        for (i=0; i<SCORESIZE; i++) /* this loop is needed to print out the */
X          for (j=0; j<SCORESIZE; j++) /* winners in order */
X            {
X            p = &winr[j];   /* pointer to the scoreboard entry */
X            if (p->order == i)
X                {
X                if (p->score)
X                    {
X                    count++;
X                    lprintf("%10d     %2d      %5d Mobuls   %s \n",
X                    (long)p->score,(long)p->hardlev,(long)p->timeused,p->who);
X                    }
X                break;
X                }
X            }
X        }
X    return(count);  /* return number of people on scoreboard */
X    }
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 
X */
Xstatic shou(x)
X    int x;
X    {
X    register int i,j,n,k;
X    int count;
X    for (count=j=i=0; i<SCORESIZE; i++) /* is the scoreboard empty? */
X        if (sco[i].score!= 0)
X            { j++; break; }
X    if (j)
X        {
X        lprcat("\n   Score   Difficulty   Larn Visitor Log\n");
X        for (i=0; i<SCORESIZE; i++) /* be sure to print them out in order */
X          for (j=0; j<SCORESIZE; j++)
X            if (sco[j].order == i)
X                {
X                if (sco[j].score)
X                    {
X                    count++;
X                    lprintf("%10d     %2d       %s ",
X                        (long)sco[j].score,(long)sco[j].hardlev,sco[j].who);
X                    if (sco[j].what < 256) lprintf("killed by a %s",monster[sco[j].what].name);
X                        else lprintf("%s",whydead[sco[j].what - 256]);
X                    if (x != 263) lprintf(" on %s",levelname[sco[j].level]);
X                    if (x)
X                        {
X                        for (n=0; n<26; n++) { iven[n]=sco[j].sciv[n][0]; ivenarg[n]=sco[j].sciv[n][1]; }
X                        for (k=1; k<99; k++)
X                          for (n=0; n<26; n++)
X                            if (k==iven[n]) show3(n);
X                        lprcat("\n\n");
X                        }
X                    else lprc('\n');
X                    }
X                j=SCORESIZE;
X                }
X        }
X    return(count);  /* return the number of players just shown */
X    }
X
X/*
X *  showscores()        Function to show the scoreboard on the terminal
X *
X *  Returns nothing of value
X */
Xstatic char esb[] = "The scoreboard is empty.\n";
Xshowscores()
X    {
X    register int i,j;
X    lflush();  lcreat((char*)0);  if (readboard()<0) return;
X    i=winshou();    j=shou(0);
X    if (i+j == 0) lprcat(esb); else lprc('\n');
X    lflush();
X    }
X
X/*
X *  showallscores() Function to show scores and the iven lists that go with them
X *
X *  Returns nothing of value
X */
Xshowallscores()
X    {
X    register int i,j;
X    lflush();  lcreat((char*)0);  if (readboard()<0) return;
X    c[WEAR] = c[WIELD] = c[SHIELD] = -1;  /* not wielding or wearing anything */
X    for (i=0; i<MAXPOTION; i++) potionname[i][0]=' ';
X    for (i=0; i<MAXSCROLL; i++) scrollname[i][0]=' ';
X    i=winshou();  j=shou(1);
X    if (i+j==0) lprcat(esb); else lprc('\n');
X    lflush();
X    }
X
X/*
X *  sortboard()     Function to sort the scoreboard
X *
X *  Returns 0 if no sorting done, else returns 1
X */
Xstatic sortboard()
X    {
X    register int i,j,pos;
X    long jdat;
X    for (i=0; i<SCORESIZE; i++) sco[i].order = winr[i].order = -1;
X    pos=0;  while (pos < SCORESIZE)
X        {
X        jdat=0;
X        for (i=0; i<SCORESIZE; i++)
X            if ((sco[i].order < 0) && (sco[i].score >= jdat))
X                { j=i;  jdat=sco[i].score; }
X        sco[j].order = pos++;
X        }
X    pos=0;  while (pos < SCORESIZE)
X        {
X        jdat=0;
X        for (i=0; i<SCORESIZE; i++)
X            if ((winr[i].order < 0) && (winr[i].score >= jdat))
X                { j=i;  jdat=winr[i].score; }
X        winr[j].order = pos++;
X        }
X    return(1);
X    }
X
X/*
X *  newscore(score, whoo, whyded, winner)   Function to add entry to scoreboard
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    {
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        {
X        for (i=0; i<SCORESIZE; i++) if (sco[i].suid == userid) sco[i].score=0;
X        taxes = score*TAXRATE;
X        score += 100000*c[HARDGAME];    /* bonus for winning */
X    /* if he has a slot on the winning scoreboard update it if greater score */
X        for (i=0; i<SCORESIZE; i++) if (winr[i].suid == userid)
X                { new1sub(score,i,whoo,taxes); return; }
X    /* he had no entry. look for last entry and see if he has a greater score */
X        for (i=0; i<SCORESIZE; i++) if (winr[i].order == SCORESIZE-1)
X                { new1sub(score,i,whoo,taxes); return; }
X        }
X    else if (!cheat) /* for not winning scoreboard */
X        {
X    /* if he has a slot on the scoreboard update it if greater score */
X        for (i=0; i<SCORESIZE; i++) if (sco[i].suid == userid)
X                { new2sub(score,i,whoo,whyded); return; }
X    /* he had no entry. look for last entry and see if he has a greater score */
X        for (i=0; i<SCORESIZE; i++) if (sco[i].order == SCORESIZE-1)
X                { new2sub(score,i,whoo,whyded); return; }
X        }
X    }
X
X/*
X *  new1sub(score,i,whoo,taxes)       Subroutine to put player into a 
X *      int score,i,whyded,taxes;         winning scoreboard entry if his score
X *      char *whoo;                       is high enough
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 *      slot in scoreboard in i, and the tax bill in taxes.
X *  Returns nothing of value
X */
Xstatic new1sub(score,i,whoo,taxes)
X    long score,taxes;
X    int i;
X    char *whoo;
X    {
X    register struct wscofmt *p;
X    p = &winr[i];
X    p->taxes += taxes;
X    if ((score >= p->score) || (c[HARDGAME] > p->hardlev))
X        {
X        strcpy(p->who,whoo);        p->score=score;
X        p->hardlev=c[HARDGAME];     p->suid=userid;
X        p->timeused=gtime/100;
X# ifndef MAIL           /* dgk */
X        p->hasmail = 1;
X# endif
X        }
X    }
X
X/*
X *  new2sub(score,i,whoo,whyded)          Subroutine to put player into a 
X *      int score,i,whyded,taxes;         non-winning scoreboard entry if his
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    {
X    register int j;
X    register struct scofmt *p;
X    p = &sco[i];
X    if ((score >= p->score) || (c[HARDGAME] > p->hardlev))
X        {
X        strcpy(p->who,whoo);  p->score=score;
X        p->what=whyded;       p->hardlev=c[HARDGAME];
X        p->suid=userid;       p->level=level;
X        for (j=0; j<26; j++)
X            { p->sciv[j][0]=iven[j]; p->sciv[j][1]=ivenarg[j]; }
X        }
X    }
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[LIFEPROT] and a reincarnatable death!)
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    {
X    register int f,win;
X    char ch,*mod;
X    long zzz,i;
X# ifdef EXTRA
X    struct tms cputime;
X# endif
X    if (c[LIFEPROT]>0) /* if life protection */
X        {
X        switch((x>0) ? x : -x)
X            {
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            };
X        --c[LIFEPROT]; c[HP]=1; --c[CONSTITUTION];
X        cursors(); lprcat("\nYou feel wiiieeeeerrrrrd all over! "); beep();
X        lflush();  sleep(4);
X        return; /* only case where died() returns */
X        }
Xinvalid:
X    clearvt100();  lflush();  f=0;
X    if (ckpflag) unlink(ckpfile);   /* remove checkpoint file if used */
X# ifdef MSDOS
X    if (swapfd) {
X        close(swapfd);
X        (void) unlink(swapfile);/* Remove swapfile */
X    }
X    unsetraw();
X# endif
X    if (x<0) { f++; x = -x; }   /* if we are not to display the scores */
X    if ((x == 300) || (x == 257))  exit();  /* for quick exit or saved game */
X    if (x == 263)  win = 1;  else  win = 0;
X    c[GOLD] += c[BANKACCOUNT];   c[BANKACCOUNT] = 0;
X        /*  now enter the player at the end of the scoreboard */
X    newscore(c[GOLD], logname, x, win);
X    diedsub(x); /* print out the score line */  lflush();
X
X    set_score_output();
X    if ((wizard == 0) && (c[GOLD] > 0))     /*  wizards can't score     */
X        {
X        if (lappend(logfile)<0)  /* append to file */
X            {
X            if (lcreat(logfile)<0) /* and can't create new log file */
X                {
X                lcreat((char*)0);
X                lprcat("\nCan't open record file:  I can't post your score.\n");
X                sncbr();  resetscroll();  lflush();  exit();
X                }
X            chmod(logfile,0666);
X            }
X        strcpy(logg.who,loginname);
X        logg.score = c[GOLD];       logg.diff = c[HARDGAME];
X        if (x < 256)
X            {
X            ch = *monster[x].name;
X            if (ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
X                mod="an";  else mod="a";
X            sprintf(logg.what,"killed by %s %s",mod,monster[x].name);
X            }
X        else sprintf(logg.what,"%s",whydead[x - 256]);
X        logg.cavelev=level;
X        time(&zzz);   /* get cpu time -- write out score info */
X        logg.diedtime=zzz;
X#ifdef EXTRA
X        times(&cputime);  /* get cpu time -- write out score info */
X        logg.cputime = i = (cputime.tms_utime + cputime.tms_stime)/60 + c[CPUTIME];
X        logg.lev=c[LEVEL];          logg.ac=c[AC];
X        logg.hpmax=c[HPMAX];        logg.hp=c[HP];
X        logg.elapsedtime=(zzz-initialtime+59)/60;
X        logg.usage=(10000*i)/(zzz-initialtime);
X        logg.bytin=c[BYTESIN];      logg.bytout=c[BYTESOUT];
X        logg.moves=c[MOVESMADE];    logg.spused=c[SPELLSCAST];
X        logg.killed=c[MONSTKILLED];
X#endif
X        lwrite((char*)&logg,sizeof(struct log_fmt));     lwclose();
X
X/*  now for the scoreboard maintenance -- not for a suspended game  */
X        if (x != 257)
X            {
X            if (sortboard())  scorerror = writeboard();
X            }
X        }
X    if ((x==256) || (x==257) || (f != 0)) exit();
X    if (scorerror == 0) showscores();   /* if we updated the scoreboard */
X# ifdef MAIL
X    if (x == 263) mailbill();
X# endif
X    exit();
X    }
X
X/*
X *  diedsub(x) Subroutine to print out the line showing the player when he is killed
X *      int x;
X */
Xstatic diedsub(x)
Xint x;
X    {
X    register char ch,*mod;
X    lprintf("Score: %d, Diff: %d,  %s ",(long)c[GOLD],(long)c[HARDGAME],logname);
X    if (x < 256)
X        {
X        ch = *monster[x].name;
X        if (ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
X            mod="an";  else mod="a";
X        lprintf("killed by %s %s",mod,monster[x].name);
X        }
X    else lprintf("%s",whydead[x - 256]);
X    if (x != 263) lprintf(" on %s\n",levelname[level]);  else lprc('\n');
X    }
X
X/*
X *  diedlog()   Subroutine to read a log file and print it out in ascii format
X */
Xdiedlog()
X    {
X    register int n;
X    register char *p;
X    struct stat stbuf;
X    lcreat((char*)0);
X    if (lopen(logfile)<0)
X        {
X        lprintf("Can't locate log file <%s>\n",logfile);
X        return;
X        }
X#ifdef AMIGA
X    if (stat(logfile,&stbuf) < 0)
X#else
X    if (fstat(fd,&stbuf) < 0)
X#endif /* AMIGA */
X        {
X        lprintf("Can't  stat log file <%s>\n",logfile);
X        return;
X        }
X    for (n=stbuf.st_size/sizeof(struct log_fmt); n>0; --n)
X        {
X        lrfill((char*)&logg,sizeof(struct log_fmt));
X        p = ctime(&logg.diedtime); p[16]='\n'; p[17]=0;
X        lprintf("Score: %d, Diff: %d,  %s %s on %d at %s",(long)(logg.score),(long)(logg.diff),logg.who,logg.what,(long)(logg.cavelev),p+4);
X#ifdef EXTRA
X        if (logg.moves<=0) logg.moves=1;
X        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));
X        lprintf("  CPU time used: %d seconds,  Machine usage: %d.%02d%%\n",(long)(logg.cputime),(long)(logg.usage/100),(long)(logg.usage%100));
X        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));
X        lprintf("  out bytes per move: %d,  time per move: %d ms\n",(long)(logg.bytout/logg.moves),(long)((logg.cputime*1000)/logg.moves));
X#endif
X        }
X        lflush();  lrclose();  return;
X    }
X
X#ifndef UIDSCORE
X/*
X *  getplid(name)       Function to get players id # from id file
X *
X *  Enter with the name of the players character in name.
X *  Returns the id # of the players character, or -1 if failure.
X *  This routine will try to find the name in the id file, if its not there,
X *  it will try to make a new entry in the file.  Only returns -1 if can't
X *  find him in the file, and can't make a new entry in the file.
X *  Format of playerids file:
X *          Id # in ascii     \n     character name     \n   
X */
Xstatic int havepid= -1; /* playerid # if previously done */
Xgetplid(nam)
X    char *nam;
X    {
X    int fd7,high=999,no;
X    register char *p,*p2;
X    char name[80];
X    if (havepid != -1) return(havepid); /* already did it */
X    lflush();   /* flush any pending I/O */
X    sprintf(name,"%s\n",nam);   /* append a \n to name */
X    if (lopen(playerids) < 0)   /* no file, make it */
X        {
X        if ((fd7=creat(playerids,0666)) < 0)  return(-1); /* can't make it */
X        close(fd7);  goto addone;   /* now append new playerid record to file */
X        }
X    for (;;)    /* now search for the name in the player id file */
X        {
X        p = lgetl();  if (p==NULL) break;   /* EOF? */
X        no = atoi(p);   /* the id # */
X        p2= lgetl();  if (p2==NULL) break;  /* EOF? */
X        if (no>high) high=no;   /* accumulate highest id # */
X        if (strcmp(p2,name)==0) /* we found him */
X            {
X            return(no); /* his id number */
X            }
X        }
X    lrclose();
X    /* if we get here, we didn't find him in the file -- put him there */
Xaddone:
X    if (lappend(playerids) < 0) return(-1); /* can't open file for append */
X    lprintf("%d\n%s",(long)++high,name);  /* new id # and name */
X    lwclose();
X    lcreat((char*)0);   /* re-open terminal channel */
X    return(high);
X    }
X#endif UIDSCORE
END_OF_FILE
if test 26174 -ne `wc -c <'scores.c'`; then
    echo shar: \"'scores.c'\" unpacked with wrong size!
fi
# end of 'scores.c'
fi
echo shar: End of archive 10 \(of 17\).
cp /dev/null ark10isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 17 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
Mail comments to the moderator at <amiga-request@uunet.uu.net>.
Post requests for sources, and general discussion to comp.sys.amiga.misc.
