⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 io.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
		    && ! (sect==5 && (locc==0 || locc>=100)))/* unless sect 5*/		{       switch(sect)    /* now put it into right table  */			{   case 1:     /* long descriptions            */				ltext[oldloc].seekadr=seekhere;				ltext[oldloc].txtlen=maystart-seekstart;				break;			    case 2:     /* short descriptions           */				stext[oldloc].seekadr=seekhere;				stext[oldloc].txtlen=maystart-seekstart;				break;			    case 5:     /* object descriptions          */				ptext[oldloc].seekadr=seekhere;				ptext[oldloc].txtlen=maystart-seekstart;				break;			    case 6:     /* random messages              */				if (oldloc>RTXSIZ)				{       printf("Too many random msgs\n");					exit(0);				}				rtext[oldloc].seekadr=seekhere;				rtext[oldloc].txtlen=maystart-seekstart;				break;			    case 10:    /* class messages               */				ctext[clsses].seekadr=seekhere;				ctext[clsses].txtlen=maystart-seekstart;				cval[clsses++]=oldloc;				break;			    case 12:    /* magic messages               */				if (oldloc>MAGSIZ)				{       printf("Too many magic msgs\n");					exit(0);				}				mtext[oldloc].seekadr=seekhere;				mtext[oldloc].txtlen=maystart-seekstart;				break;			    default:				printf("rdesc called with bad section\n");				exit(0);			}			seekhere += maystart-seekstart;		}		if (locc<0)		{       outsw=0;        /* turn off output              */			seekhere += 3;  /* -1<delimiter>                */			return;		}		if (sect!=5 || (locc>0 && locc<100))		{       if (oldloc!=locc)/* starting a new message       */				seekstart=maystart;			oldloc=locc;		}		FLUSHLF;                /* scan the line                */	}}rtrav()                                 /* read travel table            */{       register int locc;	register struct travlist *t;	register char *s;	char buf[12];	int len,m,n,entries;	for (oldloc= -1;;)              /* get another line             */	{       if ((locc=rnum())!=oldloc && oldloc>=0) /* end of entry */		{			t->next = 0;    /* terminate the old entry      */		/*      printf("%d:%d entries\n",oldloc,entries);       */		/*      twrite(oldloc);                                 */		}		if (locc== -1) return;		if (locc!=oldloc)        /* getting a new entry         */		{       t=travel[locc]=(struct travlist *) malloc(sizeof (struct travlist));		/*      printf("New travel list for %d\n",locc);        */			entries=0;			oldloc=locc;		}		for (s=buf;; *s++)      /* get the newloc number /ASCII */			if ((*s=next())==TAB || *s==LF) break;		*s=0;		len=length(buf)-1;      /* quad long number handling    */	/*      printf("Newloc: %s (%d chars)\n",buf,len);              */		if (len<4)              /* no "m" conditions            */		{       m=0;			n=atoi(buf);    /* newloc mod 1000 = newloc     */		}		else                    /* a long integer               */		{       n=atoi(buf+len-3);			buf[len-3]=0;   /* terminate newloc/1000        */			m=atoi(buf);		}		while (breakch!=LF)     /* only do one line at a time   */		{       if (entries++) t=t->next=(struct travlist *) malloc(sizeof (struct travlist));			t->tverb=rnum();/* get verb from the file       */			t->tloc=n;      /* table entry mod 1000         */			t->conditions=m;/* table entry / 1000           */		/*      printf("entry %d for %d\n",entries,locc);       */		}	}}#ifdef DEBUGtwrite(loq)                             /* travel options from this loc */int loq;{       register struct travlist *t;	printf("If");	speak(&ltext[loq]);	printf("then\n");	for (t=travel[loq]; t!=0; t=t->next)	{       printf("verb %d takes you to ",t->tverb);		if (t->tloc<=300)			speak(&ltext[t->tloc]);		else if (t->tloc<=500)			printf("special code %d\n",t->tloc-300);		else			rspeak(t->tloc-500);		printf("under conditions %d\n",t->conditions);	}}#endif DEBUGrvoc(){       register char *s;               /* read the vocabulary          */	register int index;	char buf[6];	for (;;)	{       index=rnum();		if (index<0) break;		for (s=buf,*s=0;; s++)  /* get the word                 */			if ((*s=next())==TAB || *s=='\n' || *s==LF				|| *s==' ') break;			/* terminate word with newline, LF, tab, blank  */		if (*s!='\n' && *s!=LF) FLUSHLF;  /* can be comments    */		*s=0;	/*      printf("\"%s\"=%d\n",buf,index);*/		vocab(buf,-2,index);	}/*	prht();	*/}rlocs()                                 /* initial object locations     */{	for (;;)	{       if ((obj=rnum())<0) break;		plac[obj]=rnum();       /* initial loc for this obj     */		if (breakch==TAB)       /* there's another entry        */			fixd[obj]=rnum();		else    fixd[obj]=0;	}}rdflt()                                 /* default verb messages        */{	for (;;)	{       if ((verb=rnum())<0) break;		actspk[verb]=rnum();	}}rliq()                                  /* liquid assets &c: cond bits  */{       register int bitnum;	for (;;)                        /* read new bit list            */	{       if ((bitnum=rnum())<0) break;		for (;;)                /* read locs for bits           */		{       cond[rnum()] |= setbit[bitnum];			if (breakch==LF) break;		}	}}rhints(){       register int hintnum,i;	hntmax=0;	for (;;)	{       if ((hintnum=rnum())<0) break;		for (i=1; i<5; i++)			hints[hintnum][i]=rnum();		if (hintnum>hntmax) hntmax=hintnum;	}}rspeak(msg)int msg;{       if (msg!=0) speak(&rtext[msg]);}mspeak(msg)int msg;{       if (msg!=0) speak(&mtext[msg]);}speak(msg)       /* read, decrypt, and print a message (not ptext)      */struct text *msg;/* msg is a pointer to seek address and length of mess */{	register char *s, nonfirst;	s = msg->seekadr;	nonfirst=0;	while (s - msg->seekadr < msg->txtlen)  /* read a line at a time */	{       tape=iotape;            /* restart decryption tape      */		while ((*s++ ^ *tape++) != TAB); /* read past loc num       */		/* assume tape is longer than location number           */		/*   plus the lookahead put together                    */		if ((*s ^ *tape) == '>' &&			(*(s+1) ^ *(tape+1)) == '$' &&			(*(s+2) ^ *(tape+2)) == '<') break;		if (blklin && !nonfirst++) putchar('\n');		do		{       if (*tape == 0) tape = iotape;/* rewind decryp tape */			putchar(*s ^ *tape);		} while ((*s++ ^ *tape++) != LF);   /* better end with LF   */	}}pspeak(m,skip) /* read, decrypt an print a ptext message              */int m;         /* msg is the number of all the p msgs for this place  */int skip;       /* assumes object 1 doesn't have prop 1, obj 2 no prop 2 &c*/{	register char *s,nonfirst;	char *numst, save;	struct text *msg;	char *tbuf;	msg = &ptext[m];	if ((tbuf=(char *) malloc(msg->txtlen + 1)) == 0) bug(108);	memcpy(tbuf, msg->seekadr, msg->txtlen + 1);   /* Room to null */	s = tbuf;	nonfirst=0;	while (s - tbuf < msg->txtlen) /* read line at a time */	{       tape=iotape;            /* restart decryption tape      */		for (numst=s; (*s^= *tape++)!=TAB; s++); /* get number  */		save = *s; /* Temporarily trash the string (cringe) */		*s++ = 0; /* decrypting number within the string          */		if (atoi(numst) != 100 * skip && skip >= 0)		{       while ((*s++^*tape++)!=LF) /* flush the line    */				if (*tape==0) tape=iotape;			continue;		}		if ((*s^*tape)=='>' && (*(s+1)^*(tape+1))=='$' &&			(*(s+2)^*(tape+2))=='<') break;		if (blklin && ! nonfirst++) putchar('\n');		do		{       if (*tape==0) tape=iotape;			putchar(*s^*tape);		} while ((*s++^*tape++)!=LF);   /* better end with LF   */		if (skip<0) break;	}	free(tbuf);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -