-+-+-+-+-+-+-+-+ START OF PART 38 -+-+-+-+-+-+-+-+ X ch = *monster`5Bx`5D.name; X if (ch=='a' `7C`7C ch=='e' `7C`7C ch=='i' `7C`7C ch=='o' `7C`7C V ch=='u') X mod="an"; else mod="a"; X sprintf(logg.what,"killed by %s %s",mod,monster`5Bx`5D.name); X `7D X else sprintf(logg.what,"%s",whydead`5Bx - 256`5D); X logg.cavelev=level; X time(&zzz); /* get cpu time -- write out score info */ X logg.diedtime=zzz; X#ifdef EXTRA X# ifndef MSDOS X times(&cputime); /* get cpu time -- write out score info */ X logg.cputime = i = (cputime.tms_utime + cputime.tms_stime)/60 + c`5B VCPUTIME`5D; X# endif X logg.lev=c`5BLEVEL`5D; logg.ac=c`5BAC`5D; X logg.hpmax=c`5BHPMAX`5D; logg.hp=c`5BHP`5D; X logg.elapsedtime=(zzz-initialtime+59)/60; X logg.usage=(10000*i)/(zzz-initialtime); X logg.bytin=c`5BBYTESIN`5D; logg.bytout=c`5BBYTESOUT`5D; X logg.moves=c`5BMOVESMADE`5D; logg.spused=c`5BSPELLSCAST`5D; X logg.killed=c`5BMONSTKILLED`5D; 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 `7B X if (sortboard()) scorerror = writeboard(); X `7D X `7D X if ((x==256) `7C`7C (x==257) `7C`7C (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 `7D X X/* X * diedsub(x) Subroutine to print out the line showing the player when he i Vs killed X * int x; X */ Xstatic diedsub(x) Xint x; X `7B X register char ch,*mod; X lprintf("Score: %d, Diff: %d, %s ",(long)c`5BGOLD`5D,(long)c`5BHARDGAME V`5D,logname); X if (x < 256) X `7B X ch = *monster`5Bx`5D.name; X if (ch=='a' `7C`7C ch=='e' `7C`7C ch=='i' `7C`7C ch=='o' `7C`7C ch== V'u') X mod="an"; else mod="a"; X lprintf("killed by %s %s",mod,monster`5Bx`5D.name); X `7D X else lprintf("%s",whydead`5Bx - 256`5D); X if (x != 263) lprintf(" on %s\n",levelname`5Blevel`5D); else lprc('\n') V; X `7D X X/* X * diedlog() Subroutine to read a log file and print it out in ascii form Vat X */ Xdiedlog() X `7B X register int n; X register char *p; X struct stat stbuf; X lcreat((char*)0); X if (lopen(logfile)<0) X `7B X lprintf("Can't locate log file <%s>\n",logfile); X return; X `7D X if (fstat(fd,&stbuf) < 0) X `7B X lprintf("Can't stat log file <%s>\n",logfile); X return; X `7D X for (n=stbuf.st_size/sizeof(struct log_fmt); n>0; --n) X `7B X lrfill((char*)&logg,sizeof(struct log_fmt)); X p = ctime(&logg.diedtime); p`5B16`5D='\n'; p`5B17`5D=0; X lprintf("Score: %d, Diff: %d, %s %s on %d at %s",(long)(logg.score) V,(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: V %d minutes\n",(long)(logg.lev),(long)(logg.ac),(long)(logg.hp),(long)(logg. Vhpmax),(long)(logg.elapsedtime)); X# ifndef MSDOS X lprintf(" CPU time used: %d seconds, Machine usage: %d.%02d%%\n",( Vlong)(logg.cputime),(long)(logg.usage/100),(long)(logg.usage%100)); X# endif X lprintf(" BYTES in: %d, out: %d, moves: %d, deaths: %d, spells cast V: %d\n",(long)(logg.bytin),(long)(logg.bytout),(long)(logg.moves),(long)(log Vg.killed),(long)(logg.spused)); X lprintf(" out bytes per move: %d",(long)(logg.bytout/logg.moves)); X# ifndef MSDOS X lprintf(", time per move: %d ms",(long)((logg.cputime*1000)/logg.mo Vves)); X# endif X lprintf("\n"); X#endif X `7D X lflush(); lrclose(); return; X `7D 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 `20 X */ Xstatic int havepid= -1; /* playerid # if previously done */ Xgetplid(nam) X char *nam; X `7B X int fd7,high=999,no; X register char *p,*p2; X char name`5B80`5D; 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 `7B X if ((fd7=creat(playerids,0666)) < 0) return(-1); /* can't make it * V/ X close(fd7); goto addone; /* now append new playerid record to fil Ve */ X `7D X for (;;) /* now search for the name in the player id file */ X `7B 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 `7B X return(no); /* his id number */ X `7D X `7D 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(-2); /* 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 `7D X#endif UIDSCORE $ CALL UNPACK SCORES.C;1 170501323 $ create 'f' X#include X#include "header.h" X#include "larndefs.h" X X#define BIT(a) (1<<((a)-1)) X Xextern char savefilename`5B`5D,wizard,predostuff,nosignal; X Xstatic s2choose() /* text to be displayed if `5EC during intro screen */ X `7B X cursor(1,24); lprcat("Press "); setbold(); lprcat("return"); resetbold() V; X lprcat(" to continue: "); lflush(); X `7D X Xstatic void cntlc() /* what to do for a `5EC */ X `7B X if (nosignal) return; /* don't do anything if inhibited */ X# ifndef MSDOS X signal(SIGQUIT,SIG_IGN); X# endif X signal(SIGINT,SIG_IGN); X quit(); if (predostuff==1) s2choose(); else showplayer(); X lflush(); X# ifndef MSDOS X signal(SIGQUIT,cntlc); X# endif X signal(SIGINT,cntlc); X `7D X X#ifndef MSDOS X/* X * subroutine to save the game if a hangup signal X */ Xstatic sgam() X `7B X savegame(savefilename); wizard=1; died(-257); /* hangup signal */ X `7D X#endif X X#ifdef SIGTSTP Xstatic tstop() /* control Y */ X `7B X if (nosignal) return; /* nothing if inhibited */ X lcreat((char*)0); clearvt100(); lflush(); signal(SIGTSTP,SIG_DFL V); X#ifdef SIGVTALRM X /* looks like BSD4.2 or higher - must clr mask for signal to take effect V*/ X sigsetmask(sigblock(0)& `7EBIT(SIGTSTP)); X#endif X kill(getpid(),SIGTSTP); X X setupvt100(); signal(SIGTSTP,tstop); X if (predostuff==1) s2choose(); else drawscreen(); X showplayer(); lflush(); X `7D X#endif SIGTSTP X X/* X * subroutine to issue the needed signal traps called from main() X */ Xstatic void sigfpe() `7B sigpanic(SIGFPE); `7D X# ifndef MSDOS Xstatic sigbus() `7B sigpanic(SIGBUS); `7D Xstatic sigill() `7B sigpanic(SIGILL); `7D static sigtrap() `7B sigpanic(S VIGTRAP); `7D Xstatic sigiot() `7B sigpanic(SIGIOT); `7D static sigemt() `7B sigpanic(S VIGEMT); `7D Xstatic sigsegv() `7B sigpanic(SIGSEGV); `7D static sigsys() `7B sigpanic(S VIGSYS); `7D Xstatic sigpipe() `7B sigpanic(SIGPIPE); `7D static sigterm() `7B sigpanic(S VIGTERM); `7D X# endif X Xsigsetup() X `7B X signal(SIGINT, cntlc); X signal(SIGFPE, sigfpe); X# ifndef MSDOS X signal(SIGBUS, sigbus); signal(SIGQUIT, cntlc); X signal(SIGKILL, SIG_IGN); signal(SIGHUP, sgam); X signal(SIGILL, sigill); signal(SIGTRAP, sigtrap); X signal(SIGIOT, sigiot); signal(SIGEMT, sigemt); X signal(SIGSEGV, sigsegv); signal(SIGSYS, sigsys); X signal(SIGPIPE, sigpipe); signal(SIGTERM, sigterm); X#ifdef SIGTSTP X signal(SIGTSTP,tstop); signal(SIGSTOP,tstop); X#endif SIGTSTP X# endif X `7D X X#ifdef MSDOS X#define NSIG 9 X#endif X X#ifdef VMS X#define NSIG 16 X#endif X X#ifdef BSD /* for BSD UNIX? */ X Xstatic char *signame`5BNSIG`5D = `7B "", X"SIGHUP", /* 1 hangup */ X"SIGINT", /* 2 interrupt */ X"SIGQUIT", /* 3 quit */ X"SIGILL", /* 4 illegal instruction (not reset when caught) */ X"SIGTRAP", /* 5 trace trap (not reset when caught) */ X"SIGIOT", /* 6 IOT instruction */ X"SIGEMT", /* 7 EMT instruction */ X"SIGFPE", /* 8 floating point exception */ X"SIGKILL", /* 9 kill (cannot be caught or ignored) */ X"SIGBUS", /* 10 bus error */ X"SIGSEGV", /* 11 segmentation violation */ X"SIGSYS", /* 12 bad argument to system call */ X"SIGPIPE", /* 13 write on a pipe with no one to read it */ X"SIGALRM", /* 14 alarm clock */ X"SIGTERM", /* 15 software termination signal from kill */ X"SIGURG", /* 16 urgent condition on IO channel */ X"SIGSTOP", /* 17 sendable stop signal not from tty */ X"SIGTSTP", /* 18 stop signal from tty */ X"SIGCONT", /* 19 continue a stopped process */ X"SIGCHLD", /* 20 to parent on child stop or exit */ X"SIGTTIN", /* 21 to readers pgrp upon background tty read */ X"SIGTTOU", /* 22 like TTIN for output if (tp->t_local<OSTOP) */ X"SIGIO", /* 23 input/output possible signal */ X"SIGXCPU", /* 24 exceeded CPU time limit */ X"SIGXFSZ", /* 25 exceeded file size limit */ X"SIGVTALRM",/* 26 virtual time alarm */ X"SIGPROF", /* 27 profiling time alarm */ X"","","","" `7D; X X#else BSD /* for system V? */ X Xstatic char *signame`5BNSIG+1`5D = `7B "", X"SIGHUP", /* 1 hangup */ X"SIGINT", /* 2 interrupt */ X"SIGQUIT", /* 3 quit */ X"SIGILL", /* 4 illegal instruction (not reset when caught) */ X"SIGTRAP", /* 5 trace trap (not reset when caught) */ X"SIGIOT", /* 6 IOT instruction */ X"SIGEMT", /* 7 EMT instruction */ X# ifdef MSDOS X"SIGFPE"`7D; /* 8 floating point exception */ X# else MSDOS X"SIGFPE", /* 8 floating point exception */ X"SIGKILL", /* 9 kill (cannot be caught or ignored) */ X"SIGBUS", /* 10 bus error */ X"SIGSEGV", /* 11 segmentation violation */ X"SIGSYS", /* 12 bad argument to system call */ X"SIGPIPE", /* 13 write on a pipe with no one to read it */ X"SIGALRM", /* 14 alarm clock */ X# ifdef VMS X"SIGTERM"`7D; /* 15 software termination signal from kill */ X# else VMS X"SIGTERM", /* 15 software termination signal from kill */ X"SIGUSR1", /* 16 user defines signal 1 */ X"SIGUSR2", /* 17 user defines signal 2 */ X"SIGCLD", /* 18 child death */ X"SIGPWR" `7D; /* 19 power fail */ X# endif VMS X# endif MSDOS X# endif BSD X X/* X * routine to process a fatal error signal X */ Xstatic sigpanic(sig) Xint sig; X`7B X char buf`5B128`5D; X signal(sig,SIG_DFL); X sprintf(buf,"\nLarn - Panic! Signal %d received `5B%s`5D",sig,signame`5B Vsig`5D); X write(2,buf,strlen(buf)); sleep(2); X sncbr(); X savegame(savefilename);`20 X# ifdef MSDOS X exit(1); X# else X kill(getpid(),sig); /* this will terminate us */ X# endif X`7D $ CALL UNPACK SIGNAL.C;1 994799568 $ create 'f' X/* X cast() Subroutine called by parse to cast a spell for the user X speldamage(x) Function to perform spell functions cast by the player X loseint() Routine to decrement your int (intelligence) if > 3 X isconfuse() Routine to check to see if player is confused X nospell(x,monst) Routine to return 1 if a spell doesn't affect a monster X fullhit(xx) Function to return full damage against a monst (aka web V) X direct(spnum,dam,str,arg) Routine to direct spell damage 1 square in 1 d Vir X godirect(spnum,dam,str,delay,cshow) Function to perform missile attack Vs X ifblind(x,y) Routine to put "monster" or the monster name into lastm Vosnt X tdirect(spnum) Routine to teleport away a monster X omnidirect(sp,dam,str) Routine to damage all monsters 1 square from playe Vr X dirsub(x,y) Routine to ask for direction, then modify x,y for it X dirpoly(spnum) Routine to ask for a direction and polymorph a monst X annihilate() Routine to annihilate monsters around player, playerx,playe Vry X genmonst() Function to ask for monster and genocide from game X*/ X X#include "header.h" X#include "larndefs.h" X#include "objects.h" X#include "monsters.h" X#include "player.h" X#include X X#define min(x,y) (((x)>(y))?(y):(x)) X#define max(x,y) (((x)>(y))?(x):(y)) X Xstruct isave /* used for altar reality */ X `7B X char type; /* 0=item, 1=monster */ X char id; /* item number or monster number */ X short arg; /* the type of item or hitpoints of monster */ X `7D; X X/* Forward declarations X*/ Xstatic void create_guardian(); Xextern hitm(); Xextern char spelweird`5BMAXMONST+8`5D`5BSPNUM`5D; X X/* X * cast() Subroutine called by parse to cast a spell for the user X * X * No arguments and no return value. X */ Xstatic char eys`5B`5D = "\nEnter your spell: "; Xcast() X `7B X register int i,j,a,b,d; X cursors(); X if (c`5BSPELLS`5D<=0)`20 X `7B `20 X lprcat("\nYou don't have any spells!");`20 X return;`20 X `7D X lprcat(eys); X --c`5BSPELLS`5D; X while ((a=ttgetch())=='I') X `7B`20 X seemagic(-1);`20 X cursors(); `20 X lprcat(eys); X `7D X if (a=='\33')`20 X goto over; /* to escape casting a spell */ X if ((b=ttgetch())=='\33')`20 X goto over; /* to escape casting a spell */ X if ((d=ttgetch())=='\33') X `7B`20 Xover:`20 X lprcat(aborted);`20 X c`5BSPELLS`5D++;`20 X return; +-+-+-+-+-+-+-+- END OF PART 38 +-+-+-+-+-+-+-+-