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