home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / HACKSRC.ZIP / END.C < prev    next >
C/C++ Source or Header  |  1985-10-16  |  17KB  |  675 lines

  1. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  2. /* end.c - version 1.0.3 */
  3.  
  4. #include <stdio.h>
  5. #include <signal.h>
  6. #include "hack.h"
  7. #define    Sprintf    (void) sprintf
  8. extern char plname[], pl_character[];
  9. extern char *itoa(), *ordin(), *eos();
  10. extern boolean female;            /* should have been flags.female */
  11. xchar maxdlevel = 1;
  12.  
  13. done1()
  14. {
  15.     (void) signal(SIGINT,SIG_IGN);
  16.     pline("Really quit?");
  17.     if(readchar() != 'y') {
  18.         (void) signal(SIGINT,done1);
  19.         clrlin();
  20.         (void) fflush(stdout);
  21.         if(multi > 0) nomul(0);
  22.         return(0);
  23.     }
  24.     done("quit");
  25.     /* NOTREACHED */
  26. }
  27.  
  28. int done_stopprint;
  29. int done_hup;
  30.  
  31. done_intr(){
  32.     done_stopprint++;
  33.     (void) signal(SIGINT, SIG_IGN);
  34. #ifdef SIGQUIT
  35.     (void) signal(SIGQUIT, SIG_IGN);
  36. #endif
  37. }
  38.  
  39. done_hangup(){
  40.     done_hup++;
  41. #ifdef SIGHUP
  42.     (void) signal(SIGHUP, SIG_IGN);
  43. #endif
  44.     done_intr();
  45. }
  46.  
  47. done_in_by(mtmp) register struct monst *mtmp; {
  48. static char buf[BUFSZ];
  49.     pline("You die ...");
  50.     if(mtmp->data->mlet == ' '){
  51.         Sprintf(buf, "the ghost of %s", (char *) mtmp->mextra);
  52.         killer = buf;
  53.     } else if(mtmp->mnamelth) {
  54.         Sprintf(buf, "%s called %s",
  55.             mtmp->data->mname, NAME(mtmp));
  56.         killer = buf;
  57.     } else if(mtmp->minvis) {
  58.         Sprintf(buf, "invisible %s", mtmp->data->mname);
  59.         killer = buf;
  60.     } else killer = mtmp->data->mname;
  61.     done("died");
  62. }
  63.  
  64. /* called with arg "died", "drowned", "escaped", "quit", "choked", "panicked",
  65.    "burned", "starved" or "tricked" */
  66. /* Be careful not to call panic from here! */
  67. done(st1)
  68. register char *st1;
  69. {
  70.  
  71. #ifdef WIZARD
  72.     if(wizard && *st1 == 'd'){
  73.         u.uswldtim = 0;
  74.         if(u.uhpmax < 0) u.uhpmax = 100;    /* arbitrary */
  75.         u.uhp = u.uhpmax;
  76.         pline("For some reason you are still alive.");
  77.         flags.move = 0;
  78.         if(multi > 0) multi = 0; else multi = -1;
  79.         flags.botl = 1;
  80.         return;
  81.     }
  82. #endif WIZARD
  83.     (void) signal(SIGINT, done_intr);
  84. #ifdef SIGQUIT
  85.     (void) signal(SIGQUIT, done_intr);
  86. #endif
  87. #ifdef SIGHUP
  88.     (void) signal(SIGHUP, done_hangup);
  89. #endif
  90.     if(*st1 == 'q' && u.uhp < 1){
  91.         st1 = "died";
  92.         killer = "quit while already on Charon's boat";
  93.     }
  94.     if(*st1 == 's') killer = "starvation"; else
  95.     if(*st1 == 'd' && st1[1] == 'r') killer = "drowning"; else
  96.     if(*st1 == 'p') killer = "panic"; else
  97.     if(*st1 == 't') killer = "trickery"; else
  98.     if(!index("bcd", *st1)) killer = st1;
  99.     paybill();
  100.     clearlocks();
  101.     if(flags.toplin == 1) more();
  102.     if(index("bcds", *st1)){
  103. #ifdef WIZARD
  104.         if(!wizard)
  105. #endif WIZARD
  106.         savebones();
  107.         if(!flags.notombstone)
  108.             outrip();
  109.     }
  110.     if(*st1 == 'c') killer = st1;        /* after outrip() */
  111.     settty((char *) 0);    /* does a clear_screen() */
  112.     if(!done_stopprint)
  113.         printf("Goodbye %s %s...\n\n", pl_character, plname);
  114.     { long int tmp;
  115.       tmp = u.ugold - u.ugold0;
  116.       if(tmp < 0)
  117.         tmp = 0;
  118.       if(*st1 == 'd' || *st1 == 'b')
  119.         tmp -= tmp/10;
  120.       u.urexp += tmp;
  121.       u.urexp += 50 * maxdlevel;
  122.       if(maxdlevel > 20)
  123.         u.urexp += 1000*((maxdlevel > 30) ? 10 : maxdlevel - 20);
  124.     }
  125.     if(*st1 == 'e') {
  126.         extern struct monst *mydogs;
  127.         register struct monst *mtmp;
  128.         register struct obj *otmp;
  129. #define DGK
  130.         long i;
  131. #else
  132.         register int i;
  133. #endif DGK
  134.         register unsigned worthlessct = 0;
  135.         boolean has_amulet = FALSE;
  136.  
  137.         killer = st1;
  138.         keepdogs();
  139.         mtmp = mydogs;
  140.         if(mtmp) {
  141.             if(!done_stopprint) printf("You");
  142.             while(mtmp) {
  143.                 if(!done_stopprint)
  144.                     printf(" and %s", monnam(mtmp));
  145.                 if(mtmp->mtame)
  146.                     u.urexp += mtmp->mhp;
  147.                 mtmp = mtmp->nmon;
  148.             }
  149.             if(!done_stopprint)
  150.             printf("\nescaped from the dungeon with %ld points,\n",
  151.             u.urexp);
  152.         } else
  153.         if(!done_stopprint)
  154.           printf("You escaped from the dungeon with %ld points,\n",
  155.             u.urexp);
  156.         for(otmp = invent; otmp; otmp = otmp->nobj) {
  157.             if(otmp->olet == GEM_SYM){
  158.                 objects[otmp->otyp].oc_name_known = 1;
  159. #ifdef DGK
  160.                 i = (long) otmp->quan *
  161.                     objects[otmp->otyp].g_val;
  162. #else
  163.                 i = otmp->quan*objects[otmp->otyp].g_val;
  164. #endif DGK
  165.                 if(i == 0) {
  166.                     worthlessct += otmp->quan;
  167.                     continue;
  168.                 }
  169.                 u.urexp += i;
  170.                 if(!done_stopprint)
  171. #ifdef DGK
  172.                   printf("\t%s (worth %ld Zorkmids),\n",
  173. #else
  174.                   printf("\t%s (worth %d Zorkmids),\n",
  175. #endif DGK
  176.                     doname(otmp), i);
  177.             } else if(otmp->olet == AMULET_SYM) {
  178.                 otmp->known = 1;
  179.                 i = (otmp->spe < 0) ? 2 : 5000;
  180.                 u.urexp += i;
  181.                 if(!done_stopprint)
  182.                   printf("\t%s (worth %d Zorkmids),\n",
  183.                     doname(otmp), i);
  184.                 if(otmp->spe >= 0) {
  185.                     has_amulet = TRUE;
  186.                     killer = "escaped (with amulet)";
  187.                 }
  188.             }
  189.         }
  190.         if(worthlessct) if(!done_stopprint)
  191.           printf("\t%u worthless piece%s of coloured glass,\n",
  192.           worthlessct, plur(worthlessct));
  193.         if(has_amulet) u.urexp *= 2;
  194.     } else
  195.         if(!done_stopprint)
  196.           printf("You %s on dungeon level %d with %ld points,\n",
  197.             st1, dlevel, u.urexp);
  198.     if(!done_stopprint)
  199.       printf("and %ld piece%s of gold, after %ld move%s.\n",
  200.         u.ugold, plur(u.ugold), moves, plur(moves));
  201.     if(!done_stopprint)
  202.   printf("You were level %u with a maximum of %d hit points when you %s.\n",
  203.         u.ulevel, u.uhpmax, st1);
  204.     if(*st1 == 'e' && !done_stopprint){
  205.         getret();    /* all those pieces of coloured glass ... */
  206.         cls();
  207.     }
  208. #ifdef WIZARD
  209.     if(!wizard)
  210. #endif WIZARD
  211.         topten();
  212.     if(done_stopprint) printf("\n\n");
  213.     exit(0);
  214. }
  215.  
  216. #define newttentry() (struct toptenentry *) alloc(sizeof(struct toptenentry))
  217. #define    NAMSZ    10
  218. #define    DTHSZ    40
  219. #define    PERSMAX    1
  220. #define    POINTSMIN    1    /* must be > 0 */
  221. #define    ENTRYMAX    100    /* must be >= 10 */
  222. #ifndef    MSDOS
  223. #define    PERS_IS_UID        /* delete for PERSMAX per name; now per uid */
  224. #endif
  225. struct toptenentry {
  226.     struct toptenentry *tt_next;
  227.     long int points;
  228.     int level,maxlvl,hp,maxhp;
  229.     int uid;
  230.     char plchar;
  231.     char sex;
  232.     char name[NAMSZ+1];
  233.     char death[DTHSZ+1];
  234.     char date[7];        /* yymmdd */
  235. } *tt_head;
  236.  
  237. topten(){
  238.     int uid = getuid();
  239.     int rank, rank0 = -1, rank1 = 0;
  240.     int occ_cnt = PERSMAX;
  241.     register struct toptenentry *t0, *t1, *tprev;
  242.     char *recfile = RECORD;
  243.     char *reclock = "record_lock";
  244.     int sleepct = 300;
  245.     FILE *rfile;
  246.     register flg = 0;
  247.     extern char *getdate();
  248. #define    HUP    if(!done_hup)
  249. #ifndef    MSDOS
  250.     while(link(recfile, reclock) == -1) {
  251.         HUP perror(reclock);
  252.         if(!sleepct--) {
  253.             HUP puts("I give up. Sorry.");
  254.             HUP puts("Perhaps there is an old record_lock around?");
  255.             return;
  256.         }
  257.         HUP printf("Waiting for access to record file. (%d)\n",
  258.             sleepct);
  259.         HUP (void) fflush(stdout);
  260.         sleep(1);
  261.     }
  262. #endif
  263.     if(!(rfile = fopen(recfile,"r"))){
  264.         HUP puts("Cannot open record file!");
  265.         goto unlock;
  266.     }
  267.     HUP (void) putchar('\n');
  268.  
  269.     /* create a new 'topten' entry */
  270.     t0 = newttentry();
  271.     t0->level = dlevel;
  272.     t0->maxlvl = maxdlevel;
  273.     t0->hp = u.uhp;
  274.     t0->maxhp = u.uhpmax;
  275.     t0->points = u.urexp;
  276.     t0->plchar = pl_character[0];
  277.     t0->sex = (female ? 'F' : 'M');
  278.     t0->uid = uid;
  279.     (void) strncpy(t0->name, plname, NAMSZ);
  280.     (t0->name)[NAMSZ] = 0;
  281.     (void) strncpy(t0->death, killer, DTHSZ);
  282.     (t0->death)[DTHSZ] = 0;
  283.     (void) strcpy(t0->date, getdate());
  284.  
  285.     /* assure minimum number of points */
  286.     if(t0->points < POINTSMIN)
  287.         t0->points = 0;
  288.  
  289.     t1 = tt_head = newttentry();
  290.     tprev = 0;
  291.     /* rank0: -1 undefined, 0 not_on_list, n n_th on list */
  292.     for(rank = 1; ; ) {
  293.       if(fscanf(rfile, "%6s %d %d %d %d %d %ld %c%c %[^,],%[^\n]",
  294.         t1->date, &t1->uid,
  295.         &t1->level, &t1->maxlvl,
  296.         &t1->hp, &t1->maxhp, &t1->points,
  297.         &t1->plchar, &t1->sex, t1->name, t1->death) != 11
  298.       || t1->points < POINTSMIN)
  299.             t1->points = 0;
  300.       if(rank0 < 0 && t1->points < t0->points) {
  301.         rank0 = rank++;
  302.         if(tprev == 0)
  303.             tt_head = t0;
  304.         else
  305.             tprev->tt_next = t0;
  306.         t0->tt_next = t1;
  307.         occ_cnt--;
  308.         flg++;        /* ask for a rewrite */
  309.       } else
  310.         tprev = t1;
  311.       if(t1->points == 0) break;
  312.       if(
  313. #ifdef PERS_IS_UID
  314.          t1->uid == t0->uid &&
  315. #else
  316.          strncmp(t1->name, t0->name, NAMSZ) == 0 &&
  317. #endif PERS_IS_UID
  318.          t1->plchar == t0->plchar && --occ_cnt <= 0){
  319.         if(rank0 < 0){
  320.             rank0 = 0;
  321.             rank1 = rank;
  322.     HUP printf("You didn't beat your previous score of %ld points.\n\n",
  323.                 t1->points);
  324.         }
  325.         if(occ_cnt < 0){
  326.             flg++;
  327.             continue;
  328.         }
  329.       }
  330.       if(rank <= ENTRYMAX){
  331.           t1 = t1->tt_next = newttentry();
  332.           rank++;
  333.       }
  334.       if(rank > ENTRYMAX){
  335.         t1->points = 0;
  336.         break;
  337.       }
  338.     }
  339.     if(flg) {    /* rewrite record file */
  340.         (void) fclose(rfile);
  341.         if(!(rfile = fopen(recfile,"w"))){
  342.             HUP puts("Cannot write record file\n");
  343.             goto unlock;
  344.         }
  345.  
  346.         if(!done_stopprint) if(rank0 > 0){
  347.             if(rank0 <= 10)
  348.             puts("You made the top ten list!\n");
  349.             else
  350.         printf("You reached the %d%s place on the top %d list.\n\n",
  351.             rank0, ordin(rank0), ENTRYMAX);
  352.         }
  353.     }
  354.     if(rank0 == 0) rank0 = rank1;
  355.     if(rank0 <= 0) rank0 = rank;
  356.     if(!done_stopprint) outheader();
  357.     t1 = tt_head;
  358.     for(rank = 1; t1->points != 0; rank++, t1 = t1->tt_next) {
  359.       if(flg) fprintf(rfile,"%6s %d %d %d %d %d %ld %c%c %s,%s\n",
  360.         t1->date, t1->uid,
  361.         t1->level, t1->maxlvl,
  362.         t1->hp, t1->maxhp, t1->points,
  363.         t1->plchar, t1->sex, t1->name, t1->death);
  364.       if(done_stopprint) continue;
  365.       if(rank > flags.end_top &&
  366.         (rank < rank0-flags.end_around || rank > rank0+flags.end_around)
  367.         && (!flags.end_own ||
  368. #ifdef PERS_IS_UID
  369.                   t1->uid != t0->uid ))
  370. #else
  371.                   strncmp(t1->name, t0->name, NAMSZ)))
  372. #endif PERS_IS_UID
  373.           continue;
  374.       if(rank == rank0-flags.end_around &&
  375.          rank0 > flags.end_top+flags.end_around+1 &&
  376.          !flags.end_own)
  377.         (void) putchar('\n');
  378.       if(rank != rank0)
  379.         (void) outentry(rank, t1, 0);
  380.       else if(!rank1)
  381.         (void) outentry(rank, t1, 1);
  382.       else {
  383.         int t0lth = outentry(0, t0, -1);
  384.         int t1lth = outentry(rank, t1, t0lth);
  385.         if(t1lth > t0lth) t0lth = t1lth;
  386.         (void) outentry(0, t0, t0lth);
  387.       }
  388.     }
  389.     if(rank0 >= rank) if(!done_stopprint)
  390.         (void) outentry(0, t0, 1);
  391.     (void) fclose(rfile);
  392. unlock:
  393.     (void) unlink(reclock);
  394. }
  395.  
  396. outheader() {
  397. char linebuf[BUFSZ];
  398. register char *bp;
  399.     (void) strcpy(linebuf, "Number Points  Name");
  400.     bp = eos(linebuf);
  401.     while(bp < linebuf + COLNO - 9) *bp++ = ' ';
  402.     (void) strcpy(bp, "Hp [max]");
  403.     puts(linebuf);
  404. }
  405.  
  406. /* so>0: standout line; so=0: ordinary line; so<0: no output, return lth */
  407. int
  408. outentry(rank,t1,so) register struct toptenentry *t1; {
  409. boolean quit = FALSE, killed = FALSE, starv = FALSE;
  410. char linebuf[BUFSZ];
  411.     linebuf[0] = 0;
  412.     if(rank) Sprintf(eos(linebuf), "%3d", rank);
  413.         else Sprintf(eos(linebuf), "   ");
  414. #ifdef DGK
  415.     Sprintf(eos(linebuf), " %6ld %10s", t1->points, t1->name);
  416. #else
  417.     Sprintf(eos(linebuf), " %6ld %8s", t1->points, t1->name);
  418. #endif DGK
  419.     if(t1->plchar == 'X') Sprintf(eos(linebuf), " ");
  420.     else Sprintf(eos(linebuf), "-%c ", t1->plchar);
  421.     if(!strncmp("escaped", t1->death, 7)) {
  422.       if(!strcmp(" (with amulet)", t1->death+7))
  423.         Sprintf(eos(linebuf), "escaped the dungeon with amulet");
  424.       else
  425.         Sprintf(eos(linebuf), "escaped the dungeon [max level %d]",
  426.           t1->maxlvl);
  427.     } else {
  428.       if(!strncmp(t1->death,"quit",4)) {
  429.         quit = TRUE;
  430.         if(t1->maxhp < 3*t1->hp && t1->maxlvl < 4)
  431.           Sprintf(eos(linebuf), "cravenly gave up");
  432.         else
  433.         Sprintf(eos(linebuf), "quit");
  434.       }
  435.       else if(!strcmp(t1->death,"choked"))
  436.         Sprintf(eos(linebuf), "choked on %s food",
  437.         (t1->sex == 'F') ? "her" : "his");
  438.       else if(!strncmp(t1->death,"starv",5))
  439.         Sprintf(eos(linebuf), "starved to death"), starv = TRUE;
  440.       else Sprintf(eos(linebuf), "was killed"), killed = TRUE;
  441.       Sprintf(eos(linebuf), " on%s level %d",
  442.         (killed || starv) ? "" : " dungeon", t1->level);
  443.       if(t1->maxlvl != t1->level)
  444.         Sprintf(eos(linebuf), " [max %d]", t1->maxlvl);
  445.       if(quit && t1->death[4]) Sprintf(eos(linebuf), t1->death + 4);
  446.     }
  447.     if(killed) Sprintf(eos(linebuf), " by %s%s",
  448.       (!strncmp(t1->death, "trick", 5) || !strncmp(t1->death, "the ", 4))
  449.         ? "" :
  450.       index(vowels,*t1->death) ? "an " : "a ",
  451.       t1->death);
  452.     Sprintf(eos(linebuf), ".");
  453.     if(t1->maxhp) {
  454.       register char *bp = eos(linebuf);
  455.       char hpbuf[10];
  456.       int hppos;
  457.       Sprintf(hpbuf, (t1->hp > 0) ? itoa(t1->hp) : "-");
  458.       hppos = COLNO - 7 - strlen(hpbuf);
  459.       if(bp <= linebuf + hppos) {
  460.         while(bp < linebuf + hppos) *bp++ = ' ';
  461.         (void) strcpy(bp, hpbuf);
  462.         Sprintf(eos(bp), " [%d]", t1->maxhp);
  463.       }
  464.     }
  465.     if(so == 0) puts(linebuf);
  466.     else if(so > 0) {
  467.       register char *bp = eos(linebuf);
  468.       if(so >= COLNO) so = COLNO-1;
  469.       while(bp < linebuf + so) *bp++ = ' ';
  470.       *bp = 0;
  471.       standoutbeg();
  472.       fputs(linebuf,stdout);
  473.       standoutend();
  474. #ifdef DGK
  475.     /* This is needed to get the screen back to normal after standout */
  476.       end_screen();
  477. #endif DGK
  478.       (void) putchar('\n');
  479.     }
  480.     return(strlen(linebuf));
  481. }
  482.  
  483. char *
  484. itoa(a) int a; {
  485. static char buf[12];
  486.     Sprintf(buf,"%d",a);
  487.     return(buf);
  488. }
  489.  
  490. char *
  491. ordin(n) int n; {
  492. register int d = n%10;
  493.     return((d==0 || d>3 || n/10==1) ? "th" : (d==1) ? "st" :
  494.         (d==2) ? "nd" : "rd");
  495. }
  496.  
  497. clearlocks(){
  498. register x;
  499. #ifdef SIGHUP
  500.     (void) signal(SIGHUP,SIG_IGN);
  501. #endif
  502.     for(x = maxdlevel; x >= 0; x--) {
  503.         glo(x);
  504.         (void) unlink(lock);    /* not all levels need be present */
  505.     }
  506. }
  507.  
  508. #ifdef NOSAVEONHANGUP
  509. hangup()
  510. {
  511.     (void) signal(SIGINT, SIG_IGN);
  512.     clearlocks();
  513.     exit(1);
  514. }
  515. #endif NOSAVEONHANGUP
  516.  
  517. char *
  518. eos(s)
  519. register char *s;
  520. {
  521.     while(*s) s++;
  522.     return(s);
  523. }
  524.  
  525. /* it is the callers responsibility to check that there is room for c */
  526. charcat(s,c) register char *s, c; {
  527.     while(*s) s++;
  528.     *s++ = c;
  529.     *s = 0;
  530. }
  531.  
  532. /*
  533.  * Called with args from main if argc >= 0. In this case, list scores as
  534.  * requested. Otherwise, find scores for the current player (and list them
  535.  * if argc == -1).
  536.  */
  537. prscore(argc,argv) int argc; char **argv; {
  538.     extern char *hname;
  539.     char **players;
  540.     int playerct;
  541.     int rank;
  542.     register struct toptenentry *t1, *t2;
  543.     char *recfile = RECORD;
  544.     FILE *rfile;
  545.     register flg = 0;
  546.     register int i;
  547. #ifdef nonsense
  548.     long total_score = 0L;
  549.     char totchars[10];
  550.     int totcharct = 0;
  551. #endif nonsense
  552.     int outflg = (argc >= -1);
  553. #ifdef PERS_IS_UID
  554.     int uid = -1;
  555. #else
  556.     char *player0;
  557. #endif PERS_IS_UID
  558.  
  559.     if(!(rfile = fopen(recfile,"r"))){
  560.         puts("Cannot open record file!");
  561.         return;
  562.     }
  563.  
  564.     if(argc > 1 && !strncmp(argv[1], "-s", 2)){
  565.         if(!argv[1][2]){
  566.             argc--;
  567.             argv++;
  568.         } else if(!argv[1][3] && index("CFKSTWX", argv[1][2])) {
  569.             argv[1]++;
  570.             argv[1][0] = '-';
  571.         } else    argv[1] += 2;
  572.     }
  573.     if(argc <= 1){
  574. #ifdef PERS_IS_UID
  575.         uid = getuid();
  576.         playerct = 0;
  577. #else
  578.         player0 = plname;
  579.         if(!*player0)
  580.             player0 = "hackplayer";
  581.         playerct = 1;
  582.         players = &player0;
  583. #endif PERS_IS_UID
  584.     } else {
  585.         playerct = --argc;
  586.         players = ++argv;
  587.     }
  588.     if(outflg) putchar('\n');
  589.  
  590.     t1 = tt_head = newttentry();
  591.     for(rank = 1; ; rank++) {
  592.       if(fscanf(rfile, "%6s %d %d %d %d %d %ld %c%c %[^,],%[^\n]",
  593.         t1->date, &t1->uid,
  594.         &t1->level, &t1->maxlvl,
  595.         &t1->hp, &t1->maxhp, &t1->points,
  596.         &t1->plchar, &t1->sex, t1->name, t1->death) != 11)
  597.             t1->points = 0;
  598.       if(t1->points == 0) break;
  599. #ifdef PERS_IS_UID
  600.       if(!playerct && t1->uid == uid)
  601.         flg++;
  602.       else
  603. #endif PERS_IS_UID
  604.       for(i = 0; i < playerct; i++){
  605.         if(strcmp(players[i], "all") == 0 ||
  606.            strncmp(t1->name, players[i], NAMSZ) == 0 ||
  607.           (players[i][0] == '-' &&
  608.            players[i][1] == t1->plchar &&
  609.            players[i][2] == 0) ||
  610.           (digit(players[i][0]) && rank <= atoi(players[i])))
  611.             flg++;
  612.       }
  613.       t1 = t1->tt_next = newttentry();
  614.     }
  615.     (void) fclose(rfile);
  616.     if(!flg) {
  617.         if(outflg) {
  618.         printf("Cannot find any entries for ");
  619.         if(playerct < 1) printf("you.\n");
  620.         else {
  621.           if(playerct > 1) printf("any of ");
  622.           for(i=0; i<playerct; i++)
  623.             printf("%s%s", players[i], (i<playerct-1)?", ":".\n");
  624.           printf("Call is: %s -s [playernames]\n", hname);
  625.         }
  626.         }
  627.         return;
  628.     }
  629.  
  630.     if(outflg) outheader();
  631.     t1 = tt_head;
  632.     for(rank = 1; t1->points != 0; rank++, t1 = t2) {
  633.         t2 = t1->tt_next;
  634. #ifdef PERS_IS_UID
  635.         if(!playerct && t1->uid == uid)
  636.             goto outwithit;
  637.         else
  638. #endif PERS_IS_UID
  639.         for(i = 0; i < playerct; i++){
  640.             if(strcmp(players[i], "all") == 0 ||
  641.                strncmp(t1->name, players[i], NAMSZ) == 0 ||
  642.               (players[i][0] == '-' &&
  643.                players[i][1] == t1->plchar &&
  644.                players[i][2] == 0) ||
  645.               (digit(players[i][0]) && rank <= atoi(players[i]))){
  646.             outwithit:
  647.                 if(outflg)
  648.                     (void) outentry(rank, t1, 0);
  649. #ifdef nonsense
  650.                 total_score += t1->points;
  651.                 if(totcharct < sizeof(totchars)-1)
  652.                     totchars[totcharct++] = t1->plchar;
  653. #endif nonsense
  654.                 break;
  655.             }
  656.         }
  657.         free((char *) t1);
  658.     }
  659. #ifdef nonsense
  660.     totchars[totcharct] = 0;
  661.  
  662.     /* We would like to determine whether he is experienced. However,
  663.        the information collected here only tells about the scores/roles
  664.        that got into the topten (top 100?). We should maintain a
  665.        .hacklog or something in his home directory. */
  666.     flags.beginner = (total_score < 6000);
  667.     for(i=0; i<6; i++)
  668.         if(!index(totchars, "CFKSTWX"[i])) {
  669.         flags.beginner = 1;
  670.         if(!pl_character[0]) pl_character[0] = "CFKSTWX"[i];
  671.         break;
  672.     }
  673. #endif nonsense
  674. }
  675.