Annotation of 43BSDReno/games/adventure/init.c, revision 1.1

1.1     ! root        1: #
        !             2: /*      Re-coding of advent in C: data initialization                   */
        !             3: 
        !             4: static char sccsid[] = "       init.c  4.2     89/03/05        ";
        !             5: 
        !             6: #include <sys/types.h>
        !             7: #include <stdio.h>
        !             8: #include "hdr.h"
        !             9: #include "pathnames.h"
        !            10: 
        !            11: int blklin = TRUE;
        !            12: int setup  = 0;
        !            13: 
        !            14: int setbit[16] = {1,2,4,010,020,040,0100,0200,0400,01000,02000,04000,
        !            15:                  010000,020000,040000,0100000};
        !            16: 
        !            17: 
        !            18: init(command)                           /* everything for 1st time run  */
        !            19: char *command;                          /* command we were called with  */
        !            20: {       int stat,adfd;
        !            21:        rdata();                        /* read data from orig. file    */
        !            22:        linkdata();
        !            23:        poof();
        !            24:        setup=1;                        /* indicate that data is in     */
        !            25:        if (save(command, "adventure") < 0) {
        !            26:                fprintf(stderr, "adventure: save failed\n");
        !            27:                exit(1);
        !            28:        }
        !            29:        adfd=open("adventure",1);
        !            30:        lseek(adfd,0L,2);
        !            31:        close(datfd);
        !            32:        if (vfork() == 0) {
        !            33:                dup2(adfd, 1);
        !            34:                execl(_PATH_CAT, "cat", TMPFILE, 0);
        !            35:                fprintf(stderr, "adventure: unable to find %s\n", _PATH_CAT);
        !            36:                exit(1);
        !            37:        }
        !            38:        wait(&stat);
        !            39:        unlink(TMPFILE);
        !            40:        exit(stat);
        !            41: }
        !            42: 
        !            43: 
        !            44: linkdata()                              /*  secondary data manipulation */
        !            45: {       register int i,j;
        !            46:        /*      array linkages          */
        !            47:        for (i=1; i<=LOCSIZ; i++)
        !            48:                if (ltext[i].seekadr!=0 && travel[i] != 0)
        !            49:                        if ((travel[i]->tverb)==1) cond[i]=2;
        !            50:        for (j=100; j>0; j--)
        !            51:                if (fixd[j]>0)
        !            52:                {       drop(j+100,fixd[j]);
        !            53:                        drop(j,plac[j]);
        !            54:                }
        !            55:        for (j=100; j>0; j--)
        !            56:        {       fixed[j]=fixd[j];
        !            57:                if (plac[j]!=0 && fixd[j]<=0) drop(j,plac[j]);
        !            58:        }
        !            59: 
        !            60:        maxtrs=79;
        !            61:        tally=0;
        !            62:        tally2=0;
        !            63: 
        !            64:        for (i=50; i<=maxtrs; i++)
        !            65:        {       if (ptext[i].seekadr!=0) prop[i] = -1;
        !            66:                tally -= prop[i];
        !            67:        }
        !            68: 
        !            69:        /* define mnemonics */
        !            70:        keys=vocab("keys",1);
        !            71:        lamp=vocab("lamp",1);
        !            72:        grate=vocab("grate",1);
        !            73:        cage=vocab("cage",1);
        !            74:        rod=vocab("rod",1);
        !            75:        rod2=rod+1;
        !            76:        steps=vocab("steps",1);
        !            77:        bird=vocab("bird",1);
        !            78:        door=vocab("door",1);
        !            79:        pillow=vocab("pillow",1);
        !            80:        snake=vocab("snake",1);
        !            81:        fissur=vocab("fissu",1);
        !            82:        tablet=vocab("table",1);
        !            83:        clam=vocab("clam",1);
        !            84:        oyster=vocab("oyster",1);
        !            85:        magzin=vocab("magaz",1);
        !            86:        dwarf=vocab("dwarf",1);
        !            87:        knife=vocab("knife",1);
        !            88:        food=vocab("food",1);
        !            89:        bottle=vocab("bottl",1);
        !            90:        water=vocab("water",1);
        !            91:        oil=vocab("oil",1);
        !            92:        plant=vocab("plant",1);
        !            93:        plant2=plant+1;
        !            94:        axe=vocab("axe",1);
        !            95:        mirror=vocab("mirro",1);
        !            96:        dragon=vocab("drago",1);
        !            97:        chasm=vocab("chasm",1);
        !            98:        troll=vocab("troll",1);
        !            99:        troll2=troll+1;
        !           100:        bear=vocab("bear",1);
        !           101:        messag=vocab("messa",1);
        !           102:        vend=vocab("vendi",1);
        !           103:        batter=vocab("batte",1);
        !           104: 
        !           105:        nugget=vocab("gold",1);
        !           106:        coins=vocab("coins",1);
        !           107:        chest=vocab("chest",1);
        !           108:        eggs=vocab("eggs",1);
        !           109:        tridnt=vocab("tride",1);
        !           110:        vase=vocab("vase",1);
        !           111:        emrald=vocab("emera",1);
        !           112:        pyram=vocab("pyram",1);
        !           113:        pearl=vocab("pearl",1);
        !           114:        rug=vocab("rug",1);
        !           115:        chain=vocab("chain",1);
        !           116: 
        !           117:        back=vocab("back",0);
        !           118:        look=vocab("look",0);
        !           119:        cave=vocab("cave",0);
        !           120:        null=vocab("null",0);
        !           121:        entrnc=vocab("entra",0);
        !           122:        dprssn=vocab("depre",0);
        !           123: 
        !           124:        say=vocab("say",2);
        !           125:        lock=vocab("lock",2);
        !           126:        throw=vocab("throw",2);
        !           127:        find=vocab("find",2);
        !           128:        invent=vocab("inven",2);
        !           129:        /* initialize dwarves */
        !           130:        chloc=114;
        !           131:        chloc2=140;
        !           132:        for (i=1; i<=6; i++)
        !           133:                dseen[i]=FALSE;
        !           134:        dflag=0;
        !           135:        dloc[1]=19;
        !           136:        dloc[2]=27;
        !           137:        dloc[3]=33;
        !           138:        dloc[4]=44;
        !           139:        dloc[5]=64;
        !           140:        dloc[6]=chloc;
        !           141:        daltlc=18;
        !           142: 
        !           143:        /* random flags & ctrs */
        !           144:        turns=0;
        !           145:        lmwarn=FALSE;
        !           146:        iwest=0;
        !           147:        knfloc=0;
        !           148:        detail=0;
        !           149:        abbnum=5;
        !           150:        for (i=0; i<=4; i++)
        !           151:                if (rtext[2*i+81].seekadr!=0) maxdie=i+1;
        !           152:        numdie=holdng=dkill=foobar=bonus=0;
        !           153:        clock1=30;
        !           154:        clock2=50;
        !           155:        saved=0;
        !           156:        closng=panic=closed=scorng=FALSE;
        !           157: }
        !           158: 
        !           159: 
        !           160: 
        !           161: trapdel()                               /* come here if he hits a del   */
        !           162: {      delhit++;                       /* main checks, treats as QUIT  */
        !           163:        signal(2,trapdel);              /* catch subsequent DELs        */
        !           164: }
        !           165: 
        !           166: 
        !           167: startup()
        !           168: {
        !           169:        time_t time();
        !           170: 
        !           171:        demo=start(0);
        !           172:        srand((int)(time((time_t *)NULL)));     /* random seed */
        !           173:        /* srand(371);                          /* non-random seed */
        !           174:        hinted[3]=yes(65,1,0);
        !           175:        newloc=1;
        !           176:        setup=3;
        !           177:        limit=330;
        !           178:        if (hinted[3]) limit=1000;      /* better batteries if instrucs */
        !           179: }
        !           180: 

unix.superglobalmegacorp.com

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