|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T h
Length: 6656 (0x1a00)
Types: TextFile
Names: »hack.end.c«
└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen
└─⟦this⟧ »cph85dist/hack/hack.end.c«
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* hack.end.c - version 1.0.3 */
#include "hack.h"
#include <stdio.h>
#include <signal.h>
#define Sprintf (void) sprintf
extern char plname[], pl_character[];
extern char *itoa(), *ordin(), *eos();
xchar maxdlevel = 1;
done1()
{
(void) signal(SIGINT,SIG_IGN);
pline("Really quit?");
if(readchar() != 'y') {
(void) signal(SIGINT,done1);
clrlin();
(void) fflush(stdout);
if(multi > 0) nomul(0);
return(0);
}
done("quit");
/* NOTREACHED */
}
int done_stopprint;
int done_hup;
done_intr(){
done_stopprint++;
(void) signal(SIGINT, SIG_IGN);
(void) signal(SIGQUIT, SIG_IGN);
}
done_hangup(){
done_hup++;
(void) signal(SIGHUP, SIG_IGN);
done_intr();
}
done_in_by(mtmp) register struct monst *mtmp; {
static char buf[BUFSZ];
pline("You die ...");
if(mtmp->data->mlet == ' '){
Sprintf(buf, "the ghost of %s", (char *) mtmp->mextra);
killer = buf;
} else if(mtmp->mnamelth) {
Sprintf(buf, "%s called %s",
mtmp->data->mname, NAME(mtmp));
killer = buf;
} else if(mtmp->minvis) {
Sprintf(buf, "invisible %s", mtmp->data->mname);
killer = buf;
} else killer = mtmp->data->mname;
done("died");
}
/* called with arg "died", "drowned", "escaped", "quit", "choked", "panicked",
"burned", "starved" or "tricked" */
/* Be careful not to call panic from here! */
done(st1)
register char *st1;
{
#ifdef WIZARD
if(wizard && *st1 == 'd'){
u.uswldtim = 0;
if(u.uhpmax < 0) u.uhpmax = 100; /* arbitrary */
u.uhp = u.uhpmax;
pline("For some reason you are still alive.");
flags.move = 0;
if(multi > 0) multi = 0; else multi = -1;
flags.botl = 1;
return;
}
#endif WIZARD
(void) signal(SIGINT, done_intr);
(void) signal(SIGQUIT, done_intr);
(void) signal(SIGHUP, done_hangup);
if(*st1 == 'q' && u.uhp < 1){
st1 = "died";
killer = "quit while already on Charon's boat";
}
if(*st1 == 's') killer = "starvation"; else
if(*st1 == 'd' && st1[1] == 'r') killer = "drowning"; else
if(*st1 == 'p') killer = "panic"; else
if(*st1 == 't') killer = "trickery"; else
if(!index("bcd", *st1)) killer = st1;
paybill();
clearlocks();
if(flags.toplin == 1) more();
if(index("bcds", *st1)){
#ifdef WIZARD
if(!wizard)
#endif WIZARD
savebones();
if(!flags.notombstone)
outrip();
}
if(*st1 == 'c') killer = st1; /* after outrip() */
settty((char *) 0); /* does a clear_screen() */
if(!done_stopprint)
printf("Goodbye %s %s...\n\n", pl_character, plname);
{ long int tmp;
tmp = u.ugold - u.ugold0;
if(tmp < 0)
tmp = 0;
if(*st1 == 'd' || *st1 == 'b')
tmp -= tmp/10;
u.urexp += tmp;
u.urexp += 50 * maxdlevel;
if(maxdlevel > 20)
u.urexp += 1000*((maxdlevel > 30) ? 10 : maxdlevel - 20);
}
if(*st1 == 'e') {
extern struct monst *mydogs;
register struct monst *mtmp;
register struct obj *otmp;
register int i;
register unsigned worthlessct = 0;
boolean has_amulet = FALSE;
killer = st1;
keepdogs();
mtmp = mydogs;
if(mtmp) {
if(!done_stopprint) printf("You");
while(mtmp) {
if(!done_stopprint)
printf(" and %s", monnam(mtmp));
if(mtmp->mtame)
u.urexp += mtmp->mhp;
mtmp = mtmp->nmon;
}
if(!done_stopprint)
printf("\nescaped from the dungeon with %ld points,\n",
u.urexp);
} else
if(!done_stopprint)
printf("You escaped from the dungeon with %ld points,\n",
u.urexp);
for(otmp = invent; otmp; otmp = otmp->nobj) {
if(otmp->olet == GEM_SYM){
objects[otmp->otyp].oc_name_known = 1;
i = otmp->quan*objects[otmp->otyp].g_val;
if(i == 0) {
worthlessct += otmp->quan;
continue;
}
u.urexp += i;
if(!done_stopprint)
printf("\t%s (worth %d Zorkmids),\n",
doname(otmp), i);
} else if(otmp->olet == AMULET_SYM) {
otmp->known = 1;
i = (otmp->spe < 0) ? 2 : 5000;
u.urexp += i;
if(!done_stopprint)
printf("\t%s (worth %d Zorkmids),\n",
doname(otmp), i);
if(otmp->spe >= 0) {
has_amulet = TRUE;
killer = "escaped (with amulet)";
}
}
}
if(worthlessct) if(!done_stopprint)
printf("\t%u worthless piece%s of coloured glass,\n",
worthlessct, plur(worthlessct));
if(has_amulet) u.urexp *= 2;
} else
if(!done_stopprint)
printf("You %s on dungeon level %d with %ld points,\n",
st1, dlevel, u.urexp);
if(!done_stopprint)
printf("and %ld piece%s of gold, after %ld move%s.\n",
u.ugold, plur(u.ugold), moves, plur(moves));
if(!done_stopprint)
printf("You were level %u with a maximum of %d hit points when you %s.\n",
u.ulevel, u.uhpmax, st1);
if(*st1 == 'e' && !done_stopprint){
getret(); /* all those pieces of coloured glass ... */
cls();
}
#ifdef WIZARD
if(!wizard)
#endif WIZARD
topten();
if(done_stopprint) printf("\n\n");
exit(0);
}
#define newttentry() (struct toptenentry *) alloc(sizeof(struct toptenentry))
#define NAMSZ 8
#define DTHSZ 40
#define PERSMAX 1
#define POINTSMIN 1 /* must be > 0 */
#define ENTRYMAX 100 /* must be >= 10 */
#define PERS_IS_UID /* delete for PERSMAX per name; now per uid */
struct toptenentry {
struct toptenentry *tt_next;
long int points;
int level,maxlvl,hp,maxhp;
int uid;
char plchar;
char sex;
char name[NAMSZ+1];
char death[DTHSZ+1];
char date[7]; /* yymmdd */
} *tt_head;
topten(){
int uid = getuid();
int rank, rank0 = -1, rank1 = 0;
int occ_cnt = PERSMAX;
register struct toptenentry *t0, *t1, *tprev;
char *recfile = RECORD;
char *reclock = "record_lock";
int sleepct = 300;
FILE *rfile;
register flg = 0;
extern char *getdate();
#define HUP if(!done_hup)
while(link(recfile, reclock) == -1) {
HUP perror(reclock);
if(!sleepct--) {
HUP puts("I give up. Sorry.");
HUP puts("Perhaps there is an old record_lock around?");
return;
}
HUP printf("Waiting for access to record file. (%d)\n",
sleepct);
HUP (void) fflush(stdout);
sleep(1);
}
if(!(rfile = fopen(recfile,"r"))){
HUP puts("Cannot open record file!");
goto unlock;
}
HUP (void) putchar('\n');
/* create a new 'topten' entry */
t0 = newttentry();
t0->level = dlevel;
t0->maxlvl = maxdlevel;
t0->hp = u.uhp;
t0->maxhp = u.uhpmax;
t0->points = u.urexp;
t0->plchar = pl_character[0];
t0->sex = (flags.female ? 'F' : 'M');
t0->uid = uid;
(void) strncpy(t0->name, plname, NAMSZ);
(t0->name)[NAMSZ] = 0;
(void) strncpy(t0->death, killer, DTHSZ);
(t0->death)[DTHSZ] = 0;
(void) strcpy(t0->date, getdate());
/* assure minimum number of points */
if(t0->points < POINTSMIN)
t0->points = 0;
t1 = tt_head = newttentry();
tprev = 0;
/* rank0: -1 undefined, 0 not_on_list, n n_th on list */
for(rank = 1; ; ) {