Annotation of 43BSD/games/adventure/wizard.c, revision 1.1.1.1

1.1       root        1: #
                      2: /*      Re-coding of advent in C: privileged operations                 */
                      3: 
                      4: static char sccsid[] = "       wizard.c        4.1     82/05/11        ";
                      5: 
                      6: # include "hdr.h"
                      7: 
                      8: datime(d,t)
                      9: int *d,*t;
                     10: {       int tvec[2],*tptr;
                     11:        int *localtime();
                     12:        time(tvec);
                     13:        tptr=localtime(tvec);
                     14:        *d=tptr[7]+365*(tptr[5]-77);    /* day since 1977  (mod leap)   */
                     15:        /* bug: this will overflow in the year 2066 AD                  */
                     16:        /* it will be attributed to Wm the C's millenial celebration    */
                     17:        *t=tptr[2]*60+tptr[1];          /* and minutes since midnite    */
                     18: }                                       /* pretty painless              */
                     19: 
                     20: 
                     21: char *magic;
                     22: 
                     23: poof()
                     24: {       magic="dwarf";
                     25:        latncy=45;
                     26: }
                     27: 
                     28: start(n)
                     29: {       int d,t,delay;
                     30:        datime(&d,&t);
                     31:        delay=(d-saved)*1440+(t-savet); /* good for about a month       */
                     32:        if (delay>=latncy || setup >= 0)
                     33:        {       saved= -1;
                     34:                return(FALSE);
                     35:        }
                     36:        printf("This adventure was suspended a mere %d minutes ago.",delay);
                     37:        if (delay<=latncy/3)
                     38:        {       mspeak(2);
                     39:                exit(0);
                     40:        }
                     41:        mspeak(8);
                     42:        if (!wizard())
                     43:        {       mspeak(9);
                     44:                exit(0);
                     45:        }
                     46:        saved = -1;
                     47:        return(FALSE);
                     48: }
                     49: 
                     50: wizard()                /* not as complex as advent/10 (for now)        */
                     51: {       register int wiz;
                     52:        char *word,*x;
                     53:        if (!yesm(16,0,7)) return(FALSE);
                     54:        mspeak(17);
                     55:        getin(&word,&x);
                     56:        if (!weq(word,magic))
                     57:        {       mspeak(20);
                     58:                return(FALSE);
                     59:        }
                     60:        mspeak(19);
                     61:        return(TRUE);
                     62: }
                     63: 
                     64: ciao(cmdfile)
                     65: char *cmdfile;
                     66: {       register char *c;
                     67:        register int outfd, size;
                     68:        char fname[80], buf[512];
                     69:        extern unsigned filesize;
                     70: 
                     71:        lseek(datfd,(long)filesize,0);
                     72:        for (;;)
                     73:        {       printf("What would you like to call the saved version?\n");
                     74:                for (c=fname;; c++)
                     75:                        if ((*c=getchar())=='\n') break;
                     76:                *c=0;
                     77:                if (save(cmdfile,fname)>=0) break;
                     78:                printf("I can't use that one.\n");
                     79:                return;
                     80:        }
                     81:        outfd=open(fname,1);
                     82:        lseek(outfd,0L,2);                /* end of executable file       */
                     83:        while ((size=read(datfd,buf,512))>0)
                     84:                write(outfd,buf,size);  /* copy the message data        */
                     85:        printf("                    ^\n");
                     86:        printf("That should do it.  Gis revido.\n");
                     87:        exit(0);
                     88: }
                     89: 
                     90: 
                     91: ran(range)                              /* uses unix rng                */
                     92: int range;                              /* can't div by 32768 because   */
                     93: {
                     94:        long rand(), i;
                     95:        i = rand() % range;
                     96:        return(i);
                     97: }
                     98: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.