Path: news.larc.nasa.gov!amiga-request
From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
Subject: v91i150: Larn 12.3 - dungeon type adventure game, Part06/17
Reply-To: Sie <S.Raybould@fulcrum.bt.co.uk>
Newsgroups: comp.sources.amiga
Message-ID: <comp.sources.amiga.v91i150@ab20.larc.nasa.gov>
References: <comp.sources.amiga.v91i145@ab20.larc.nasa.gov>
Date: 27 Aug 91 01:51:57 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 150
Archive-name: games/larn-12.3/part06

#!/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 6 (of 17)."
# Contents:  create.c diag.c tok.c
# Wrapped by tadguy@ab20 on Mon Aug 26 21:51:53 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'create.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'create.c'\"
else
echo shar: Extracting \"'create.c'\" \(15884 characters\)
sed "s/^X//" >'create.c' <<'END_OF_FILE'
X/* create.c */
X#include "header.h"
X#include "larndefs.h"
X#include "monsters.h"
X#include "objects.h"
X#include "player.h"
X
X/*
X    makeplayer()
X
X    subroutine to create the player and the players attributes
X    this is called at the beginning of a game and at no other time
X */
Xmakeplayer()
X    {
X    register int i;
X    scbr();  clear();
X    c[HPMAX]=c[HP]=10;      /*  start player off with 15 hit points */
X    c[LEVEL]=1;             /*  player starts at level one          */
X    c[SPELLMAX]=c[SPELLS]=1;    /*  total # spells starts off as 3  */
X    c[REGENCOUNTER]=16;     c[ECOUNTER]=96; /*start regeneration correctly*/
X    c[SHIELD] = c[WEAR] = c[WIELD] = -1;
X    for (i=0; i<26; i++)  iven[i]=0;
X    spelknow[0]=spelknow[1]=1; /*he knows protection, magic missile*/
X    if (c[HARDGAME]<=0)
X        {
X        iven[0]=OLEATHER; iven[1]=ODAGGER; iven[2] = 0;
X        ivenarg[1]=ivenarg[0]=c[WEAR]=0;  c[WIELD]=1;
X        }
X    playerx=rnd(MAXX-2);    playery=rnd(MAXY-2);
X    regen_bottom = TRUE ;
X    for (i=0; i<6; i++)  c[i]=12; /* make the attributes, ie str, int, etc. */
X    recalc();
X    }
X
X/*
X    newcavelevel(level)
X    int level;
X
X    function to enter a new level.  This routine must be called anytime the
X    player changes levels.  If that level is unknown it will be created.
X    A new set of monsters will be created for a new level, and existing
X    levels will get a few more monsters.
X    Note that it is here we remove genocided monsters from the present level.
X */
Xnewcavelevel(x)
X    register int x;
X    {
X    register int i,j;
X    if (beenhere[level]) savelevel();   /* put the level back into storage  */
X    level = x;              /* get the new level and put in working storage */
X    if (beenhere[x])
X        {
X        getlevel();
X        sethp(0);
X        positionplayer();
X        checkgen();
X        return;
X        }
X
X    /* fill in new level
X    */
X    for (i=0; i<MAXY; i++)
X        for (j=0; j<MAXX; j++)
X            know[j][i]=mitem[j][i]=0;
X    makemaze(x);
X    makeobject(x);
X    beenhere[x]=1;
X    sethp(1);
X    positionplayer();
X    checkgen();   /* wipe out any genocided monsters */
X
X#if WIZID
X    if (wizard || x==0)
X#else
X    if (x==0)
X#endif
X        for (j=0; j<MAXY; j++)
X            for (i=0; i<MAXX; i++)
X                know[i][j] = KNOWALL;
X    }
X
X/*
X    makemaze(level)
X    int level;
X
X    subroutine to make the caverns for a given level.  only walls are made.
X */
Xstatic int mx,mxl,mxh,my,myl,myh,tmp2;
Xstatic makemaze(k)
X    int k;
X    {
X    register int i,j,tmp;
X    int z;
X    if (k > 1 && (rnd(17)<=4 || k==MAXLEVEL-1 || k==MAXLEVEL+MAXVLEVEL-1))
X        {
X        if (cannedlevel(k));    return;     /* read maze from data file */
X        }
X    if (k==0)  tmp=0;  else tmp=OWALL;
X    for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)  item[j][i]=tmp;
X    if (k==0) return;       eat(1,1);
X    if (k==1) item[33][MAXY-1] = OENTRANCE;
X
X/*  now for open spaces -- not on level 10  */
X    if (k != MAXLEVEL-1)
X        {
X        tmp2 = rnd(3)+3;
X        for (tmp=0; tmp<tmp2; tmp++)
X            {
X            my = rnd(11)+2;   myl = my - rnd(2);  myh = my + rnd(2);
X            if (k < MAXLEVEL)
X                {
X                mx = rnd(44)+5;  mxl = mx - rnd(4);  mxh = mx + rnd(12)+3;
X                z=0;
X                }
X            else
X                {
X                mx = rnd(60)+3;  mxl = mx - rnd(2);  mxh = mx + rnd(2);
X                z = makemonst(k);
X                }
X            for (i=mxl; i<mxh; i++)     for (j=myl; j<myh; j++)
X                {  item[i][j]=0;
X                   if ((mitem[i][j]=z)) hitp[i][j]=monster[z].hitpoints;
X                }
X            }
X        }
X    if (k!=MAXLEVEL-1) { my=rnd(MAXY-2);  for (i=1; i<MAXX-1; i++)  item[i][my] = 0; }
X    if (k>1)  treasureroom(k);
X    }
X
X/*
X    function to eat away a filled in maze
X */
Xeat(xx,yy)
X    register int xx,yy;
X    {
X    register int dir,try;
X    dir = rnd(4);   try=2;
X    while (try)
X        {
X        switch(dir)
X            {
X            case 1: if (xx <= 2) break;     /*  west    */
X                    if ((item[xx-1][yy]!=OWALL) || (item[xx-2][yy]!=OWALL)) break;
X                    item[xx-1][yy] = item[xx-2][yy] = 0;
X                    eat(xx-2,yy);   break;
X
X            case 2: if (xx >= MAXX-3) break;    /*  east    */
X                    if ((item[xx+1][yy]!=OWALL) || (item[xx+2][yy]!=OWALL)) break;
X                    item[xx+1][yy] = item[xx+2][yy] = 0;
X                    eat(xx+2,yy);   break;
X
X            case 3: if (yy <= 2) break;     /*  south   */
X                    if ((item[xx][yy-1]!=OWALL) || (item[xx][yy-2]!=OWALL)) break;
X                    item[xx][yy-1] = item[xx][yy-2] = 0;
X                    eat(xx,yy-2);   break;
X
X            case 4: if (yy >= MAXY-3 ) break;   /*  north   */
X                    if ((item[xx][yy+1]!=OWALL) || (item[xx][yy+2]!=OWALL)) break;
X                    item[xx][yy+1] = item[xx][yy+2] = 0;
X                    eat(xx,yy+2);   break;
X            };
X        if (++dir > 4)  { dir=1;  --try; }
X        }
X    }
X
X/*
X *  function to read in a maze from a data file
X *
X *  Format of maze data file:  1st character = # of mazes in file (ascii digit)
X *              For each maze: 18 lines (1st 17 used) 67 characters per line
X *
X *  Special characters in maze data file:
X *
X *      #   wall            D   door            .   random monster
X *      ~   eye of larn     !   cure dianthroritis
X *      -   random object
X */
Xstatic cannedlevel(k)
X    int k;
X    {
X    char *row,*lgetl();
X    register int i,j;
X    int it,arg,mit,marg;
X    if (lopen(larnlevels)<0)
X        {
X        write(1,"Can't open the maze data file\n",30);   died(-282); return(0);
X        }
X    i=lgetc();  if (i<='0') { died(-282); return(0); }
X    for (i=18*rund(i-'0'); i>0; i--)    lgetl();   /* advance to desired maze */
X    for (i=0; i<MAXY; i++)
X        {
X        row = lgetl();
X        for (j=0; j<MAXX; j++)
X            {
X            it = mit = arg = marg = 0;
X            switch(*row++)
X                {
X                case '#': it = OWALL;                               break;
X                case 'D': it = OCLOSEDDOOR;     arg = rnd(30);      break;
X                case '~': if (k!=MAXLEVEL-1) break;
X                          it = OLARNEYE;
X                          mit = rund(8)+DEMONLORD;
X                          marg = monster[mit].hitpoints;            break;
X                case '!': if (k!=MAXLEVEL+MAXVLEVEL-1)  break;
X                          it = OPOTION;         arg = 21;
X                          mit = DEMONLORD+7;
X                          marg = monster[mit].hitpoints;            break;
X                case '.': if (k<MAXLEVEL)  break;
X                          mit = makemonst(k+1);
X                          marg = monster[mit].hitpoints;            break;
X                case '-': it = newobject(k+1,&arg);                 break;
X                };
X            item[j][i] = it;        iarg[j][i] = arg;
X            mitem[j][i] = mit;      hitp[j][i] = marg;
X
X#if WIZID
X            know[j][i] = (wizard) ? KNOWALL : 0;
X#else
X            know[j][i] = 0;
X#endif
X            }
X        }
X    lrclose();
X    return(1);
X    }
X
X/*
X    function to make a treasure room on a level
X    level 10's treasure room has the eye in it and demon lords
X    level V3 has potion of cure dianthroritis and demon prince
X */
Xstatic treasureroom(lv)
X    register int lv;
X    {
X    register int tx,ty,xsize,ysize;
X
X    for (tx=1+rnd(10);  tx<MAXX-10;  tx+=10)
X      if ( (lv==MAXLEVEL-1) || (lv==MAXLEVEL+MAXVLEVEL-1) || rnd(13)==2)
X        {
X        xsize = rnd(6)+3;       ysize = rnd(3)+3;  
X        ty = rnd(MAXY-9)+1;  /* upper left corner of room */
X        if (lv==MAXLEVEL-1 || lv==MAXLEVEL+MAXVLEVEL-1)
X            troom(lv,xsize,ysize,tx=tx+rnd(MAXX-24),ty,rnd(3)+6);
X            else troom(lv,xsize,ysize,tx,ty,rnd(9));
X        }
X    }
X
X/*
X *  subroutine to create a treasure room of any size at a given location 
X *  room is filled with objects and monsters 
X *  the coordinate given is that of the upper left corner of the room
X */
Xstatic troom(lv,xsize,ysize,tx,ty,glyph)
X    int lv,xsize,ysize,tx,ty,glyph;
X    {
X    register int i,j;
X    int tp1,tp2;
X    for (j=ty-1; j<=ty+ysize; j++)
X        for (i=tx-1; i<=tx+xsize; i++)          /* clear out space for room */
X            item[i][j]=0;
X    for (j=ty; j<ty+ysize; j++)
X        for (i=tx; i<tx+xsize; i++)             /* now put in the walls */
X            {
X            item[i][j]=OWALL; mitem[i][j]=0; 
X            }
X    for (j=ty+1; j<ty+ysize-1; j++)
X        for (i=tx+1; i<tx+xsize-1; i++)         /* now clear out interior */
X            item[i][j]=0;
X
X    switch(rnd(2))      /* locate the door on the treasure room */
X        {
X        case 1: item[i=tx+rund(xsize)][j=ty+(ysize-1)*rund(2)]=OCLOSEDDOOR;
X                iarg[i][j] = glyph;     /* on horizontal walls */
X                break;
X        case 2: item[i=tx+(xsize-1)*rund(2)][j=ty+rund(ysize)]=OCLOSEDDOOR;
X                iarg[i][j] = glyph;     /* on vertical walls */
X                break;
X        };
X
X    tp1=playerx;  tp2=playery;  playery=ty+(ysize>>1);
X    if (c[HARDGAME]<2)
X        for (playerx=tx+1; playerx<=tx+xsize-2; playerx+=2)
X            for (i=0, j=rnd(6); i<=j; i++)
X                { something(lv+2); createmonster(makemonst(lv+1)); }
X    else
X        for (playerx=tx+1; playerx<=tx+xsize-2; playerx+=2)
X            for (i=0, j=rnd(4); i<=j; i++)
X                { something(lv+2); createmonster(makemonst(lv+3)); }
X
X    playerx=tp1;  playery=tp2;
X    }
X
X/*
X    ***********
X    MAKE_OBJECT
X    ***********
X    subroutine to create the objects in the maze for the given level
X */
Xstatic makeobject(j)
X    register int j;
X    {
X    register int i;
X    if (j==0)
X        {
X        fillroom(OENTRANCE,0);      /*  entrance to dungeon         */
X        fillroom(ODNDSTORE,0);      /*  the DND STORE               */
X        fillroom(OSCHOOL,0);        /*  college of Larn             */
X        fillroom(OBANK,0);          /*  1st national bank of larn   */
X        fillroom(OVOLDOWN,0);       /*  volcano shaft to temple     */
X        fillroom(OHOME,0);          /*  the players home & family   */
X        fillroom(OTRADEPOST,0);     /*  the trading post            */
X        fillroom(OLRS,0);           /*  the larn revenue service    */
X        return;
X        }
X
X    if (j==MAXLEVEL) fillroom(OVOLUP,0); /* volcano shaft up from the temple */
X
X/*  make the fixed objects in the maze STAIRS   */
X    if ((j>0) && (j != MAXLEVEL-1) && (j != MAXLEVEL+MAXVLEVEL-1))
X        fillroom(OSTAIRSDOWN,0);
X    if ((j > 1) && (j != MAXLEVEL))
X        fillroom(OSTAIRSUP,0);
X
X/*  make the random objects in the maze     */
X
X    fillmroom(rund(3),OBOOK,j);             
X    fillmroom(rund(3),OALTAR,0);
X    fillmroom(rund(3),OSTATUE,0);           
X    fillmroom(rund(3),OPIT,0);
X    fillmroom(rund(3),OFOUNTAIN,0);         
X    fillmroom( rnd(3)-2,OIVTELETRAP,0);
X    fillmroom(rund(2),OTHRONE,0);           
X    fillmroom(rund(2),OMIRROR,0);
X    fillmroom(rund(2),OTRAPARROWIV,0);      
X    fillmroom( rnd(3)-2,OIVDARTRAP,0);
X    fillmroom(rund(3),OCOOKIE,0);
X    if (j==1) 
X        fillmroom(1,OCHEST,j);
X    else 
X        fillmroom(rund(2),OCHEST,j);
X    if ((j != MAXLEVEL-1) && (j != MAXLEVEL+MAXVLEVEL-1))
X        fillmroom(rund(2),OIVTRAPDOOR,0);
X    if (j<=10)
X        {
X        fillmroom((rund(2)),ODIAMOND,rnd(10*j+1)+10);
X        fillmroom(rund(2),ORUBY,rnd(6*j+1)+6);
X        fillmroom(rund(2),OEMERALD,rnd(4*j+1)+4);
X        fillmroom(rund(2),OSAPPHIRE,rnd(3*j+1)+2);
X        }
X    for (i=0; i<rnd(4)+3; i++)
X        fillroom(OPOTION,newpotion());  /*  make a POTION   */
X    for (i=0; i<rnd(5)+3; i++)
X        fillroom(OSCROLL,newscroll());  /*  make a SCROLL   */
X    for (i=0; i<rnd(12)+11; i++)
X        fillroom(OGOLDPILE,12*rnd(j+1)+(j<<3)+10); /* make GOLD */
X    if (j==5)   
X        fillroom(OBANK2,0);         /* branch office of the bank */
X    froom(2,ORING,0);               /* a ring mail          */
X    froom(1,OSTUDLEATHER,0);        /* a studded leather    */
X    froom(3,OSPLINT,0);             /* a splint mail        */
X    froom(5,OSHIELD,rund(3));       /* a shield             */
X    froom(2,OBATTLEAXE,rund(3));    /* a battle axe         */
X    froom(5,OLONGSWORD,rund(3));    /* a long sword         */
X    froom(5,OFLAIL,rund(3));        /* a flail              */
X    froom(4,OREGENRING,rund(3));    /* ring of regeneration */
X    froom(1,OPROTRING,rund(3));     /* ring of protection   */
X    froom(2,OSTRRING,1+rnd(3));     /* ring of strength     */
X    froom(7,OSPEAR,rnd(5));         /* a spear              */
X    froom(3,OORBOFDRAGON,0);        /* orb of dragon slaying*/
X    froom(4,OSPIRITSCARAB,0);       /* scarab of negate spirit*/
X    froom(4,OCUBEofUNDEAD,0);       /* cube of undead control   */
X    froom(2,ORINGOFEXTRA,0);        /* ring of extra regen      */
X    froom(3,ONOTHEFT,0);            /* device of antitheft      */
X    froom(2,OSWORDofSLASHING,0);    /* sword of slashing */
X    if (c[BESSMANN]==0)
X        {
X        froom(4,OHAMMER,0);/*Bessman's flailing hammer*/
X        c[BESSMANN]=1;
X        }
X    if (c[HARDGAME]<3 || (rnd(4)==3))
X        {
X        if (j>3)
X            {
X            froom(3,OSWORD,3);        /* sunsword + 3         */
X            froom(5,O2SWORD,rnd(4));  /* a two handed sword */
X            froom(3,OBELT,4);         /* belt of striking     */
X            froom(3,OENERGYRING,3);   /* energy ring          */
X            froom(4,OPLATE,5);        /* platemail + 5        */
X            froom(3,OCLEVERRING,1+rnd(2));  /* ring of cleverness */
X            }
X        }
X    }
X
X/*
X    subroutine to fill in a number of objects of the same kind
X */
X
Xstatic fillmroom(n,what,arg)
X    int n,arg;
X    char what;
X    {
X    register int i;
X    for (i=0; i<n; i++)     fillroom(what,arg);
X    }
Xstatic froom(n,itm,arg)
X    int n,arg;
X    char itm;
X    {   if (rnd(151) < n) fillroom(itm,arg);    }
X
X/*
X    subroutine to put an object into an empty room
X *  uses a random walk
X */
Xstatic fillroom(what,arg)
X    int arg;
X    char what;
X    {
X    register int x,y;
X
X#ifdef EXTRA
X    c[FILLROOM]++;
X#endif
X
X    x=rnd(MAXX-2);  y=rnd(MAXY-2);
X    while (item[x][y])
X        {
X
X#ifdef EXTRA
X        c[RANDOMWALK]++;    /* count up these random walks */
X#endif
X
X        x += rnd(3)-2;      y += rnd(3)-2;
X        if (x > MAXX-2)  x=1;       if (x < 1)  x=MAXX-2;
X        if (y > MAXY-2)  y=1;       if (y < 1)  y=MAXY-2;
X        }
X    item[x][y]=what;        iarg[x][y]=arg;
X    }
X
X/*
X    subroutine to put monsters into an empty room without walls or other
X    monsters
X */
Xfillmonst(what)
X    char what;
X    {
X    register int x,y,trys;
X    for (trys=5; trys>0; --trys) /* max # of creation attempts */
X      {
X      x=rnd(MAXX-2);  y=rnd(MAXY-2);
X      if ((item[x][y]==0) && (mitem[x][y]==0) && ((playerx!=x) || (playery!=y)))
X        {
X        mitem[x][y] = what;  know[x][y] &= ~KNOWHERE;
X        hitp[x][y] = monster[what].hitpoints;  return(0);
X        }
X      }
X    return(-1); /* creation failure */
X    }
X
X/*
X    creates an entire set of monsters for a level
X    must be done when entering a new level
X    if sethp(1) then wipe out old monsters else leave them there
X */
Xstatic sethp(flg)
X    int flg;
X    {
X    register int i,j;
X    if (flg) for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) stealth[j][i]=0;
X    if (level==0) { c[TELEFLAG]=0; return; } /* if teleported and found level 1 then know level we are on */
X    if (flg)   j = rnd(12) + 2 + (level>>1);   else   j = (level>>1) + 1;
X    for (i=0; i<j; i++)  fillmonst(makemonst(level));
X    }
X
X/*
X *  Function to destroy all genocided monsters on the present level
X */
Xstatic checkgen()
X    {
X    register int x,y;
X    for (y=0; y<MAXY; y++)
X        for (x=0; x<MAXX; x++)
X            if (monster[mitem[x][y]].genocided)
X                mitem[x][y]=0; /* no more monster */
X    }
END_OF_FILE
if test 15884 -ne `wc -c <'create.c'`; then
    echo shar: \"'create.c'\" unpacked with wrong size!
fi
# end of 'create.c'
fi
if test -f 'diag.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'diag.c'\"
else
echo shar: Extracting \"'diag.c'\" \(14227 characters\)
sed "s/^X//" >'diag.c' <<'END_OF_FILE'
X/* diag.c */
X#ifdef VMS
X# include <types.h>
X# include <stat.h>
X#else
X# include <sys/types.h>
X# include <sys/stat.h>
X#endif VMS
X
X#ifndef AMIGA
X# ifndef MSDOS
X#  ifndef VMS
X#   include <sys/times.h>
X  static struct tms cputime;
X#  endif VMS
X# endif MSDOS
X#endif AMIGA
X
X#include "header.h"
X#include "larndefs.h"
X#include "monsters.h"
X#include "objects.h"
X#include "player.h"
X
Xextern long int initialtime;
Xextern int rmst,maxitm,lasttime;
Xextern char nosignal;
X
X/*
X    ***************************
X    DIAG -- dungeon diagnostics
X    ***************************
X
X    subroutine to print out data for debugging
X */
X#ifdef EXTRA
Xstatic int rndcount[16];
Xdiag()
X    {
X    register int i,j;
X    int hit,dam;
X    cursors();  lwclose();
X    if (lcreat(diagfile) < 0)   /*  open the diagnostic file    */
X        {
X        lcreat((char*)0); lprcat("\ndiagnostic failure\n"); return(-1);
X        }
X
X    write(1,"\nDiagnosing . . .\n",18);
X    lprcat("\n\nBeginning of DIAG diagnostics ----------\n");
X
X/*  for the character attributes    */
X
X    lprintf("\n\nPlayer attributes:\n\nHit points: %2d(%2d)",(long)c[HP],(long)c[HPMAX]);
X    lprintf("\ngold: %d  Experience: %d  Character level: %d  Level in caverns: %d",
X        (long)c[GOLD],(long)c[EXPERIENCE],(long)c[LEVEL],(long)level);
X    lprintf("\nTotal types of monsters: %d",(long)MAXMONST+8);
X
X    lprcat("\f\nHere's the dungeon:\n\n");
X
X    i=level;
X    for (j=0; j<MAXLEVEL+MAXVLEVEL; j++)
X        {
X        newcavelevel(j);
X        lprintf("\nMaze for level %s:\n",levelname[level]);
X        diagdrawscreen();
X        }
X    newcavelevel(i);
X
X    lprcat("\f\nNow for the monster data:\n\n");
X    lprcat("   Monster Name      LEV  AC   DAM  ATT  DEF    GOLD   HP     EXP   \n");
X    lprcat("--------------------------------------------------------------------------\n");
X    for (i=0; i<=MAXMONST+8; i++)
X        {
X        lprintf("%19s  %2d  %3d ",monster[i].name,(long)monster[i].level,(long)monster[i].armorclass);
X        lprintf(" %3d  %3d  %3d  ",(long)monster[i].damage,(long)monster[i].attack,(long)monster[i].defense);
X        lprintf("%6d  %3d   %6d\n",(long)monster[i].gold,(long)monster[i].hitpoints,(long)monster[i].experience);
X        }
X
X    lprcat("\n\nHere's a Table for the to hit percentages\n");
X    lprcat("\n     We will be assuming that players level = 2 * monster level");
X    lprcat("\n     and that the players dexterity and strength are 16.");
X    lprcat("\n    to hit: if (rnd(22) < (2[monst AC] + your level + dex + WC/8 -1)/2) then hit");
X    lprcat("\n    damage = rund(8) + WC/2 + STR - c[HARDGAME] - 4");
X    lprcat("\n    to hit:  if rnd(22) < to hit  then player hits\n");
X    lprcat("\n    Each entry is as follows:  to hit / damage / number hits to kill\n");
X    lprcat("\n          monster     WC = 4         WC = 20        WC = 40");
X    lprcat("\n---------------------------------------------------------------");
X    for (i=0; i<=MAXMONST+8; i++)
X        {
X        hit = 2*monster[i].armorclass+2*monster[i].level+16;
X        dam = 16 - c[HARDGAME];
X        lprintf("\n%20s   %2d/%2d/%2d       %2d/%2d/%2d       %2d/%2d/%2d",
X                    monster[i].name,
X                    (long)(hit/2),(long)max(0,dam+2),(long)(monster[i].hitpoints/(dam+2)+1),
X                    (long)((hit+2)/2),(long)max(0,dam+10),(long)(monster[i].hitpoints/(dam+10)+1),
X                    (long)((hit+5)/2),(long)max(0,dam+20),(long)(monster[i].hitpoints/(dam+20)+1));
X        }
X
X    lprcat("\n\nHere's the list of available potions:\n\n");
X    for (i=0; i<MAXPOTION; i++) lprintf("%20s\n",&potionname[i][1]);
X    lprcat("\n\nHere's the list of available scrolls:\n\n");
X    for (i=0; i<MAXSCROLL; i++) lprintf("%20s\n",&scrollname[i][1]);
X    lprcat("\n\nHere's the spell list:\n\n");
X    lprcat("spell          name           description\n");
X    lprcat("-------------------------------------------------------------------------------------------\n\n");
X    for (j=0; j<SPNUM; j++)
X        {
X        lprc(' ');  lprcat(spelcode[j]);
X        lprintf(" %21s  %s\n",spelname[j],speldescript[j]); 
X        }
X
X    lprcat("\n\nFor the c[] array:\n");
X    for (j=0; j<100; j+=10)
X        {
X        lprintf("\nc[%2d] = ",(long)j); for (i=0; i<9; i++) lprintf("%5d ",(long)c[i+j]);
X        }
X
X    lprcat("\n\nTest of random number generator ----------------");
X    lprcat("\n    for 25,000 calls divided into 16 slots\n\n");
X
X    for (i=0; i<16; i++)  rndcount[i]=0;
X    for (i=0; i<25000; i++) rndcount[rund(16)]++;
X    for (i=0; i<16; i++)  { lprintf("  %5d",(long)rndcount[i]); if (i==7) lprc('\n'); }
X
X    lprcat("\n\n");         lwclose();
X    lcreat((char*)0);       lprcat("Done Diagnosing . . .");
X    return(0);
X    }
X/*
X    subroutine to count the number of occurrences of an object
X */
Xdcount(l)
X    int l;
X    {
X    register int i,j,p;
X    int k;
X    k=0;
X    for (i=0; i<MAXX; i++)
X        for (j=0; j<MAXY; j++)
X            for (p=0; p<MAXLEVEL; p++)
X                if (cell[(long) p*MAXX*MAXY+i*MAXY+j].item == l) k++;
X    return(k);
X    }
X
X/*
X    subroutine to draw the whole screen as the player knows it
X */
Xdiagdrawscreen()
X    {
X    register int i,j,k;
X
X    for (i=0; i<MAXY; i++)
X
X/*  for the east west walls of this line    */
X        {
X        for (j=0; j<MAXX; j++)  if (k=mitem[j][i]) lprc(monstnamelist[k]); else
X                                lprc(objnamelist[item[j][i]]);
X        lprc('\n');
X        }
X    }
X#endif
X
X/*
X    to save the game in a file
X */
Xstatic long int zzz=0;
Xsavegame(fname)
X    char *fname;
X    {
X    extern char lastmonst[], course[];
X    register int i,k;
X    register struct sphere *sp;
X    struct stat statbuf;
X# ifdef MSDOS
X    struct  cel buf[MAXX];
X    RAMBLOCK    *rp;
X    DISKBLOCK   *dp;
X# endif
X
X    nosignal=1;  lflush();  savelevel();
X    ointerest();
X    if (lcreat(fname) < 0)
X        {
X        lcreat((char*)0); lprintf("\nCan't open file <%s> to save game\n",fname);
X        nosignal=0;  return(-1);
X        }
X
X    set_score_output();
X
X# ifdef MSDOS
X    lwrite((char*)beenhere,MAXLEVEL+MAXVLEVEL);
X
X    /* Some levels may be out on disk, some are in memory.
X     */
X    for (k = 0; k < MAXLEVEL + MAXVLEVEL; k++)
X        if (beenhere[k]) {
X
X            /* Is the level in memory already ?
X             */
X            for (rp = ramblks; rp; rp = rp->next)
X                if (rp->level == k)
X                    break;
X            if (rp != NULL) {
X                lwrite((char *) &rp->gtime, sizeof (long));
X                warn(" %d", k);
X# ifdef ndef
X                warn("From memory\n", k);
X# endif
X                lwrite((char *) rp->cell, sizeof rp->cell);
X                continue;
X            }
X
X            /* Is it on disk ?
X             */
X            for (dp = diskblks; dp; dp = dp->next)
X                if (dp->level == k)
X                    break;
X
X            if (dp == NULL) {
X                levelinfo();
X                error("Level %d is neither in memory nor on disk\n", k);
X            }
X
X            /* Copy the contents of the SWAPFILE */
X            lwrite((char *) &dp->gtime, sizeof (long));
X# ifdef ndef
X            warn("From swap file...\n", k);
X# endif
X            warn(" %ds", k);
X            if (lseek(swapfd, dp->fpos, 0) < 0) {
X                warn("Can't seek to %ld\n", dp->fpos);
X                return -1;
X            }
X            for (i = 0; i < MAXY; i++) {
X# ifdef ndef
X                warn("Copying swap file...\n");
X# endif
X                if (vread(swapfd, (char *) buf, sizeof buf) !=
X                    sizeof buf) {
X                    warn("Swap file short!\n");
X                    return -1;
X                }
X                lwrite((char *) buf, sizeof buf);
X            }
X        }
X# else
X    lwrite((char*)beenhere,MAXLEVEL+MAXVLEVEL);
X    for (k=0; k<MAXLEVEL+MAXVLEVEL; k++)
X        if (beenhere[k])
X            lwrite((char*)&cell[(long) k*MAXX*MAXY],sizeof(struct cel)*MAXY*MAXX);
X# endif
X
X#ifndef AMIGA
X# ifndef VMS
X#  ifndef MSDOS
X    times(&cputime);    /* get cpu time */
X    c[CPUTIME] += (cputime.tms_utime+cputime.tms_stime)/60;
X#  endif MSDOS
X# endif VMS
X#endif AMIGA
X
X    lwrite((char*)&c[0],100*sizeof(long));
X    lprint((long)gtime);        lprc(level);
X    lprc(playerx);      lprc(playery);
X    lwrite((char*)iven,26); lwrite((char*)ivenarg,26*sizeof(short));
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);       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);           lprc(cheat);        lprc(VERSION);
X    for (i=0; i<MAXMONST; i++) lprc(monster[i].genocided); /* genocide info */
X    for (sp=spheres; sp; sp=sp->p)
X        lwrite((char*)sp,sizeof(struct sphere));    /* save spheres of annihilation */
X    time(&zzz);         lprint((long)(zzz-initialtime));
X    lwrite((char*)&zzz,sizeof(long));
X# ifndef MSDOS
X#ifdef AMIGA
X    if(stat(fname, &statbuf) < 0)
X#else
X    if(fstat(lfd,&statbuf) < 0)
X#endif /* AMIGA */
X      lprint(0L);
X    else lprint((long)statbuf.st_ino); /* inode # */
X# endif
X
X    lwclose();  lastmonst[0] = 0;
X#ifndef VT100
X    setscroll();
X#endif VT100
X    lcreat((char*)0);  nosignal=0;
X    return(0);
X    }
X
Xrestoregame(fname)
X    char *fname;
X    {
X    register int i,k;
X    register struct sphere *sp,*sp2;
X    struct stat filetimes;
X# ifdef MSDOS
X    RAMBLOCK    *rp, *getramblk();
X# endif
X
X    cursors(); lprcat("\nRestoring . . .");  lflush();
X    if (lopen(fname) <= 0)
X        {
X        lcreat((char*)0); lprintf("\nCan't open file <%s>to restore game\n",fname);
X        nap(2000); c[GOLD]=c[BANKACCOUNT]=0;  died(-265); return;
X        }
X    lrfill((char*)beenhere,MAXLEVEL+MAXVLEVEL);
X
X# ifdef MSDOS
X    /* As levels get read in from the save file, store them away
X     * by calling putsavelevel.
X     */
X    for (k = 0; k < MAXLEVEL + MAXVLEVEL; k++)
X        if (beenhere[k]) {
X            rp = getramblk(k);
X            lrfill((char *) &rp->gtime, sizeof (long));
X            lrfill((char *) rp->cell, sizeof rp->cell);
X            rp->level = k;
X        }
X# else
X    for (k=0; k<MAXLEVEL+MAXVLEVEL; k++)
X        if (beenhere[k])
X            lrfill((char*)&cell[(long) k*MAXX*MAXY],sizeof(struct cel)*MAXY*MAXX);
X# endif
X
X    lrfill((char*)&c[0],100*sizeof(long));  gtime = lrint();
X    level = c[CAVELEVEL] = lgetc();
X    playerx = lgetc();      playery = lgetc();
X    lrfill((char*)iven,26);     lrfill((char*)ivenarg,26*sizeof(short));
X    for (k=0; k<MAXSCROLL; k++)  scrollname[k][0] = lgetc();
X    for (k=0; k<MAXPOTION; k++)  potionname[k][0] = lgetc();
X    lrfill((char*)spelknow,SPNUM);      wizard = lgetc();
X    rmst = lgetc();         /*  random monster creation flag */
X
X    for (i=0; i<90; i++)    itm[i].qty = lgetc();
X    lrfill((char*)course,25);           cheat = lgetc();
X    if (VERSION != lgetc())     /*  version number  */
X        {
X        cheat=1;
X        lprcat("Sorry, But your save file is for an older version of larn\n");
X        nap(2000); c[GOLD]=c[BANKACCOUNT]=0;  died(-266); return;
X        }
X
X    for (i=0; i<MAXMONST; i++) monster[i].genocided=lgetc(); /* genocide info */
X    for (sp=0,i=0; i<c[SPHCAST]; i++)
X        {
X        sp2 = sp;
X        sp = (struct sphere *)malloc(sizeof(struct sphere));
X        if (sp==0) { write(2,"Can't malloc() for sphere space\n",32); break; }
X        lrfill((char*)sp,sizeof(struct sphere));    /* get spheres of annihilation */
X        sp->p=0;    /* null out pointer */
X        if (i==0) spheres=sp;   /* beginning of list */
X            else sp2->p = sp;
X        }
X
X    time(&zzz);
X    initialtime = zzz-lrint();
X#ifdef AMIGA
X    stat(fname, &filetimes);
X#else
X    fstat(fd,&filetimes);   /*  get the creation and modification time of file  */
X#endif /* AMIGA */
X    lrfill((char*)&zzz,sizeof(long));   zzz += 6;
X    if (filetimes.st_ctime > zzz) fsorry(); /*  file create time    */
X    else if (filetimes.st_mtime > zzz) fsorry(); /* file modify time    */
X    if (c[HP]<0) { died(284); return; } /* died a post mortem death */
X
X    oldx = oldy = 0;
X#ifndef VMS
X# ifndef MSDOS
X    i = lrint();  /* inode # */
X    if (i && (filetimes.st_ino!=i)) fsorry();
X# endif MSDOS
X#endif VMS
X    lrclose();
X    if (strcmp(fname,ckpfile) == 0)
X        {
X        if (lappend(fname) < 0) fcheat();  else { lprc(' '); lwclose(); }
X        lcreat((char*)0);
X        }
X    else if (unlink(fname) < 0) fcheat(); /* can't unlink save file */
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]) /* if patch up lev 25 player */
X        {
X        long tmp;
X        tmp = c[EXPERIENCE]-skill[24]; /* amount to go up */
X        c[EXPERIENCE] = skill[24];
X        raiseexperience((long)tmp);
X        }
X    getlevel();  lasttime=gtime;
X    }
X
X/*
X    subroutine to not allow greedy cheaters
X */
Xstatic greedy()
X    {
X#if WIZID
X    if (wizard) return;
X#endif
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"); nap(5000);  c[GOLD]=c[BANKACCOUNT]=0;  died(-267); return;
X    }
X
X/*
X    subroutine to not allow altered save files and terminate the attempted
X    restart
X */
Xstatic fsorry()
X    {
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 normal scoreboard.");
X    cheat = 1;  nap(4000);
X    }
X
X/*
X    subroutine to not allow game if save file can't be deleted
X */
Xstatic fcheat()
X    {
X#if WIZID
X    if (wizard) return;
X#endif
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 larn community, I\n");
X    lprcat("cannot let you play this game.\n");
X    nap(5000);  c[GOLD]=c[BANKACCOUNT]=0;  died(-268); return;
X    }
END_OF_FILE
if test 14227 -ne `wc -c <'diag.c'`; then
    echo shar: \"'diag.c'\" unpacked with wrong size!
fi
# end of 'diag.c'
fi
if test -f 'tok.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tok.c'\"
else
echo shar: Extracting \"'tok.c'\" \(13574 characters\)
sed "s/^X//" >'tok.c' <<'END_OF_FILE'
X/* tok.c */
X/*
X   yylex()
X   flushall()
X   sethard()
X   readopts()
X   actual_readopts()
X*/
X#ifdef VMS
X#include <types.h>
X#include <file.h>
X#include <iodef.h>
X#else VMS
X#include <sys/types.h>
X#ifdef SYSV
X#include <fcntl.h>
X# ifndef MSDOS
X#   include <termio.h>
X# endif
X#else SYSV
X# ifndef AMIGA
X#  ifndef MSDOS
X#   include <sys/ioctl.h>
X#  endif MSDOS
X# endif AMIGA
X#endif SYSV
X#endif VMS
X
X#include <ctype.h>
X#include "header.h"
X#include "larndefs.h"
X#include "monsters.h"
X#include "objects.h"
X#include "player.h"
X
X#ifdef __STDC__
Xstatic void actual_readopts( char*, char* );
X#else
Xstatic void actual_readopts();
X#endif
X
X# define CHKPTINT   400
X
Xstatic char lastok=0;
Xint yrepcount=0;
Xchar move_no_pickup = FALSE ;
X
X#ifdef TIMECHECK
Xint dayplay=0;
X#endif TIMECHECK
X
X#ifndef FLUSHNO
X#define FLUSHNO 5
X#endif FLUSHNO
Xstatic int flushno=FLUSHNO; /* input queue flushing threshold */
X#define MAXUM 52    /* maximum number of user re-named monsters */
X#define MAXMNAME 40 /* max length of a monster re-name */
Xstatic char usermonster[MAXUM][MAXMNAME]; /* the user named monster name goes here */
Xstatic char usermpoint=0;           /* the user monster pointer */
X#ifdef MSDOS
X extern int rawio;
X#endif
X
X/*
X    lexical analyzer for larn
X */
Xyylex()
X    {
X    char cc;
X    int ic;
X    char firsttime = TRUE;
X
X    if (hit2flag)
X        {
X        hit2flag=0;
X        yrepcount=0;
X        return(' ');
X        }
X    if (yrepcount>0)
X        {
X        --yrepcount;
X        return(lastok);
X        }
X    else
X        yrepcount=0;
X    if (yrepcount==0) 
X        { 
X        bottomdo(); 
X        showplayer();               /* show where the player is */
X        move_no_pickup = FALSE;     /* clear 'm' flag */
X        }
X
X    lflush();
X    while (1)
X        {
X        c[BYTESIN]++;
X        if (ckpflag)
X          if ((c[BYTESIN] % CHKPTINT) == 0) /* check for periodic checkpointing */
X            {
X#ifndef DOCHECKPOINTS
X#ifdef MSDOS|AMIGA
X            cursors();
X            lprcat("\nCheckpointing . . .");
X            savegame(ckpfile);
X            lprcat("\nDone\n");
X            showplayer();
X            lflush();
X            lflushall(); /* Kill any stored key strokes */
X#else
X#ifdef VMS
X            savegame(ckpfile);
X#else
X            wait(0);    /* wait for other forks to finish */
X            if (fork() == 0) { savegame(ckpfile); exit(); }
X#endif
X#endif
X#else
X#ifdef VMS
X            savegame(ckpfile);
X#else
X            wait(0);    /* wait for other forks to finish */
X            if (fork() == 0) { savegame(ckpfile); exit(); }
X#endif
X#endif
X
X#ifdef TIMECHECK
X            if (dayplay==0)
X              if (playable())
X                {
X                cursor(1,19);
X                lprcat("\nSorry, but it is now time for work.  Your game has been saved.\n"); beep();
X                lflush();
X                savegame(savefilename);
X                wizard=nomove=1;
X                sleep(4);
X                died(-257);
X                }
X#endif TIMECHECK
X
X            }
X# ifdef AMIGA
X	FlushKBD();
X# else
X# ifndef MSDOS
X# ifdef VMS
X        /* If keyboard input buffer is too big then flush some? RDE */
X        /* Check this! but for now just ignore it... */
X# else
X#  ifndef SYSV
X        do /* if keyboard input buffer is too big, flush some of it */
X            {
X            ioctl(0,FIONREAD,&ic);
X            if (ic>flushno)   read(0,&cc,1);
X            }
X        while (ic>flushno);
X#  endif SYSV
X# endif VMS
X# endif MSDOS
X# endif AMIGA
X
X# ifdef AMIGA
X	cc = AmGetch();
X# else
X# ifdef MSDOS
X        cc = ttgetch();
X# else MSDOS
X# ifdef VMS
X        cc = ttgetch();
X# else
X        if (read(0,&cc,1) != 1)
X            return(lastok = -1);
X# endif VMS
X# endif MSDOS
X# endif AMIGA
X        if (cc == '!')      /* ! shell escape */
X            {
X            resetscroll();  /* scrolling region, home, clear, no attributes */
X            clear();
X# ifdef AMIGA
X	    DoShell();
X# else
X# ifdef MSDOS
X            doshell();
X# else MSDOS
X# ifdef VMS
X            lflush();
X            sncbr();
X            oneliner("");
X            scbr();
X# else VMS
X            lflush();
X            sncbr();
X            if ((ic=fork())==0) /* child */
X                {
X#ifdef SYSV
X                char *s, *getenv();
X                if ((s=getenv("SHELL")) == (char *) 0)
X                    s = "/bin/sh";
X                execl(s,"larn-shell", (char *)0);
X                exit();
X#else
X                execl("/bin/csh",0);
X                exit();
X                wait(0);
X#endif
X                }
X            if (ic<0) /* error */
X                {
X                write(2,"Can't fork off a shell!\n",25);
X                sleep(2);
X                }
X#ifdef SYSV
X            else
X                wait( (int *)0 );
X#endif SYSV
X# endif VMS
X# endif MSDOS
X# endif AMIGA
X            setscroll();
X            return(lastok = 'L'-64);    /* redisplay screen */
X            }
X
X        /* get repeat count, showing to player
X        */
X        if ((cc <= '9') && (cc >= '0'))
X            {
X            yrepcount = yrepcount*10 + cc - '0';
X
X            /* show count to player for feedback
X            */
X            if ( yrepcount >= 10 )
X                {
X                cursors();
X                if (firsttime)
X                    lprcat("\n");
X                lprintf("count: %d", (long)yrepcount );
X                firsttime=FALSE;
X                lflush();  /* show count */
X                }
X            }
X        else
X            {
X            /* check for multi-character commands in command mode, and handle.
X            */
X            if ( cc == 'm' && !prompt_mode )
X                {
X                move_no_pickup = TRUE ;
X                cc = ttgetch();
X                }
X            if ( yrepcount > 0 )
X                --yrepcount;
X            return(lastok = cc);
X            }
X        }
X    }
X
X/*
X *  flushall()  Function to flush all type-ahead in the input buffer
X */
Xlflushall()
X    {
X# ifdef AMIGA
X      FlushKBD();
X# else AMIGA
X# ifdef MSDOS
X    while (kbhit())
X        getch();
X# else MSDOS
X# ifdef VMS
X    /* Flush all type-ahead -- RDE */
X    extern int  iochan;     /* defined in IO.C  */
X    int     c;
X
X    SYS$QIOW(0,iochan,IO$_READLBLK|IO$M_TIMED|IO$M_PURGE,0,0,0,&c,1,0,0,0,0);
X
X# else VMS
X#ifdef SYSV
X    ioctl(0,TCFLSH,0);
X#else
X    char cc;
X    int ic;
X    for (;;) {      /* if keyboard input buffer is too big, flush some of it */
X        ioctl(0,FIONREAD,&ic);
X        if (ic<=0)
X            return;
X        while (ic>0) {
X            read(0,&cc,1);
X            --ic;
X        } /* gobble up the byte */
X    }
X# endif SYSV
X# endif VMS
X# endif MSDOS
X# endif AMIGA
X}
X
X/*
X    function to set the desired hardness
X    enter with hard= -1 for default hardness, else any desired hardness
X */
Xsethard(hard)
Xint hard;
X{
X    register int    j,k;
X    long        i;
X    struct monst    *mp;
X
X    j=c[HARDGAME]; hashewon();
X    if (restorflag==0)  /* don't set c[HARDGAME] if restoring game */
X        {
X        if (hard >= 0) c[HARDGAME]= hard;
X        }
X    else c[HARDGAME]=j; /* set c[HARDGAME] to proper value if restoring game */
X
X    if (k=c[HARDGAME])
X      for (j=0; j<=MAXMONST+8; j++) {
X        mp = &monster[j];
X        i = ((6+k) * mp->hitpoints + 1)/6;
X        mp->hitpoints = (i<0) ? 32767 : i;
X        i = ((6+k) * mp->damage + 1) / 5;
X        mp->damage = (i>127) ? 127 : i;
X        i = (10 * mp->gold)/(10+k);
X        mp->gold = (i>32767) ? 32767 : i;
X        i = mp->armorclass - k;
X        mp->armorclass = (i< -127) ? -127 : i;
X        i = (7*mp->experience)/(7+k) + 1;
X        mp->experience = (i<=0) ? 1 : i;
X    }
X}
X
X
X/*
X    function to read and process the larn options file
X*/
Xreadopts()
X    {
X    register int j;
X    char original_objects = FALSE ;
X    char namenotchanged = TRUE;     /* set to 0 if a name is specified */
X
X# ifdef MSDOS
X    if (plopen(optsfile) < 0)
X# else
X    if (lopen(optsfile) < 0)
X# endif
X        {
X        lprintf("Can't open options file \"%s\"\n", optsfile);
X        lflush();
X        sleep(1);
X        }
X    else
X        actual_readopts(&namenotchanged, &original_objects);
X
X    if (namenotchanged)
X        strcpy(logname,loginname);
X
X    /* original objects require object highlighting to be ON (in order
X       to distinguish between objects and monsters).  set up object list
X       properly.
X    */
X    if (original_objects)
X        {
X        boldobjects = TRUE ;
X        strncpy( objnamelist, original_objnamelist, MAXOBJECT );
X        }
X    else
X        strncpy( objnamelist, hacklike_objnamelist, MAXOBJECT );
X    objnamelist[MAXOBJECT] = '\0' ;
X
X    /* now set all the invisible objects and monsters to have the
X       same appearance as the floor (as defined by the user)
X    */
X    objnamelist[OWALL] = wallc;
X
X    objnamelist[0]        =
X    objnamelist[OIVTELETRAP]  =
X    objnamelist[OTRAPARROWIV] =
X    objnamelist[OIVDARTRAP]   =
X    objnamelist[OIVTRAPDOOR]  = floorc;
X    monstnamelist[0] =
X    monstnamelist[INVISIBLESTALKER] = floorc;
X    for (j=DEMONLORD; j<=DEMONPRINCE; j++)
X        monstnamelist[j] = floorc;
X    }
X
Xstatic void actual_readopts( namenotchanged, original_objects )
Xchar *namenotchanged;
Xchar *original_objects;
X    {
X    register char *i;
X    register int j,k;
X
X    i = " ";
X    while (*i)
X        {
X        /* check for EOF
X        */
X        if ((i=(char *)lgetw()) == 0)
X            return;
X#if 0
X        while (*i && ((*i==' ') || (*i=='\t'))) i++; /* eat leading whitespace */
X#endif
X        /* leading # a comment, eat the rest of the line.  Handle multiple
X           comment lines in a row.
X        */
X        while (*i == '#')
X            {
X            char cc;
X            do
X                cc = (char)lgetc();
X            while ( ( cc != '\n' ) && ( cc != NULL));
X            if ((i = (char *)lgetw()) == 0)
X                return;
X            }
X
X        if (strcmp(i,"bold-objects") == 0)
X            boldon=1;
X        else if (strcmp(i,"enable-checkpointing") == 0)
X            ckpflag=1;
X        else if (strcmp(i,"inverse-objects") == 0)
X            boldon=0;
X        else if (strcmp(i,"prompt-on-objects") == 0 )
X            prompt_mode = TRUE ;
X        else if (strcmp(i,"auto-pickup") == 0 )
X            auto_pickup = TRUE ;
X        else if (strcmp(i,"highlight-objects") == 0 )
X            boldobjects = TRUE ;
X        else if (strcmp(i,"original-objects") == 0 )
X            *original_objects = TRUE ;
X        else if (strcmp(i,"female") == 0)
X            sex=0; /* male or female */
X# ifdef MSDOS
X        else if (strcmp(i, "graphics:") == 0)
X            {
X            wallc = atoi(lgetw());
X            floorc = atoi(lgetw());
X            }
X        else if (strcmp(i, "larndir:") == 0)
X            {
X            if ((i=lgetw())==0)
X                break;
X            strncpy(larndir, i, DIRLEN);
X            larndir[DIRLEN - 1] = 0;
X            }
X        else if (strcmp(i, "rawio") == 0)
X            rawio = 1;
X        else if (strcmp(i, "swapfile:") == 0)
X            {
X            if ((i = (char *)lgetw()) == 0)
X                break;
X            strncpy(swapfile, i, PATHLEN);
X            swapfile[PATHLEN - 1] = 0;
X            }
X        else if (strcmp(i, "ramlevels:") == 0)
X            ramlevels = atoi(lgetw());
X        else if (strcmp(i, "cursor:") == 0)
X            {
X            cursorset = 1;
X            cursorstart = (unsigned char) atoi(lgetw());
X            cursorend = (unsigned char) atoi(lgetw());
X            }
X        else if (strcmp(i, "keypad") == 0)
X            keypad = 1;
X        else if (strcmp(i, "DECRainbow") == 0)
X            DECRainbow = 1;
X# endif
X        else if (strcmp(i,"monster:")== 0)   /* name favorite monster */
X            {
X            if ((i=(char *)lgetw())==0)
X                break;
X            if (strlen(i)>=MAXMNAME)
X                i[MAXMNAME-1]=0;
X            strcpy(usermonster[usermpoint],i);
X            if (usermpoint >= MAXUM)
X                break; /* defined all of em */
X            if (isalpha(j=usermonster[usermpoint][0]))
X                {
X                for (k=1; k<MAXMONST+8; k++) /* find monster */
X                  if (monstnamelist[k] == j)
X                    {
X                    monster[k].name = &usermonster[usermpoint++][0];
X                    break;
X                    }
X                }
X            }
X        else if (strcmp(i,"male") == 0)
X            sex=1;
X        else if (strcmp(i,"name:") == 0) /* defining players name */
X            {
X            if ((i=lgetw())==0)
X                break;
X            if (strlen(i)>=LOGNAMESIZE)
X                i[LOGNAMESIZE-1]=0;
X            strcpy(logname,i);
X            *namenotchanged = FALSE;
X# ifdef MSDOS
X            strcpy(loginname,i);
X# endif
X            }
X        else if (strcmp(i,"no-introduction") == 0)
X            nowelcome=1;
X        else if (strcmp(i,"no-beep") == 0)
X            nobeep=1;
X# ifndef MSDOS
X        else if (strcmp(i,"process-name:")== 0)
X            {
X            if ((i=lgetw())==0)
X                break;
X            if (strlen(i)>=PSNAMESIZE)
X                i[PSNAMESIZE-1]=0;
X            strcpy(psname,i);
X            }
X        else if (strcmp(i,"play-day-play") == 0)
X# ifdef TIMECHECK
X            dayplay=1;
X# else
X        ;
X# endif
X# endif
X        else if (strcmp(i,"savefile:") == 0) /* defining savefilename */
X            {
X            if ((i=lgetw())==0)
X                break;
X            if (strlen(i)>=SAVEFILENAMESIZE) /* avoid overflow */
X                i[SAVEFILENAMESIZE-1]=0;
X            strcpy(savefilename,i);
X            }
X        else
X            {
X            lprintf("Unknown option \"%s\"\n", i);
X            lflush();
X            sleep(1);
X            }
X        }
X    }
END_OF_FILE
if test 13574 -ne `wc -c <'tok.c'`; then
    echo shar: \"'tok.c'\" unpacked with wrong size!
fi
# end of 'tok.c'
fi
echo shar: End of archive 6 \(of 17\).
cp /dev/null ark6isdone
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.
