mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-01 08:27:59 +00:00
Merge a bunch of cleanups from NetBSD.
PR: 8083 Submitted by: Stephen J. Roznowski <sjr@home.net> Obtained from: a whole slew of NetBSD PRs
This commit is contained in:
parent
f1cb6ca392
commit
af71cfbb87
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=45801
@ -39,9 +39,9 @@ static char sccsid[] = "@(#)crc.c 8.1 (Berkeley) 5/31/93";
|
||||
static char ORIGINAL_sccsid[] = "@(#)crc.c 5.2 (Berkeley) 4/4/91";
|
||||
#endif /* not lint */
|
||||
|
||||
typedef unsigned long u_long;
|
||||
#include <sys/types.h>
|
||||
|
||||
u_long crctab[] = {
|
||||
const u_long crctab[] = {
|
||||
0x7fffffff,
|
||||
0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
|
||||
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e,
|
||||
@ -105,7 +105,7 @@ u_long crctab[] = {
|
||||
*/
|
||||
|
||||
u_long crcval;
|
||||
int step;
|
||||
u_int step;
|
||||
|
||||
crc_start()
|
||||
{
|
||||
@ -113,11 +113,11 @@ crc_start()
|
||||
}
|
||||
|
||||
u_long crc(ptr, nr) /* Process nr bytes at a time; ptr points to them */
|
||||
char *ptr;
|
||||
const char *ptr;
|
||||
int nr;
|
||||
{
|
||||
register int i;
|
||||
register char *p;
|
||||
register const char *p;
|
||||
|
||||
while (nr > 0)
|
||||
for (p = ptr; nr--; ++p)
|
||||
|
@ -109,6 +109,7 @@ int entry; /* entry=2 means goto 20000 */ /* 3=19000 */
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
die(entry) /* label 90 */
|
||||
int entry;
|
||||
{ register int i;
|
||||
@ -135,5 +136,4 @@ int entry;
|
||||
}
|
||||
loc=3;
|
||||
oldloc=loc;
|
||||
return(2000);
|
||||
}
|
||||
|
@ -53,15 +53,16 @@
|
||||
|
||||
/* hdr.h: included by c advent files */
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
|
||||
int datfd; /* message file descriptor */
|
||||
int delhit;
|
||||
volatile sig_atomic_t delhit;
|
||||
int yea;
|
||||
extern char data_file[]; /* Virtual data file */
|
||||
|
||||
#define TAB 011
|
||||
#define LF 012
|
||||
#define FLUSHLINE while (getchar()!='\n')
|
||||
#define FLUSHLINE do { int flushline_ch; while ((flushline_ch = getchar()) != EOF && flushline_ch != '\n'); } while (0)
|
||||
#define FLUSHLF while (next()!=LF)
|
||||
|
||||
int loc,newloc,oldloc,oldlc2,wzdark,gaveup,kq,k,k2;
|
||||
|
@ -197,14 +197,14 @@ linkdata() /* secondary data manipulation */
|
||||
|
||||
|
||||
trapdel() /* come here if he hits a del */
|
||||
{ delhit++; /* main checks, treats as QUIT */
|
||||
{ delhit = 1; /* main checks, treats as QUIT */
|
||||
signal(2,trapdel); /* catch subsequent DELs */
|
||||
}
|
||||
|
||||
|
||||
startup()
|
||||
{
|
||||
demo=Start(0);
|
||||
demo=Start();
|
||||
srandomdev();
|
||||
hinted[3]=yes(65,1,0);
|
||||
newloc=1;
|
||||
|
@ -46,6 +46,7 @@ static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93";
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <err.h>
|
||||
|
||||
|
||||
getin(wrd1,wrd2) /* get command from user */
|
||||
@ -78,6 +79,9 @@ char **wrd1,**wrd2; /* no prompt, usually */
|
||||
*s=0;
|
||||
return;
|
||||
}
|
||||
case EOF:
|
||||
printf("user closed input stream, quitting...\n");
|
||||
exit(0);
|
||||
default:
|
||||
if (++numch>=MAXSTR) /* string too long */
|
||||
{ printf("Give me a break!!\n");
|
||||
@ -90,27 +94,19 @@ char **wrd1,**wrd2; /* no prompt, usually */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
confirm(mesg) /* confirm irreversible action */
|
||||
char *mesg;
|
||||
{ register int result;
|
||||
printf("%s",mesg); /* tell him what he did */
|
||||
if (getchar()=='y') /* was his first letter a 'y'? */
|
||||
result=1;
|
||||
else result=0;
|
||||
FLUSHLINE;
|
||||
return(result);
|
||||
}
|
||||
|
||||
yes(x,y,z) /* confirm with rspeak */
|
||||
int x,y,z;
|
||||
{ register int result;
|
||||
register char ch;
|
||||
int ch;
|
||||
for (;;)
|
||||
{ rspeak(x); /* tell him what we want*/
|
||||
if ((ch=getchar())=='y')
|
||||
result=TRUE;
|
||||
else if (ch=='n') result=FALSE;
|
||||
else if (ch == EOF) {
|
||||
printf("user closed input stream, quitting...\n");
|
||||
exit(0);
|
||||
}
|
||||
FLUSHLINE;
|
||||
if (ch=='y'|| ch=='n') break;
|
||||
printf("Please answer the question.\n");
|
||||
@ -123,12 +119,16 @@ int x,y,z;
|
||||
yesm(x,y,z) /* confirm with mspeak */
|
||||
int x,y,z;
|
||||
{ register int result;
|
||||
register char ch;
|
||||
int ch;
|
||||
for (;;)
|
||||
{ mspeak(x); /* tell him what we want*/
|
||||
if ((ch=getchar())=='y')
|
||||
result=TRUE;
|
||||
else if (ch=='n') result=FALSE;
|
||||
else if (ch == EOF) {
|
||||
printf("user closed input stream, quitting...\n");
|
||||
exit(0);
|
||||
}
|
||||
FLUSHLINE;
|
||||
if (ch=='y'|| ch=='n') break;
|
||||
printf("Please answer the question.\n");
|
||||
@ -144,8 +144,8 @@ char *inptr; /* Pointer into virtual disk */
|
||||
|
||||
int outsw = 0; /* putting stuff to data file? */
|
||||
|
||||
char iotape[] = "Ax3F'\003tt$8h\315qer*h\017nGKrX\207:!l";
|
||||
char *tape = iotape; /* pointer to encryption tape */
|
||||
const char iotape[] = "Ax3F'\003tt$8h\315qer*h\017nGKrX\207:!l";
|
||||
const char *tape = iotape; /* pointer to encryption tape */
|
||||
|
||||
next() /* next virtual char, bump adr */
|
||||
{
|
||||
@ -274,8 +274,7 @@ int sect;
|
||||
break;
|
||||
case 6: /* random messages */
|
||||
if (oldloc>RTXSIZ)
|
||||
{ printf("Too many random msgs\n");
|
||||
exit(0);
|
||||
{ errx(1, "Too many random msgs");
|
||||
}
|
||||
rtext[oldloc].seekadr=seekhere;
|
||||
rtext[oldloc].txtlen=maystart-seekstart;
|
||||
@ -287,15 +286,13 @@ int sect;
|
||||
break;
|
||||
case 12: /* magic messages */
|
||||
if (oldloc>MAGSIZ)
|
||||
{ printf("Too many magic msgs\n");
|
||||
exit(0);
|
||||
{ errx(1, "Too many magic msgs");
|
||||
}
|
||||
mtext[oldloc].seekadr=seekhere;
|
||||
mtext[oldloc].txtlen=maystart-seekstart;
|
||||
break;
|
||||
default:
|
||||
printf("rdesc called with bad section\n");
|
||||
exit(0);
|
||||
errx(1, "rdesc called with bad section");
|
||||
}
|
||||
seekhere += maystart-seekstart;
|
||||
}
|
||||
@ -331,13 +328,15 @@ rtrav() /* read travel table */
|
||||
if (locc!=oldloc) /* getting a new entry */
|
||||
{ t=travel[locc]=(struct travlist *) malloc(sizeof (struct travlist));
|
||||
/* printf("New travel list for %d\n",locc); */
|
||||
if (t == NULL)
|
||||
errx(1, "Out of memory!");
|
||||
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 */
|
||||
len=strlen(buf); /* quad long number handling */
|
||||
/* printf("Newloc: %s (%d chars)\n",buf,len); */
|
||||
if (len<4) /* no "m" conditions */
|
||||
{ m=0;
|
||||
@ -349,7 +348,11 @@ rtrav() /* read travel table */
|
||||
m=atoi(buf);
|
||||
}
|
||||
while (breakch!=LF) /* only do one line at a time */
|
||||
{ if (entries++) t=t->next=(struct travlist *) malloc(sizeof (struct travlist));
|
||||
{ if (entries++) {
|
||||
t=t->next=(struct travlist *) malloc(sizeof (struct travlist));
|
||||
if (t == NULL)
|
||||
errx(1, "Out of memory!");
|
||||
}
|
||||
t->tverb=rnum();/* get verb from the file */
|
||||
t->tloc=n; /* table entry mod 1000 */
|
||||
t->conditions=m;/* table entry / 1000 */
|
||||
@ -453,7 +456,7 @@ int 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 */
|
||||
const struct text *msg;/* msg is a pointer to seek address and length of mess */
|
||||
{
|
||||
register char *s, nonfirst;
|
||||
|
||||
@ -486,7 +489,8 @@ int skip; /* assumes object 1 doesn't have prop 1, obj 2 no prop 2 &c*/
|
||||
char *tbuf;
|
||||
|
||||
msg = &ptext[m];
|
||||
if ((tbuf=(char *) malloc(msg->txtlen + 1)) == 0) bug(108);
|
||||
if ((tbuf=(char *) malloc(msg->txtlen + 1)) == 0)
|
||||
errx(1, "Out of memory!");
|
||||
memcpy(tbuf, msg->seekadr, msg->txtlen + 1); /* Room to null */
|
||||
s = tbuf;
|
||||
|
||||
|
@ -51,6 +51,7 @@ static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/2/93";
|
||||
#include <sys/file.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "hdr.h"
|
||||
|
||||
|
||||
@ -68,7 +69,7 @@ char **argv;
|
||||
setgid(getgid());
|
||||
|
||||
init(); /* Initialize everything */
|
||||
signal(2,trapdel);
|
||||
signal(SIGINT,trapdel);
|
||||
|
||||
if (argc > 1) /* Restore file specified */
|
||||
{ /* Restart is label 8305 (Fortran) */
|
||||
@ -76,15 +77,15 @@ char **argv;
|
||||
switch(i)
|
||||
{
|
||||
case 0: /* The restore worked fine */
|
||||
yea=Start(0);
|
||||
yea=Start();
|
||||
k=null;
|
||||
unlink(argv[1]);/* Don't re-use the save */
|
||||
goto l8; /* Get where we're going */
|
||||
case 1: /* Couldn't open it */
|
||||
exit(0); /* So give up */
|
||||
exit(1); /* So give up */
|
||||
case 2: /* Oops -- file was altered */
|
||||
rspeak(202); /* You dissolve */
|
||||
exit(0); /* File could be non-adventure */
|
||||
exit(1); /* File could be non-adventure */
|
||||
} /* So don't unlink it. */
|
||||
}
|
||||
|
||||
@ -105,7 +106,7 @@ char **argv;
|
||||
kk = &stext[loc];
|
||||
if ((abb[loc]%abbnum)==0 || kk->seekadr==0)
|
||||
kk = <ext[loc];
|
||||
if (!forced(loc) && dark(0))
|
||||
if (!forced(loc) && dark())
|
||||
{ if (wzdark && pct(35))
|
||||
{ die(90);
|
||||
goto l2000;
|
||||
@ -118,7 +119,7 @@ char **argv;
|
||||
if (forced(loc))
|
||||
goto l8;
|
||||
if (loc==33 && pct(25)&&!closng) rspeak(8);
|
||||
if (!dark(0))
|
||||
if (!dark())
|
||||
{ abb[loc]++;
|
||||
for (i=atloc[loc]; i!=0; i=linkx[i]) /*2004 */
|
||||
{ obj=i;
|
||||
@ -153,12 +154,12 @@ char **argv;
|
||||
if (toting(i)&&prop[i]<0) /*2604 */
|
||||
prop[i] = -1-prop[i];
|
||||
}
|
||||
wzdark=dark(0); /* 2605 */
|
||||
wzdark=dark(); /* 2605 */
|
||||
if (knfloc>0 && knfloc!=loc) knfloc=1;
|
||||
getin(&wd1,&wd2);
|
||||
if (delhit) /* user typed a DEL */
|
||||
{ delhit=0; /* reset counter */
|
||||
copystr("quit",wd1); /* pretend he's quitting*/
|
||||
strcpy(wd1,"quit"); /* pretend he's quitting*/
|
||||
*wd2=0;
|
||||
}
|
||||
l2608: if ((foobar = -foobar)>0) foobar=0; /* 2608 */
|
||||
@ -210,16 +211,16 @@ char **argv;
|
||||
}
|
||||
l19999: k=43;
|
||||
if (liqloc(loc)==water) k=70;
|
||||
if (weq(wd1,"enter") &&
|
||||
(weq(wd2,"strea")||weq(wd2,"water")))
|
||||
if (!strncmp(wd1,"enter",5) &&
|
||||
(!strncmp(wd2,"strea",5)||!strncmp(wd2,"water",5)))
|
||||
goto l2010;
|
||||
if (weq(wd1,"enter") && *wd2!=0) goto l2800;
|
||||
if ((!weq(wd1,"water")&&!weq(wd1,"oil"))
|
||||
|| (!weq(wd2,"plant")&&!weq(wd2,"door")))
|
||||
if (!strncmp(wd1,"enter",5) && *wd2!=0) goto l2800;
|
||||
if ((strncmp(wd1,"water",5)&&strncmp(wd1,"oil",3))
|
||||
|| (strncmp(wd2,"plant",5)&&strncmp(wd2,"door",4)))
|
||||
goto l2610;
|
||||
if (at(vocab(wd2,1))) copystr("pour",wd2);
|
||||
if (at(vocab(wd2,1))) strcpy(wd2,"pour");
|
||||
|
||||
l2610: if (weq(wd1,"west"))
|
||||
l2610: if (!strncmp(wd1,"west",4))
|
||||
if (++iwest==10) rspeak(17);
|
||||
l2630: i=vocab(wd1,-1);
|
||||
if (i== -1)
|
||||
@ -237,22 +238,19 @@ char **argv;
|
||||
case 3: goto l4000;
|
||||
case 4: goto l2010;
|
||||
default:
|
||||
printf("Error 22\n");
|
||||
exit(0);
|
||||
bug(22);
|
||||
}
|
||||
|
||||
l8:
|
||||
switch(march())
|
||||
{ case 2: continue; /* i.e. goto l2 */
|
||||
case 99:
|
||||
switch(die(99))
|
||||
{ case 2000: goto l2000;
|
||||
default: bug(111);
|
||||
}
|
||||
die(99);
|
||||
goto l2000;
|
||||
default: bug(110);
|
||||
}
|
||||
|
||||
l2800: copystr(wd2,wd1);
|
||||
l2800: strcpy(wd1,wd2);
|
||||
*wd2=0;
|
||||
goto l2610;
|
||||
|
||||
@ -355,7 +353,7 @@ char **argv;
|
||||
if (here(tablet)) obj=obj*100+tablet;
|
||||
if (here(messag)) obj=obj*100+messag;
|
||||
if (closed&&toting(oyster)) obj=oyster;
|
||||
if (obj>100||obj==0||dark(0)) goto l8000;
|
||||
if (obj>100||obj==0||dark()) goto l8000;
|
||||
goto l9270;
|
||||
case 30: /* suspend=8300 */
|
||||
spk=201;
|
||||
@ -366,7 +364,7 @@ char **argv;
|
||||
printf(" %d minutes before continuing.",latncy);
|
||||
if (!yes(200,54,54)) goto l2012;
|
||||
datime(&saved,&savet);
|
||||
ciao(argv[0]); /* Do we quit? */
|
||||
ciao(); /* Do we quit? */
|
||||
continue; /* Maybe not */
|
||||
case 31: /* hours=8310 */
|
||||
printf("Colossal cave is closed 9am-5pm Mon ");
|
||||
@ -418,7 +416,7 @@ char **argv;
|
||||
l9080: if (!here(lamp)) goto l2011;
|
||||
prop[lamp]=0;
|
||||
rspeak(40);
|
||||
if (dark(0)) rspeak(16);
|
||||
if (dark()) rspeak(16);
|
||||
goto l2012;
|
||||
|
||||
case 9: /* wave */
|
||||
@ -443,7 +441,7 @@ char **argv;
|
||||
default: bug(112);
|
||||
}
|
||||
l9130: case 13: /* pour */
|
||||
if (obj==bottle||obj==0) obj=liq(0);
|
||||
if (obj==bottle||obj==0) obj=liq();
|
||||
if (obj==0) goto l8000;
|
||||
if (!toting(obj)) goto l2011;
|
||||
spk=78;
|
||||
@ -472,10 +470,10 @@ char **argv;
|
||||
||obj==bear) spk=71;
|
||||
goto l2011;
|
||||
l9150: case 15: /* 9150 - drink */
|
||||
if (obj==0&&liqloc(loc)!=water&&(liq(0)!=water
|
||||
if (obj==0&&liqloc(loc)!=water&&(liq()!=water
|
||||
||!here(bottle))) goto l8000;
|
||||
if (obj!=0&&obj!=water) spk=110;
|
||||
if (spk==110||liq(0)!=water||!here(bottle))
|
||||
if (spk==110||liq()!=water||!here(bottle))
|
||||
goto l2011;
|
||||
prop[bottle]=1;
|
||||
place[water]=0;
|
||||
@ -494,7 +492,7 @@ char **argv;
|
||||
default: bug(113);
|
||||
}
|
||||
case 19: case 20: /* 9190: find, invent */
|
||||
if (at(obj)||(liq(0)==obj&&at(bottle))
|
||||
if (at(obj)||(liq()==obj&&at(bottle))
|
||||
||k==liqloc(loc)) spk=94;
|
||||
for (i=1; i<=5; i++)
|
||||
if (dloc[i]==loc&&dflag>=2&&obj==dwarf)
|
||||
@ -522,7 +520,7 @@ char **argv;
|
||||
rspeak(bonus);
|
||||
done(2);
|
||||
l9270: case 27: /* read */
|
||||
if (dark(0)) goto l5190;
|
||||
if (dark()) goto l5190;
|
||||
if (obj==magzin) spk=190;
|
||||
if (obj==tablet) spk=196;
|
||||
if (obj==messag) spk=191;
|
||||
@ -566,7 +564,7 @@ char **argv;
|
||||
l5110: if (k!=dwarf) goto l5120;
|
||||
for (i=1; i<=5; i++)
|
||||
if (dloc[i]==loc&&dflag>=2) goto l5010;
|
||||
l5120: if ((liq(0)==k&&here(bottle))||k==liqloc(loc)) goto l5010;
|
||||
l5120: if ((liq()==k&&here(bottle))||k==liqloc(loc)) goto l5010;
|
||||
if (obj!=plant||!at(plant2)||prop[plant2]==0) goto l5130;
|
||||
obj=plant2;
|
||||
goto l5010;
|
||||
|
@ -118,7 +118,7 @@ struct savestruct save_array[] =
|
||||
};
|
||||
|
||||
save(outfile) /* Two passes on data: first to get checksum, second */
|
||||
char *outfile; /* to output the data using checksum to start random #s */
|
||||
const char *outfile; /* to output the data using checksum to start random #s */
|
||||
{
|
||||
FILE *out;
|
||||
struct savestruct *p;
|
||||
@ -151,7 +151,7 @@ char *outfile; /* to output the data using checksum to start random #s */
|
||||
}
|
||||
|
||||
restore(infile)
|
||||
char *infile;
|
||||
const char *infile;
|
||||
{
|
||||
FILE *in;
|
||||
struct savestruct *p;
|
||||
|
@ -59,15 +59,14 @@ static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include "hdr.h" /* SEED lives in there; keep them coordinated. */
|
||||
|
||||
#define USAGE "Usage: setup file > data.c (file is typically glorkz)\n"
|
||||
#define USAGE "Usage: setup file > data.c (file is typically glorkz)"
|
||||
|
||||
#define YES 1
|
||||
#define NO 0
|
||||
|
||||
void fatal();
|
||||
|
||||
#define LINE 10 /* How many values do we get on a line? */
|
||||
|
||||
main(argc, argv)
|
||||
@ -77,10 +76,10 @@ char *argv[];
|
||||
FILE *infile;
|
||||
int c, count, linestart;
|
||||
|
||||
if (argc != 2) fatal(USAGE);
|
||||
if (argc != 2) errx(1, USAGE);
|
||||
|
||||
if ((infile = fopen(argv[1], "r")) == NULL)
|
||||
fatal("Can't read file %s.\n", argv[1]);
|
||||
err(1, "Can't read file %s", argv[1]);
|
||||
puts("/*\n * data.c: created by setup from the ascii data file.");
|
||||
puts(SIG1);
|
||||
puts(SIG2);
|
||||
@ -118,11 +117,3 @@ char *argv[];
|
||||
fclose(infile);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
void fatal(format, arg)
|
||||
char *format;
|
||||
{
|
||||
fprintf(stderr, format, arg);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 5/31/93";
|
||||
/* Re-coding of advent in C: subroutines from main */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
# include "hdr.h"
|
||||
|
||||
/* Statement functions */
|
||||
@ -69,7 +70,7 @@ int pbotl;
|
||||
{ return((1-pbotl)*water+(pbotl/2)*(water+oil));
|
||||
}
|
||||
|
||||
liq(foo)
|
||||
liq()
|
||||
{ register int i;
|
||||
i=prop[bottle];
|
||||
if (i>-1-i) return(liq2(i));
|
||||
@ -98,7 +99,7 @@ int locc;
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
dark(foo)
|
||||
dark()
|
||||
{ if ((cond[loc]%2)==0 && (prop[lamp]==0 || !here(lamp)))
|
||||
return(TRUE);
|
||||
return(FALSE);
|
||||
@ -373,6 +374,7 @@ trbridge() /* 30300 */
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
badmove() /* 20 */
|
||||
{ spk=12;
|
||||
if (k>=43 && k<=50) spk=9;
|
||||
@ -383,16 +385,17 @@ badmove() /* 20 */
|
||||
if (k==62||k==65) spk=42;
|
||||
if (k==17) spk=80;
|
||||
rspeak(spk);
|
||||
return(2);
|
||||
}
|
||||
|
||||
int
|
||||
bug(n)
|
||||
int n;
|
||||
{ printf("Please tell jim@rand.org that fatal bug %d happened.\n",n);
|
||||
exit(0);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
checkhints() /* 2600 &c */
|
||||
{ register int hint;
|
||||
for (hint=4; hint<=hntmax; hint++)
|
||||
@ -433,7 +436,7 @@ checkhints() /* 2600 &c */
|
||||
|
||||
trsay() /* 9030 */
|
||||
{ register int i;
|
||||
if (*wd2!=0) copystr(wd2,wd1);
|
||||
if (*wd2!=0) strcpy(wd1,wd2);
|
||||
i=vocab(wd1,-1);
|
||||
if (i==62||i==65||i==71||i==2025)
|
||||
{ *wd2=0;
|
||||
@ -454,7 +457,7 @@ trtake() /* 9010 */
|
||||
if (obj==chain&&prop[bear]!=0) spk=170;
|
||||
if (fixed[obj]!=0) return(2011);
|
||||
if (obj==water||obj==oil)
|
||||
{ if (here(bottle)&&liq(0)==obj)
|
||||
{ if (here(bottle)&&liq()==obj)
|
||||
{ obj=bottle;
|
||||
goto l9017;
|
||||
}
|
||||
@ -484,14 +487,14 @@ l9017: if (holdng>=7)
|
||||
l9014: if ((obj==bird||obj==cage)&&prop[bird]!=0)
|
||||
carry(bird+cage-obj,loc);
|
||||
carry(obj,loc);
|
||||
k=liq(0);
|
||||
k=liq();
|
||||
if (obj==bottle && k!=0) place[k] = -1;
|
||||
return(2009);
|
||||
}
|
||||
|
||||
|
||||
dropper() /* 9021 */
|
||||
{ k=liq(0);
|
||||
{ k=liq();
|
||||
if (k==obj) obj=bottle;
|
||||
if (obj==bottle&&k!=0) place[k]=0;
|
||||
if (obj==cage&&prop[bird]!=0) drop(bird,loc);
|
||||
@ -640,7 +643,7 @@ trkill() /* 9120 */
|
||||
verb=0;
|
||||
obj=0;
|
||||
getin(&wd1,&wd2);
|
||||
if (!weq(wd1,"y")&&!weq(wd1,"yes")) return(2608);
|
||||
if (strncmp(wd1,"y",1)&&strncmp(wd1,"yes",3)) return(2608);
|
||||
pspeak(dragon,1);
|
||||
prop[dragon]=2;
|
||||
prop[rug]=0;
|
||||
@ -764,16 +767,17 @@ trfill() /* 9220 */
|
||||
if (obj==0&&!here(bottle)) return(8000);
|
||||
spk=107;
|
||||
if (liqloc(loc)==0) spk=106;
|
||||
if (liq(0)!=0) spk=105;
|
||||
if (liq()!=0) spk=105;
|
||||
if (spk!=107) return(2011);
|
||||
prop[bottle]=((cond[loc]%4)/2)*2;
|
||||
k=liq(0);
|
||||
k=liq();
|
||||
if (toting(bottle)) place[k]= -1;
|
||||
if (k==oil) spk=108;
|
||||
return(2011);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
closing() /* 10000 */
|
||||
{ register int i;
|
||||
|
||||
@ -795,10 +799,10 @@ closing() /* 10000 */
|
||||
rspeak(129);
|
||||
clock1 = -1;
|
||||
closng=TRUE;
|
||||
return(19999);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
caveclose() /* 11000 */
|
||||
{ register int i;
|
||||
prop[bottle]=put(bottle,115,1);
|
||||
@ -825,5 +829,4 @@ caveclose() /* 11000 */
|
||||
if (toting(i)) dstroy(i);
|
||||
rspeak(132);
|
||||
closed=TRUE;
|
||||
return(2);
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ static char sccsid[] = "@(#)vocab.c 8.1 (Berkeley) 5/31/93";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include "hdr.h"
|
||||
|
||||
dstroy(object)
|
||||
@ -113,11 +114,12 @@ int object,where;
|
||||
|
||||
|
||||
vocab(word,type,value) /* look up or store a word */
|
||||
char *word;
|
||||
const char *word;
|
||||
int type; /* -2 for store, -1 for user word, >=0 for canned lookup*/
|
||||
int value; /* used for storing only */
|
||||
{ register int adr;
|
||||
register char *s,*t;
|
||||
const char *s;
|
||||
register char *t;
|
||||
int hash, i;
|
||||
struct hashtab *h;
|
||||
|
||||
@ -134,13 +136,15 @@ int value; /* used for storing only */
|
||||
if (h->val) /* already got an entry? */
|
||||
goto exitloop2;
|
||||
h->val=value;
|
||||
h->atab=malloc(length(word));
|
||||
h->atab=malloc(strlen(word)+1);
|
||||
if (h->atab == NULL)
|
||||
errx(1, "Out of memory!");
|
||||
for (s=word,t=h->atab; *s;)
|
||||
*t++ = *s++ ^ '=';
|
||||
*t=0^'=';
|
||||
/* encrypt slightly to thwart core reader */
|
||||
/* printf("Stored \"%s\" (%d ch) as entry %d\n", */
|
||||
/* word, length(word), adr); */
|
||||
/* word, strlen(word)+1, adr); */
|
||||
return(0); /* entry unused */
|
||||
case -1: /* looking up user word */
|
||||
if (h->val==0) return(-1); /* not found */
|
||||
@ -152,8 +156,7 @@ int value; /* used for storing only */
|
||||
return(h->val);
|
||||
default: /* looking up known word */
|
||||
if (h->val==0)
|
||||
{ printf("Unable to find %s in vocab\n",word);
|
||||
exit(0);
|
||||
{ errx(1, "Unable to find %s in vocab", word);
|
||||
}
|
||||
for (s=word, t=h->atab;*t ^ '=';)
|
||||
if ((*s++ ^ '=') != *t++) goto exitloop2;
|
||||
@ -164,44 +167,11 @@ int value; /* used for storing only */
|
||||
|
||||
exitloop2: /* hashed entry does not match */
|
||||
if (adr+1==hash || (adr==HTSIZE && hash==0))
|
||||
{ printf("Hash table overflow\n");
|
||||
exit(0);
|
||||
{ errx(1, "Hash table overflow");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
copystr(w1,w2) /* copy one string to another */
|
||||
char *w1,*w2;
|
||||
{ register char *s,*t;
|
||||
for (s=w1,t=w2; *s;)
|
||||
*t++ = *s++;
|
||||
*t=0;
|
||||
}
|
||||
|
||||
weq(w1,w2) /* compare words */
|
||||
char *w1,*w2; /* w1 is user, w2 is system */
|
||||
{ register char *s,*t;
|
||||
register int i;
|
||||
s=w1;
|
||||
t=w2;
|
||||
for (i=0; i<5; i++) /* compare at most 5 chars */
|
||||
{ if (*t==0 && *s==0)
|
||||
return(TRUE);
|
||||
if (*s++ != *t++) return(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
length(str) /* includes 0 at end */
|
||||
char *str;
|
||||
{ register char *s;
|
||||
register int n;
|
||||
for (n=0,s=str; *s++;) n++;
|
||||
return(n+1);
|
||||
}
|
||||
|
||||
prht() /* print hash table */
|
||||
{ register int i,j,l;
|
||||
char *c;
|
||||
|
@ -56,9 +56,15 @@ int *d,*t;
|
||||
|
||||
time(&tvec);
|
||||
tptr=localtime(&tvec);
|
||||
*d=tptr->tm_yday+365*(tptr->tm_year-77); /* day since 1977 (mod leap) */
|
||||
*t=tptr->tm_hour*60+tptr->tm_min; /* and minutes since midnite */
|
||||
} /* pretty painless */
|
||||
/* day since 1977 */
|
||||
*d = (tptr->tm_yday + 365 * (tptr->tm_year - 77)
|
||||
+ (tptr->tm_year - 77) / 4 - (tptr->tm_year - 1) / 100
|
||||
+ (tptr->tm_year + 299) / 400);
|
||||
/* bug: this will overflow in the year 2066 AD (with 16 bit int) */
|
||||
/* it will be attributed to Wm the C's millenial celebration */
|
||||
/* and minutes since midnite */
|
||||
*t=tptr->tm_hour*60+tptr->tm_min;
|
||||
}
|
||||
|
||||
|
||||
char magic[6];
|
||||
@ -69,7 +75,7 @@ poof()
|
||||
latncy = 45;
|
||||
}
|
||||
|
||||
Start(n)
|
||||
Start()
|
||||
{ int d,t,delay;
|
||||
|
||||
datime(&d,&t);
|
||||
@ -100,7 +106,7 @@ wizard() /* not as complex as advent/10 (for now) */
|
||||
if (!yesm(16,0,7)) return(FALSE);
|
||||
mspeak(17);
|
||||
getin(&word,&x);
|
||||
if (!weq(word,magic))
|
||||
if (strncmp(word,magic,5))
|
||||
{ mspeak(20);
|
||||
return(FALSE);
|
||||
}
|
||||
@ -108,16 +114,21 @@ wizard() /* not as complex as advent/10 (for now) */
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
ciao(cmdfile)
|
||||
char *cmdfile;
|
||||
ciao()
|
||||
{ register char *c;
|
||||
register int outfd, size;
|
||||
char fname[80], buf[512];
|
||||
extern unsigned filesize;
|
||||
|
||||
printf("What would you like to call the saved version?\n");
|
||||
for (c=fname;; c++)
|
||||
if ((*c=getchar())=='\n') break;
|
||||
/* XXX - should use fgetln to avoid arbitrary limit */
|
||||
for (c = fname; c < fname + sizeof fname - 1; c++) {
|
||||
int ch;
|
||||
ch = getchar();
|
||||
if (ch == '\n' || ch == EOF)
|
||||
break;
|
||||
*c = ch;
|
||||
}
|
||||
*c=0;
|
||||
if (save(fname) != 0) return; /* Save failed */
|
||||
printf("To resume, say \"adventure %s\".\n", fname);
|
||||
|
@ -79,9 +79,9 @@ static char sccsid[] = "@(#)arithmetic.c 8.1 (Berkeley) 5/31/93";
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
char keylist[] = "+-x/";
|
||||
char defaultkeys[] = "+-";
|
||||
char *keys = defaultkeys;
|
||||
const char keylist[] = "+-x/";
|
||||
const char defaultkeys[] = "+-";
|
||||
const char *keys = defaultkeys;
|
||||
int nkeys = sizeof(defaultkeys) - 1;
|
||||
int rangemax = 10;
|
||||
int nright, nwrong;
|
||||
@ -105,10 +105,13 @@ main(argc, argv)
|
||||
int ch, cnt;
|
||||
void intr();
|
||||
|
||||
/* Revoke setgid privileges */
|
||||
setgid(getgid());
|
||||
|
||||
while ((ch = getopt(argc, argv, "r:o:")) != -1)
|
||||
switch(ch) {
|
||||
case 'o': {
|
||||
register char *p;
|
||||
register const char *p;
|
||||
|
||||
for (p = keys = optarg; *p; ++p)
|
||||
if (!index(keylist, *p)) {
|
||||
|
@ -13,7 +13,5 @@ HIDEGAME=hidegame
|
||||
beforeinstall:
|
||||
(cd ${.CURDIR}/games; ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 440 \
|
||||
${GAMES} ${DESTDIR}${SHAREDIR}/games/atc)
|
||||
${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 664 ${.CURDIR}/games/ATC_scores \
|
||||
${DESTDIR}/var/games/atc_score
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -47,7 +47,9 @@
|
||||
|
||||
#define AUTHOR_STR "ATC - by Ed James"
|
||||
|
||||
#define PI 3.14159654
|
||||
#ifndef PI
|
||||
#define PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#define LOWFUEL 15
|
||||
|
||||
|
@ -53,7 +53,7 @@ char GAMES[] = "Game_List";
|
||||
|
||||
int clck, safe_planes, start_time, test_mode;
|
||||
|
||||
char *file;
|
||||
const char *file;
|
||||
|
||||
FILE *filein, *fileout;
|
||||
|
||||
|
@ -45,7 +45,8 @@
|
||||
* For more info on this and all of my stuff, mail edjames@berkeley.edu.
|
||||
*/
|
||||
|
||||
extern char GAMES[], *file;
|
||||
extern char GAMES[];
|
||||
extern const char *file;
|
||||
|
||||
extern int clck, safe_planes, start_time, test_mode;
|
||||
|
||||
|
@ -122,10 +122,11 @@ init_gr()
|
||||
}
|
||||
|
||||
setup_screen(scp)
|
||||
C_SCREEN *scp;
|
||||
const C_SCREEN *scp;
|
||||
{
|
||||
register int i, j;
|
||||
char str[3], *airstr;
|
||||
char str[3];
|
||||
const char *airstr;
|
||||
|
||||
str[2] = '\0';
|
||||
|
||||
@ -213,8 +214,9 @@ setup_screen(scp)
|
||||
}
|
||||
|
||||
draw_line(w, x, y, lx, ly, s)
|
||||
WINDOW *w;
|
||||
char *s;
|
||||
WINDOW *w;
|
||||
int x, y, lx, ly;
|
||||
const char *s;
|
||||
{
|
||||
int dx, dy;
|
||||
|
||||
@ -246,7 +248,7 @@ iomove(pos)
|
||||
}
|
||||
|
||||
ioaddstr(pos, str)
|
||||
char *str;
|
||||
const char *str;
|
||||
{
|
||||
wmove(input, 0, pos);
|
||||
waddstr(input, str);
|
||||
@ -262,7 +264,7 @@ ioclrtobot()
|
||||
}
|
||||
|
||||
ioerror(pos, len, str)
|
||||
char *str;
|
||||
const char *str;
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -359,8 +361,8 @@ planewin()
|
||||
}
|
||||
|
||||
loser(p, s)
|
||||
PLANE *p;
|
||||
char *s;
|
||||
const PLANE *p;
|
||||
const char *s;
|
||||
{
|
||||
int c;
|
||||
#ifdef BSD
|
||||
|
@ -66,10 +66,10 @@ static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 5/31/93";
|
||||
#define NUMTOKEN 257
|
||||
|
||||
typedef struct {
|
||||
int token;
|
||||
int to_state;
|
||||
char *str;
|
||||
char *(*func)();
|
||||
int token;
|
||||
int to_state;
|
||||
const char *str;
|
||||
const char *(*func)();
|
||||
} RULE;
|
||||
|
||||
typedef struct {
|
||||
@ -95,7 +95,7 @@ typedef struct {
|
||||
|
||||
#define NUMSTATES NUMELS(st)
|
||||
|
||||
char *setplane(), *circle(), *left(), *right(), *Left(), *Right(),
|
||||
const char *setplane(), *circle(), *left(), *right(), *Left(), *Right(),
|
||||
*beacon(), *ex_it(), *climb(), *descend(), *setalt(), *setrelalt(),
|
||||
*benum(), *to_dir(), *rel_dir(), *delayb(), *mark(), *unmark(),
|
||||
*airport(), *turn(), *ignore();
|
||||
@ -241,9 +241,9 @@ push(ruleno, ch)
|
||||
|
||||
getcommand()
|
||||
{
|
||||
int c, i, done;
|
||||
char *s, *(*func)();
|
||||
PLANE *pp;
|
||||
int c, i, done;
|
||||
const char *s, *(*func)();
|
||||
PLANE *pp;
|
||||
|
||||
rezero();
|
||||
|
||||
@ -368,7 +368,7 @@ gettoken()
|
||||
return (tval);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
setplane(c)
|
||||
{
|
||||
PLANE *pp;
|
||||
@ -381,7 +381,7 @@ setplane(c)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
turn(c)
|
||||
{
|
||||
if (p.altitude == 0)
|
||||
@ -389,7 +389,7 @@ turn(c)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
circle(c)
|
||||
{
|
||||
if (p.altitude == 0)
|
||||
@ -398,7 +398,7 @@ circle(c)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
left(c)
|
||||
{
|
||||
dir = D_LEFT;
|
||||
@ -408,7 +408,7 @@ left(c)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
right(c)
|
||||
{
|
||||
dir = D_RIGHT;
|
||||
@ -418,7 +418,7 @@ right(c)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
Left(c)
|
||||
{
|
||||
p.new_dir = p.dir - 2;
|
||||
@ -427,7 +427,7 @@ Left(c)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
Right(c)
|
||||
{
|
||||
p.new_dir = p.dir + 2;
|
||||
@ -436,7 +436,7 @@ Right(c)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
delayb(c)
|
||||
{
|
||||
int xdiff, ydiff;
|
||||
@ -481,42 +481,42 @@ delayb(c)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
beacon(c)
|
||||
{
|
||||
dest_type = T_BEACON;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
ex_it(c)
|
||||
{
|
||||
dest_type = T_EXIT;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
airport(c)
|
||||
{
|
||||
dest_type = T_AIRPORT;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
climb(c)
|
||||
{
|
||||
dir = D_UP;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
descend(c)
|
||||
{
|
||||
dir = D_DOWN;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
setalt(c)
|
||||
{
|
||||
if ((p.altitude == c - '0') && (p.new_altitude == p.altitude))
|
||||
@ -525,7 +525,7 @@ setalt(c)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
setrelalt(c)
|
||||
{
|
||||
if (c == 0)
|
||||
@ -549,7 +549,7 @@ setrelalt(c)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
benum(c)
|
||||
{
|
||||
dest_no = c -= '0';
|
||||
@ -580,14 +580,14 @@ benum(c)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
to_dir(c)
|
||||
{
|
||||
p.new_dir = dir_no(c);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
rel_dir(c)
|
||||
{
|
||||
int angle;
|
||||
@ -611,7 +611,7 @@ rel_dir(c)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
mark(c)
|
||||
{
|
||||
if (p.altitude == 0)
|
||||
@ -622,7 +622,7 @@ mark(c)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
unmark(c)
|
||||
{
|
||||
if (p.altitude == 0)
|
||||
@ -633,7 +633,7 @@ unmark(c)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
ignore(c)
|
||||
{
|
||||
if (p.altitude == 0)
|
||||
|
@ -51,9 +51,15 @@ static char sccsid[] = "@(#)log.c 8.1 (Berkeley) 5/31/93";
|
||||
#include "include.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
compar(a, b)
|
||||
SCORE *a, *b;
|
||||
int
|
||||
compar(va, vb)
|
||||
const void *va, *vb;
|
||||
{
|
||||
const SCORE *a, *b;
|
||||
|
||||
a = (const SCORE *)va;
|
||||
b = (const SCORE *)vb;
|
||||
|
||||
if (b->planes == a->planes)
|
||||
return (b->time - a->time);
|
||||
else
|
||||
@ -70,7 +76,7 @@ compar(a, b)
|
||||
#define MIN(t) (((t) % SECAHOUR) / SECAMIN)
|
||||
#define SEC(t) ((t) % SECAMIN)
|
||||
|
||||
char *
|
||||
const char *
|
||||
timestr(t)
|
||||
{
|
||||
static char s[80];
|
||||
@ -152,7 +158,7 @@ log_score(list_em)
|
||||
#endif
|
||||
#ifdef SYSV
|
||||
uname(&name);
|
||||
strcpy(thisscore.host, name.sysname);
|
||||
strcpy(thisscore.host, name.nodename);
|
||||
#endif
|
||||
|
||||
cp = rindex(file, '/');
|
||||
|
@ -58,17 +58,18 @@ static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
|
||||
#include "pathnames.h"
|
||||
|
||||
main(ac, av)
|
||||
int ac;
|
||||
char *av[];
|
||||
{
|
||||
int seed = 0;
|
||||
int f_usage = 0, f_list = 0, f_showscore = 0;
|
||||
int f_printpath = 0;
|
||||
char *file = NULL;
|
||||
const char *file = NULL;
|
||||
char *name, *ptr;
|
||||
#ifdef BSD
|
||||
struct itimerval itv;
|
||||
#endif
|
||||
extern char *default_game(), *okay_game();
|
||||
extern const char *default_game(), *okay_game();
|
||||
extern void log_score(), quit(), update();
|
||||
|
||||
start_time = time(0);
|
||||
@ -221,7 +222,7 @@ main(ac, av)
|
||||
}
|
||||
|
||||
read_file(s)
|
||||
char *s;
|
||||
const char *s;
|
||||
{
|
||||
extern FILE *yyin;
|
||||
int retval;
|
||||
@ -241,7 +242,7 @@ read_file(s)
|
||||
return (0);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
default_game()
|
||||
{
|
||||
FILE *fp;
|
||||
@ -266,13 +267,14 @@ default_game()
|
||||
return (file);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
okay_game(s)
|
||||
char *s;
|
||||
{
|
||||
FILE *fp;
|
||||
static char file[256];
|
||||
char *ret = NULL, line[256], games[256];
|
||||
const char *ret = NULL;
|
||||
char line[256], games[256];
|
||||
|
||||
strcpy(games, _PATH_GAMES);
|
||||
strcat(games, GAMES);
|
||||
|
@ -50,6 +50,8 @@ static char sccsid[] = "@(#)update.c 8.1 (Berkeley) 5/31/93";
|
||||
#include <string.h>
|
||||
#include "include.h"
|
||||
|
||||
char name();
|
||||
|
||||
update()
|
||||
{
|
||||
int i, dir_diff, mask, unclean;
|
||||
@ -220,9 +222,9 @@ update()
|
||||
#endif
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
command(pp)
|
||||
PLANE *pp;
|
||||
const PLANE *pp;
|
||||
{
|
||||
static char buf[50], *bp, *comm_start;
|
||||
char *index();
|
||||
@ -253,8 +255,9 @@ command(pp)
|
||||
}
|
||||
|
||||
/* char */
|
||||
char
|
||||
name(p)
|
||||
PLANE *p;
|
||||
const PLANE *p;
|
||||
{
|
||||
if (p->plane_type == 0)
|
||||
return ('A' + p->plane_no);
|
||||
@ -372,6 +375,7 @@ addplane()
|
||||
|
||||
PLANE *
|
||||
findplane(n)
|
||||
int n;
|
||||
{
|
||||
PLANE *pp;
|
||||
|
||||
@ -384,8 +388,10 @@ findplane(n)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int
|
||||
too_close(p1, p2, dist)
|
||||
PLANE *p1, *p2;
|
||||
const PLANE *p1, *p2;
|
||||
int dist;
|
||||
{
|
||||
if (ABS(p1->altitude - p2->altitude) <= dist &&
|
||||
ABS(p1->xpos - p2->xpos) <= dist && ABS(p1->ypos - p2->ypos) <= dist)
|
||||
|
@ -97,8 +97,6 @@ uses /etc/termcap
|
||||
.B -s\fIfile
|
||||
recover previously saved game from
|
||||
.IR file .
|
||||
(This can also be done by executing the saved file,
|
||||
i.e., typing its name in as a command)
|
||||
.ad
|
||||
.PP
|
||||
.PP
|
||||
|
@ -45,55 +45,48 @@ static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include "back.h"
|
||||
|
||||
#define MVPAUSE 5 /* time to sleep when stuck */
|
||||
#define MAXUSERS 35 /* maximum number of users */
|
||||
|
||||
extern char *instr[]; /* text of instructions */
|
||||
extern char *message[]; /* update message */
|
||||
extern const char *const instr[]; /* text of instructions */
|
||||
extern const char *const message[]; /* update message */
|
||||
char ospeed; /* tty output speed */
|
||||
|
||||
char *helpm[] = { /* help message */
|
||||
const char *helpm[] = { /* help message */
|
||||
"Enter a space or newline to roll, or",
|
||||
" R to reprint the board\tD to double",
|
||||
" S to save the game\tQ to quit",
|
||||
0
|
||||
};
|
||||
|
||||
char *contin[] = { /* pause message */
|
||||
const char *contin[] = { /* pause message */
|
||||
"(Type a newline to continue.)",
|
||||
"",
|
||||
0
|
||||
};
|
||||
|
||||
static char user1a[] =
|
||||
"Sorry, you cannot play backgammon when there are more than ";
|
||||
static char user1b[] =
|
||||
" users\non the system.";
|
||||
static char user2a[] =
|
||||
"\nThere are now more than ";
|
||||
static char user2b[] =
|
||||
" users on the system, so you cannot play\nanother game. ";
|
||||
static char rules[] = "\nDo you want the rules of the game?";
|
||||
static char noteach[] = "Teachgammon not available!\n\007";
|
||||
static char need[] = "Do you need instructions for this program?";
|
||||
static char askcol[] =
|
||||
static const char rules[] = "\nDo you want the rules of the game?";
|
||||
static const char noteach[] = "Teachgammon not available!\n\007";
|
||||
static const char need[] = "Do you need instructions for this program?";
|
||||
static const char askcol[] =
|
||||
"Enter 'r' to play red, 'w' to play white, 'b' to play both:";
|
||||
static char rollr[] = "Red rolls a ";
|
||||
static char rollw[] = ". White rolls a ";
|
||||
static char rstart[] = ". Red starts.\n";
|
||||
static char wstart[] = ". White starts.\n";
|
||||
static char toobad1[] = "Too bad, ";
|
||||
static char unable[] = " is unable to use that roll.\n";
|
||||
static char toobad2[] = ". Too bad, ";
|
||||
static char cantmv[] = " can't move.\n";
|
||||
static char bgammon[] = "Backgammon! ";
|
||||
static char gammon[] = "Gammon! ";
|
||||
static char again[] = ".\nWould you like to play again?";
|
||||
static char svpromt[] = "Would you like to save this game?";
|
||||
static const char rollr[] = "Red rolls a ";
|
||||
static const char rollw[] = ". White rolls a ";
|
||||
static const char rstart[] = ". Red starts.\n";
|
||||
static const char wstart[] = ". White starts.\n";
|
||||
static const char toobad1[] = "Too bad, ";
|
||||
static const char unable[] = " is unable to use that roll.\n";
|
||||
static const char toobad2[] = ". Too bad, ";
|
||||
static const char cantmv[] = " can't move.\n";
|
||||
static const char bgammon[] = "Backgammon! ";
|
||||
static const char gammon[] = "Gammon! ";
|
||||
static const char again[] = ".\nWould you like to play again?";
|
||||
static const char svpromt[] = "Would you like to save this game?";
|
||||
|
||||
static char password[] = "losfurng";
|
||||
static const char password[] = "losfurng";
|
||||
static char pbuf[10];
|
||||
|
||||
main (argc,argv)
|
||||
@ -111,7 +104,7 @@ char **argv;
|
||||
/* initialization */
|
||||
bflag = 2; /* default no board */
|
||||
acnt = 1; /* Nuber of args */
|
||||
signal (2,getout); /* trap interrupts */
|
||||
signal (SIGINT,getout); /* trap interrupts */
|
||||
if (gtty (0,&tty) == -1) /* get old tty mode */
|
||||
errexit ("backgammon(gtty)");
|
||||
old = tty.sg_flags;
|
||||
@ -122,16 +115,6 @@ char **argv;
|
||||
#endif
|
||||
ospeed = tty.sg_ospeed; /* for termlib */
|
||||
|
||||
/* check user count */
|
||||
# ifdef CORY
|
||||
if (ucount() > MAXUSERS) {
|
||||
writel (user1a);
|
||||
wrint (MAXUSERS);
|
||||
writel (user1b);
|
||||
getout();
|
||||
}
|
||||
# endif
|
||||
|
||||
/* get terminal
|
||||
* capabilities, and
|
||||
* decide if it can
|
||||
@ -222,7 +205,7 @@ char **argv;
|
||||
else
|
||||
writec ('\n');
|
||||
writel ("Password:");
|
||||
signal (14,getout);
|
||||
signal (SIGALRM,getout);
|
||||
cflag = 1;
|
||||
alarm (10);
|
||||
for (i = 0; i < 10; i++) {
|
||||
@ -550,17 +533,6 @@ char **argv;
|
||||
/* write score */
|
||||
wrscore();
|
||||
|
||||
/* check user count */
|
||||
# ifdef CORY
|
||||
if (ucount() > MAXUSERS) {
|
||||
writel (user2a);
|
||||
wrint (MAXUSERS);
|
||||
writel (user2b);
|
||||
rfl = 1;
|
||||
break;
|
||||
}
|
||||
# endif
|
||||
|
||||
/* see if he wants
|
||||
* another game */
|
||||
writel (again);
|
||||
|
@ -37,7 +37,7 @@ static char sccsid[] = "@(#)text.c 8.1 (Berkeley) 5/31/93";
|
||||
|
||||
#include "back.h"
|
||||
|
||||
char *instr[] = {
|
||||
const char *const instr[] = {
|
||||
" If you did not notice by now, this program reacts to things as",
|
||||
"soon as you type them, without waiting for a newline. This means that",
|
||||
"the special characters RUBOUT, ESC, and CONTROL-D, will not perform",
|
||||
@ -104,12 +104,13 @@ char *instr[] = {
|
||||
0};
|
||||
|
||||
|
||||
int
|
||||
text (t)
|
||||
char **t;
|
||||
const char *const *t;
|
||||
|
||||
{
|
||||
register int i;
|
||||
register char *s, *a;
|
||||
const char *s, *a;
|
||||
|
||||
fixtty (noech);
|
||||
while (*t != 0) {
|
||||
|
@ -35,7 +35,7 @@
|
||||
static char sccsid[] = "@(#)version.c 8.1 (Berkeley) 5/31/93";
|
||||
#endif /* not lint */
|
||||
|
||||
char *message[] = {
|
||||
const char *const message[] = {
|
||||
"Last updated on Saturday, January 11, 1986.",
|
||||
0
|
||||
};
|
||||
|
@ -53,75 +53,75 @@
|
||||
*
|
||||
*/
|
||||
|
||||
extern char EXEC[]; /* object for main program */
|
||||
extern char TEACH[]; /* object for tutorial program */
|
||||
extern const char EXEC[]; /* object for main program */
|
||||
extern const char TEACH[];/* object for tutorial program */
|
||||
|
||||
int pnum; /* color of player:
|
||||
extern int pnum; /* color of player:
|
||||
-1 = white
|
||||
1 = red
|
||||
0 = both
|
||||
2 = not yet init'ed */
|
||||
char *args[16]; /* args passed to teachgammon and back */
|
||||
int acnt; /* number of args */
|
||||
int aflag; /* flag to ask for rules or instructions */
|
||||
int bflag; /* flag for automatic board printing */
|
||||
int cflag; /* case conversion flag */
|
||||
int hflag; /* flag for cleaning screen */
|
||||
int mflag; /* backgammon flag */
|
||||
int raflag; /* 'roll again' flag for recovered game */
|
||||
int rflag; /* recovered game flag */
|
||||
int tflag; /* cursor addressing flag */
|
||||
int rfl; /* saved value of rflag */
|
||||
int iroll; /* special flag for inputting rolls */
|
||||
int board[26]; /* board: negative values are white,
|
||||
extern char *args[16]; /* args passed to teachgammon and back */
|
||||
extern int acnt; /* number of args */
|
||||
extern int aflag; /* flag to ask for rules or instructions */
|
||||
extern int bflag; /* flag for automatic board printing */
|
||||
extern int cflag; /* case conversion flag */
|
||||
extern int hflag; /* flag for cleaning screen */
|
||||
extern int mflag; /* backgammon flag */
|
||||
extern int raflag; /* 'roll again' flag for recovered game */
|
||||
extern int rflag; /* recovered game flag */
|
||||
extern int tflag; /* cursor addressing flag */
|
||||
extern int rfl; /* saved value of rflag */
|
||||
extern int iroll; /* special flag for inputting rolls */
|
||||
extern int board[26]; /* board: negative values are white,
|
||||
positive are red */
|
||||
int dice[2]; /* value of dice */
|
||||
int mvlim; /* 'move limit': max. number of moves */
|
||||
int mvl; /* working copy of mvlim */
|
||||
int p[5]; /* starting position of moves */
|
||||
int g[5]; /* ending position of moves (goals) */
|
||||
int h[4]; /* flag for each move if a man was hit */
|
||||
int cturn; /* whose turn it currently is:
|
||||
extern int dice[2]; /* value of dice */
|
||||
extern int mvlim; /* 'move limit': max. number of moves */
|
||||
extern int mvl; /* working copy of mvlim */
|
||||
extern int p[5]; /* starting position of moves */
|
||||
extern int g[5]; /* ending position of moves (goals) */
|
||||
extern int h[4]; /* flag for each move if a man was hit */
|
||||
extern int cturn; /* whose turn it currently is:
|
||||
-1 = white
|
||||
1 = red
|
||||
0 = just quitted
|
||||
-2 = white just lost
|
||||
2 = red just lost */
|
||||
int d0; /* flag if dice have been reversed from
|
||||
extern int d0; /* flag if dice have been reversed from
|
||||
original position */
|
||||
int table[6][6]; /* odds table for possible rolls */
|
||||
int rscore; /* red's score */
|
||||
int wscore; /* white's score */
|
||||
int gvalue; /* value of game (64 max.) */
|
||||
int dlast; /* who doubled last (0 = neither) */
|
||||
int bar; /* position of bar for current player */
|
||||
int home; /* position of home for current player */
|
||||
int off[2]; /* number of men off board */
|
||||
int *offptr; /* pointer to off for current player */
|
||||
int *offopp; /* pointer to off for opponent */
|
||||
int in[2]; /* number of men in inner table */
|
||||
int *inptr; /* pointer to in for current player */
|
||||
int *inopp; /* pointer to in for opponent */
|
||||
extern int table[6][6]; /* odds table for possible rolls */
|
||||
extern int rscore; /* red's score */
|
||||
extern int wscore; /* white's score */
|
||||
extern int gvalue; /* value of game (64 max.) */
|
||||
extern int dlast; /* who doubled last (0 = neither) */
|
||||
extern int bar; /* position of bar for current player */
|
||||
extern int home; /* position of home for current player */
|
||||
extern int off[2]; /* number of men off board */
|
||||
extern int *offptr; /* pointer to off for current player */
|
||||
extern int *offopp; /* pointer to off for opponent */
|
||||
extern int in[2]; /* number of men in inner table */
|
||||
extern int *inptr; /* pointer to in for current player */
|
||||
extern int *inopp; /* pointer to in for opponent */
|
||||
|
||||
int ncin; /* number of characters in cin */
|
||||
char cin[100]; /* input line of current move
|
||||
extern int ncin; /* number of characters in cin */
|
||||
extern char cin[100]; /* input line of current move
|
||||
(used for reconstructing input after
|
||||
a backspace) */
|
||||
|
||||
extern char *color[];
|
||||
extern const char *const color[];
|
||||
/* colors as strings */
|
||||
char **colorptr; /* color of current player */
|
||||
char **Colorptr; /* color of current player, capitalized */
|
||||
int colen; /* length of color of current player */
|
||||
extern const char *const *colorptr; /* color of current player */
|
||||
extern const char *const *Colorptr; /* color of current player, capitalized */
|
||||
extern int colen; /* length of color of current player */
|
||||
|
||||
struct sgttyb tty; /* tty information buffer */
|
||||
int old; /* original tty status */
|
||||
int noech; /* original tty status without echo */
|
||||
int raw; /* raw tty status, no echo */
|
||||
extern struct sgttyb tty; /* tty information buffer */
|
||||
extern int old; /* original tty status */
|
||||
extern int noech; /* original tty status without echo */
|
||||
extern int raw; /* raw tty status, no echo */
|
||||
|
||||
int curr; /* row position of cursor */
|
||||
int curc; /* column position of cursor */
|
||||
int begscr; /* 'beginning' of screen
|
||||
extern int curr; /* row position of cursor */
|
||||
extern int curc; /* column position of cursor */
|
||||
extern int begscr; /* 'beginning' of screen
|
||||
(not including board) */
|
||||
|
||||
int getout(); /* function to exit backgammon cleanly */
|
||||
void getout(); /* function to exit backgammon cleanly */
|
||||
|
@ -43,9 +43,9 @@ static char ln[60];
|
||||
|
||||
wrboard () {
|
||||
register int l;
|
||||
static char bl[] =
|
||||
static const char bl[] =
|
||||
"| | | |\n";
|
||||
static char sv[] =
|
||||
static const char sv[] =
|
||||
"| | | | \n";
|
||||
|
||||
fixtty (noech);
|
||||
|
@ -591,9 +591,6 @@ clear () {
|
||||
tputs (CL,CO,addbuf); /* put CL in buffer */
|
||||
}
|
||||
|
||||
tos () { /* home cursor */
|
||||
curmove (0,0);
|
||||
}
|
||||
|
||||
fancyc (c)
|
||||
register char c; /* character to output */
|
||||
@ -703,8 +700,9 @@ newline () {
|
||||
curmove (curr+1,0);
|
||||
}
|
||||
|
||||
int
|
||||
getcaps (s)
|
||||
register char *s;
|
||||
const char *s;
|
||||
|
||||
{
|
||||
register char *code; /* two letter code */
|
||||
@ -712,7 +710,7 @@ register char *s;
|
||||
char *bufp; /* pointer to cap buffer */
|
||||
char tentry[1024]; /* temporary uncoded caps buffer */
|
||||
|
||||
tgetent (tentry,s); /* get uncoded termcap entry */
|
||||
tgetent (tentry, (char *)s); /* get uncoded termcap entry */
|
||||
|
||||
LI = tgetnum ("li"); /* get number of lines */
|
||||
if (LI == -1)
|
||||
|
@ -35,15 +35,16 @@
|
||||
static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sgtty.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <termios.h>
|
||||
|
||||
/*
|
||||
* variable initialization.
|
||||
*/
|
||||
|
||||
/* name of executable object programs */
|
||||
char EXEC[] = "/usr/games/backgammon";
|
||||
char TEACH[] = "/usr/games/teachgammon";
|
||||
const char EXEC[] = "/usr/games/backgammon";
|
||||
const char TEACH[] = "/usr/games/teachgammon";
|
||||
|
||||
int pnum = 2; /* color of player:
|
||||
-1 = white
|
||||
@ -62,4 +63,37 @@ int tflag = 0; /* cursor addressing flag */
|
||||
int iroll = 0; /* special flag for inputting rolls */
|
||||
int rfl = 0;
|
||||
|
||||
char *color[] = {"White","Red","white","red"};
|
||||
const char *const color[] = {"White","Red","white","red"};
|
||||
|
||||
const char *const *Colorptr;
|
||||
const char *const *colorptr;
|
||||
int *inopp;
|
||||
int *inptr;
|
||||
int *offopp;
|
||||
int *offptr;
|
||||
char args[100];
|
||||
int bar;
|
||||
int begscr;
|
||||
int board[26];
|
||||
char cin[100];
|
||||
int colen;
|
||||
int cturn;
|
||||
int curc;
|
||||
int curr;
|
||||
int d0;
|
||||
int dice[2];
|
||||
int dlast;
|
||||
int g[5];
|
||||
int gvalue;
|
||||
int h[4];
|
||||
int home;
|
||||
int in[2];
|
||||
int mvl;
|
||||
int mvlim;
|
||||
int ncin;
|
||||
int off[2];
|
||||
int p[5];
|
||||
int rscore;
|
||||
int table[6][6];
|
||||
int wscore;
|
||||
struct termios tty, old, noech, raw;
|
||||
|
@ -35,20 +35,20 @@
|
||||
static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include "back.h"
|
||||
|
||||
extern int errno;
|
||||
|
||||
static char confirm[] = "Are you sure you want to leave now?";
|
||||
static char prompt[] = "Enter a file name: ";
|
||||
static char exist1[] = "The file '";
|
||||
static char exist2[] =
|
||||
static const char confirm[] = "Are you sure you want to leave now?";
|
||||
static const char prompt[] = "Enter a file name: ";
|
||||
static const char exist1[] = "The file '";
|
||||
static const char exist2[] =
|
||||
"' already exists.\nAre you sure you want to use this file?";
|
||||
static char cantuse[] = "\nCan't use ";
|
||||
static char saved[] = "This game has been saved on the file '";
|
||||
static char type[] = "'.\nType \"backgammon ";
|
||||
static char rec[] = "\" to recover your game.\n\n";
|
||||
static char cantrec[] = "Can't recover file: ";
|
||||
static const char cantuse[] = "\nCan't use ";
|
||||
static const char saved[] = "This game has been saved on the file '";
|
||||
static const char type[] = "'.\nType \"backgammon ";
|
||||
static const char rec[] = "\" to recover your game.\n\n";
|
||||
static const char cantrec[] = "Can't recover file: ";
|
||||
|
||||
save (n)
|
||||
register int n;
|
||||
@ -87,8 +87,8 @@ register int n;
|
||||
writec (*fs++);
|
||||
}
|
||||
*fs = '\0';
|
||||
if ((fdesc = open(fname,2)) == -1 && errno == 2) {
|
||||
if ((fdesc = creat (fname,0700)) != -1)
|
||||
if ((fdesc = open(fname,O_RDWR)) == -1 && errno == ENOENT) {
|
||||
if ((fdesc = creat (fname,0600)) != -1)
|
||||
break;
|
||||
}
|
||||
if (fdesc != -1) {
|
||||
@ -141,14 +141,15 @@ register int n;
|
||||
getout ();
|
||||
}
|
||||
|
||||
int
|
||||
recover (s)
|
||||
char *s;
|
||||
const char *s;
|
||||
|
||||
{
|
||||
register int i;
|
||||
int fdesc;
|
||||
|
||||
if ((fdesc = open (s,0)) == -1)
|
||||
if ((fdesc = open (s,O_RDONLY)) == -1)
|
||||
norec (s);
|
||||
read (fdesc,board,sizeof board);
|
||||
read (fdesc,off,sizeof off);
|
||||
@ -165,11 +166,12 @@ char *s;
|
||||
rflag = 1;
|
||||
}
|
||||
|
||||
int
|
||||
norec (s)
|
||||
register char *s;
|
||||
const char *s;
|
||||
|
||||
{
|
||||
register char *c;
|
||||
const char *c;
|
||||
|
||||
tflag = 0;
|
||||
writel (cantrec);
|
||||
|
@ -43,11 +43,11 @@ static char sccsid[] = "@(#)subs.c 8.1 (Berkeley) 5/31/93";
|
||||
int buffnum;
|
||||
char outbuff[BUFSIZ];
|
||||
|
||||
static char plred[] = "Player is red, computer is white.";
|
||||
static char plwhite[] = "Player is white, computer is red.";
|
||||
static char nocomp[] = "(No computer play.)";
|
||||
static const char plred[] = "Player is red, computer is white.";
|
||||
static const char plwhite[] = "Player is white, computer is red.";
|
||||
static const char nocomp[] = "(No computer play.)";
|
||||
|
||||
char *descr[] = {
|
||||
const char *const descr[] = {
|
||||
"Usage: backgammon [-h n r w b pr pw pb tterm sfile]\n",
|
||||
"\t-h\tgets this list\n\t-n\tdon't ask for rules or instructions",
|
||||
"\t-r\tplayer is red (implies -n)\n\t-w\tplayer is white (implies -n)",
|
||||
@ -68,12 +68,6 @@ register char *s;
|
||||
getout();
|
||||
}
|
||||
|
||||
strset (s1,s2)
|
||||
register char *s1, *s2;
|
||||
{
|
||||
while ( (*s1++ = *s2++) != '\0');
|
||||
}
|
||||
|
||||
int addbuf (c)
|
||||
register int c;
|
||||
|
||||
@ -131,11 +125,12 @@ char c;
|
||||
addbuf (c);
|
||||
}
|
||||
|
||||
void
|
||||
writel (l)
|
||||
register char *l;
|
||||
const char *l;
|
||||
{
|
||||
#ifdef DEBUG
|
||||
register char *s;
|
||||
const char *s;
|
||||
|
||||
if (trace == NULL)
|
||||
trace = fopen ("bgtrace","w");
|
||||
@ -325,7 +320,7 @@ register char **argv;
|
||||
args[acnt++] = strdup ("-n");
|
||||
break;
|
||||
|
||||
/* player is both read and white */
|
||||
/* player is both red and white */
|
||||
case 'b':
|
||||
if (rflag)
|
||||
break;
|
||||
@ -424,6 +419,7 @@ int mode;
|
||||
errexit("fixtty");
|
||||
}
|
||||
|
||||
void
|
||||
getout () {
|
||||
/* go to bottom of screen */
|
||||
if (tflag) {
|
||||
|
@ -37,7 +37,7 @@ static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 5/31/93";
|
||||
|
||||
#include "back.h"
|
||||
|
||||
char *help2[] = {
|
||||
const char *const help2[] = {
|
||||
" Enter moves as <s>-<f> or <s>/<r> where <s> is the starting",
|
||||
"position, <f> is the finishing position, and <r> is the roll.",
|
||||
"Remember, each die roll must be moved separately.",
|
||||
@ -50,7 +50,7 @@ struct state {
|
||||
int newst;
|
||||
};
|
||||
|
||||
struct state atmata[] = {
|
||||
static const struct state atmata[] = {
|
||||
|
||||
'R', 1, 0, '?', 7, 0, 'Q', 0, -3, 'B', 8, 25,
|
||||
'9', 2, 25, '8', 2, 25, '7', 2, 25, '6', 2, 25,
|
||||
|
@ -39,7 +39,7 @@ static char sccsid[] = "@(#)data.c 8.1 (Berkeley) 5/31/93";
|
||||
|
||||
int maxmoves = 23;
|
||||
|
||||
char *text0[] = {
|
||||
const char *const text0[] = {
|
||||
"To start the game, I roll a 3, and you roll a 1. This means",
|
||||
"that I get to start first. I move 8-5,6-5 since this makes a",
|
||||
"new point and helps to trap your back men on 1. You should be",
|
||||
@ -47,7 +47,7 @@ char *text0[] = {
|
||||
0
|
||||
};
|
||||
|
||||
char *text1[] = {
|
||||
const char *const text1[] = {
|
||||
"Now you shall see a move using doubles. I just rolled double",
|
||||
"5's. I will move two men from position 13 to position 3. The",
|
||||
"notation for this is 13-8,13-8,8-3,8-3. You will also roll dou-",
|
||||
@ -55,7 +55,7 @@ char *text1[] = {
|
||||
0
|
||||
};
|
||||
|
||||
char *text2[] = {
|
||||
const char *const text2[] = {
|
||||
"Excellent! As you can see, you are beginning to develop a wall",
|
||||
"which is trapping my men on position 24. Also, moving your back",
|
||||
"men forward not only improves your board position safely, but it",
|
||||
@ -68,7 +68,7 @@ char *text2[] = {
|
||||
0
|
||||
};
|
||||
|
||||
char *text3[] = {
|
||||
const char *const text3[] = {
|
||||
"As you can see, although you left a man open, it is a rela-",
|
||||
"tively safe move to an advantageous position, which might help",
|
||||
"you make a point later. Only two rolls (4 5 or 5 4) will allow",
|
||||
@ -77,13 +77,13 @@ char *text3[] = {
|
||||
0
|
||||
};
|
||||
|
||||
char *text4[] = {
|
||||
const char *const text4[] = {
|
||||
"You're pretty lucky yourself, you know. I follow by rolling 2 3",
|
||||
"and moving 25-22,24-22, forming a new point.",
|
||||
0
|
||||
};
|
||||
|
||||
char *text5[] = {
|
||||
const char *const text5[] = {
|
||||
"Not a spectacular move, but a safe one. I follow by rolling 6 1.",
|
||||
"I decide to use this roll to move 22-16,16-15. It leaves me with",
|
||||
"one man still open, but the blot is farther back on the board, and",
|
||||
@ -91,7 +91,7 @@ char *text5[] = {
|
||||
0
|
||||
};
|
||||
|
||||
char *text6[] = {
|
||||
const char *const text6[] = {
|
||||
"By moving your two men from 17 to 20, you lessen my chance of",
|
||||
"getting my man off the board. In fact, the odds are 5 to 4",
|
||||
"against me getting off. I roll with the odds and helplessly",
|
||||
@ -99,7 +99,7 @@ char *text6[] = {
|
||||
0
|
||||
};
|
||||
|
||||
char *text7[] = {
|
||||
const char *const text7[] = {
|
||||
"Note that the blot on 7 cannot be hit unless I get off the bar",
|
||||
"and have a 1 or a 6 left over, and doing so will leave two of",
|
||||
"my men open. Also, the blot on 16 cannot be hit at all! With",
|
||||
@ -107,27 +107,27 @@ char *text7[] = {
|
||||
0
|
||||
};
|
||||
|
||||
char *text8[] = {
|
||||
const char *const text8[] = {
|
||||
"See, you did not get hit and, you got to 'cover up' your open men.",
|
||||
"Quite an accomplishment. Finally, I get off the bar by rolling",
|
||||
"6 2 and moving 25-23,23-17.",
|
||||
0
|
||||
};
|
||||
|
||||
char *text9[] = {
|
||||
const char *const text9[] = {
|
||||
"My venture off the bar did not last long. However, I got lucky",
|
||||
"and rolled double 1's, allowing me to move 25-24,24-23,15-14,15-14.",
|
||||
0
|
||||
};
|
||||
|
||||
char *text10[] = {
|
||||
const char *const text10[] = {
|
||||
"You are improving your position greatly and safely, and are well",
|
||||
"on the way to winning the game. I roll a 6 2 and squeak past",
|
||||
"your back man. Now the game becomes a race to the finish.",
|
||||
0
|
||||
};
|
||||
|
||||
char *text11[] = {
|
||||
const char *const text11[] = {
|
||||
"Now that it is merely a race, you are trying to get as many men",
|
||||
"as possible into the inner table, so you can start removing them.",
|
||||
"I roll a 3 4 and move my two men farthest back to position 11",
|
||||
@ -135,20 +135,20 @@ char *text11[] = {
|
||||
0
|
||||
};
|
||||
|
||||
char *text12[] = {
|
||||
const char *const text12[] = {
|
||||
"The race is still on, and you have seem to be doing all right.",
|
||||
"I roll 6 1 and move 14-8,13-12.",
|
||||
0
|
||||
};
|
||||
|
||||
char *text13[] = {
|
||||
const char *const text13[] = {
|
||||
"Notice that you get to remove men the instant you have all of",
|
||||
"them at your inner table, even if it is the middle of a turn.",
|
||||
"I roll 1 2 and move 13-11,12-11.",
|
||||
0
|
||||
};
|
||||
|
||||
char *text14[] = {
|
||||
const char *const text14[] = {
|
||||
"Although you could have removed a man, this move illustrates two",
|
||||
"points: 1) You never have to remove men, and 2) You should try",
|
||||
"to spread out your men on your inner table. Since you have one",
|
||||
@ -157,25 +157,25 @@ char *text14[] = {
|
||||
0
|
||||
};
|
||||
|
||||
char *text15[] = {
|
||||
const char *const text15[] = {
|
||||
"This time you were able to remove men. I roll 3 4 and move",
|
||||
"11-7,11-8. The race continues.",
|
||||
0
|
||||
};
|
||||
|
||||
char *text16[] = {
|
||||
const char *const text16[] = {
|
||||
"More holes are opening up in your inner table, but you are",
|
||||
"still very much ahead. If we were doubling, you would have",
|
||||
"doubled long ago. I roll 2 6 and move 8-6,11-5.",
|
||||
0
|
||||
};
|
||||
|
||||
char *text17[] = {
|
||||
const char *const text17[] = {
|
||||
"It pays to spread out your men. I roll 3 5 and move 7-4,8-3.",
|
||||
0
|
||||
};
|
||||
|
||||
char *text18[] = {
|
||||
const char *const text18[] = {
|
||||
"You can only remove some men, but you spread out more and",
|
||||
"more, in order to be able to remove men more efficiently.",
|
||||
"I roll double 3's, which help, but not that much. I move",
|
||||
@ -183,30 +183,30 @@ char *text18[] = {
|
||||
0
|
||||
};
|
||||
|
||||
char *text19[] = {
|
||||
const char *const text19[] = {
|
||||
"I roll 1 4 and move 5-4,4-0.",
|
||||
0
|
||||
};
|
||||
|
||||
char *text20[] = {
|
||||
const char *const text20[] = {
|
||||
"You are now nicely spread out to win a game. I roll 5 6 and",
|
||||
"move 5-0,6-0.",
|
||||
0
|
||||
};
|
||||
|
||||
char *text21[] = {
|
||||
const char *const text21[] = {
|
||||
"Any minute now. Just a few short steps from victory. I roll",
|
||||
"2 4 and move 6-4,4-0.",
|
||||
0
|
||||
};
|
||||
|
||||
char *text22[] = {
|
||||
const char *const text22[] = {
|
||||
"It looks pretty hopeless for me, but I play on, rolling 1 3 and",
|
||||
"moving 4-3,3-0.",
|
||||
0
|
||||
};
|
||||
|
||||
char *text23[] = {
|
||||
const char *const text23[] = {
|
||||
"Congratulations! You just won a game of backgammon against the",
|
||||
"computer! You will now be able to play a game, but remember,",
|
||||
"when you start playing, that doubling will be enabled, which",
|
||||
@ -215,7 +215,7 @@ char *text23[] = {
|
||||
0
|
||||
};
|
||||
|
||||
struct situatn test[] = {
|
||||
const struct situatn test[] = {
|
||||
{
|
||||
{0,2,0,0,0,0,-5,0,-3,0,0,0,5,-5,0,0,0,3,0,5,0,0,0,0,-2,0},
|
||||
3, 1, {8,6,0,0}, {5,5,0,0}, 4, 2, text0
|
||||
|
@ -44,6 +44,7 @@ static char sccsid[] = "@(#)teach.c 8.1 (Berkeley) 5/31/93";
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include "back.h"
|
||||
|
||||
extern char *hello[];
|
||||
@ -61,7 +62,7 @@ extern char *lastch[];
|
||||
|
||||
extern char ospeed; /* tty output speed for termlib */
|
||||
|
||||
char *helpm[] = {
|
||||
const char *const helpm[] = {
|
||||
"\nEnter a space or newline to roll, or",
|
||||
" b to display the board",
|
||||
" d to double",
|
||||
@ -69,7 +70,7 @@ char *helpm[] = {
|
||||
0
|
||||
};
|
||||
|
||||
char *contin[] = {
|
||||
const char *const contin[] = {
|
||||
"",
|
||||
0
|
||||
};
|
||||
@ -85,7 +86,7 @@ char **argv;
|
||||
setgid(getgid());
|
||||
|
||||
acnt = 1;
|
||||
signal (2,getout);
|
||||
signal (SIGINT,getout);
|
||||
if (gtty (0,&tty) == -1) /* get old tty mode */
|
||||
errexit ("teachgammon(gtty)");
|
||||
old = tty.sg_flags;
|
||||
|
@ -37,10 +37,10 @@ static char sccsid[] = "@(#)ttext1.c 8.1 (Berkeley) 5/31/93";
|
||||
|
||||
#include "back.h"
|
||||
|
||||
char *opts = " QIMRHEDSPT";
|
||||
char *prompt = "-->";
|
||||
const char *opts = " QIMRHEDSPT";
|
||||
const char *prompt = "-->";
|
||||
|
||||
char *list[] = {
|
||||
const char *const list[] = {
|
||||
"\n\n\tI\tIntroduction to Backgammon",
|
||||
"\tM\tMoves and Points",
|
||||
"\tR\tRemoving Men from the Board",
|
||||
@ -56,7 +56,7 @@ char *list[] = {
|
||||
0
|
||||
};
|
||||
|
||||
char *hello[] = {
|
||||
const char *const hello[] = {
|
||||
"\n\032 These rules consist of text describing how to play Backgammon",
|
||||
"followed by a tutorial session where you play a practice game",
|
||||
"against the computer. When using this program, think carefuly",
|
||||
@ -74,7 +74,7 @@ char *hello[] = {
|
||||
0
|
||||
};
|
||||
|
||||
char *intro1[] = {
|
||||
const char *const intro1[] = {
|
||||
"\nIntroduction:",
|
||||
"\n Backgammon is a game involving the skill of two players and",
|
||||
"the luck of two dice. There are two players, red and white, and",
|
||||
@ -85,7 +85,7 @@ char *intro1[] = {
|
||||
"",
|
||||
0};
|
||||
|
||||
char *intro2[] = {
|
||||
const char *const intro2[] = {
|
||||
"",
|
||||
"\n Although not indicated on the board, the players' homes are",
|
||||
"located just to the right of the board. A player's men are placed",
|
||||
@ -99,7 +99,7 @@ char *intro2[] = {
|
||||
"",
|
||||
0};
|
||||
|
||||
char *moves[] = {
|
||||
const char *const moves[] = {
|
||||
"\nMoves and Points:",
|
||||
"\n Moves are made along the positions on the board according to",
|
||||
"their numbers. Red moves in the positive direction (clockwise",
|
||||
@ -130,7 +130,7 @@ char *moves[] = {
|
||||
"",
|
||||
0};
|
||||
|
||||
char *remove[] = {
|
||||
const char *const remove[] = {
|
||||
"\nRemoving Men from the Board:",
|
||||
"\n The most important part of the game is removing men, since",
|
||||
"that is how you win the game. Once a man is removed, he stays",
|
||||
@ -154,7 +154,7 @@ char *remove[] = {
|
||||
"",
|
||||
0};
|
||||
|
||||
char *hits[] = {
|
||||
const char *const hits[] = {
|
||||
"\nHitting Blots:",
|
||||
"\n Although two men on a position form an impenetrable point, a",
|
||||
"lone man is not so secure. Such a man is called a 'blot' and has",
|
||||
@ -171,7 +171,7 @@ char *hits[] = {
|
||||
"",
|
||||
0};
|
||||
|
||||
char *endgame[] = {
|
||||
const char *const endgame[] = {
|
||||
"\nEnding the Game and Scoring:",
|
||||
"\n Winning a game usually wins one point, the normal value of a",
|
||||
"game. However, if the losing player has not removed any men yet,",
|
||||
|
@ -39,7 +39,7 @@ static char sccsid[] = "@(#)ttext2.c 8.1 (Berkeley) 5/31/93";
|
||||
|
||||
char *prompt, *list, *opts;
|
||||
|
||||
char *doubl[] = {
|
||||
const char *const doubl[] = {
|
||||
"\nDoubling:",
|
||||
"\n If a player thinks he is in a good position, he may double the",
|
||||
"value of the game. However, his opponent may not accept the pro-",
|
||||
@ -54,7 +54,7 @@ char *doubl[] = {
|
||||
"",
|
||||
0};
|
||||
|
||||
char *stragy[] = {
|
||||
const char *const stragy[] = {
|
||||
"\nStrategy:",
|
||||
"\n Some general hints when playing: Try not to leave men open",
|
||||
"unless absolutely necessary. Also, it is good to make as many",
|
||||
@ -70,7 +70,7 @@ char *stragy[] = {
|
||||
"",
|
||||
0};
|
||||
|
||||
char *prog[] = {
|
||||
const char *const prog[] = {
|
||||
"\nThe Program and How It Works:",
|
||||
"\n A general rule of thumb is when you don't know what to do,",
|
||||
"type a question mark, and you should get some help. When it is",
|
||||
@ -104,7 +104,7 @@ char *prog[] = {
|
||||
"",
|
||||
0};
|
||||
|
||||
char *lastch[] = {
|
||||
const char *const lastch[] = {
|
||||
"\nTutorial (Practice Game):",
|
||||
"\n This tutorial, for simplicity's sake, will let you play one",
|
||||
"predetermined game. All the rolls have been pre-arranged, and",
|
||||
@ -123,14 +123,15 @@ char *lastch[] = {
|
||||
"",
|
||||
0};
|
||||
|
||||
int
|
||||
text (txt)
|
||||
char **txt;
|
||||
const char *const *txt;
|
||||
|
||||
{
|
||||
char **begin;
|
||||
char *a;
|
||||
const char *const *begin;
|
||||
const char *a;
|
||||
char b;
|
||||
char *c;
|
||||
const char *c;
|
||||
int i;
|
||||
|
||||
fixtty (noech);
|
||||
|
@ -39,12 +39,13 @@ static char sccsid[] = "@(#)tutor.c 8.1 (Berkeley) 5/31/93";
|
||||
#include "tutor.h"
|
||||
|
||||
extern int maxmoves;
|
||||
extern char *finis[];
|
||||
extern const char *const finis[];
|
||||
|
||||
extern struct situatn test[];
|
||||
extern const struct situatn test[];
|
||||
|
||||
static char better[] = "That is a legal move, but there is a better one.\n";
|
||||
static const char better[] = "That is a legal move, but there is a better one.\n";
|
||||
|
||||
void
|
||||
tutor () {
|
||||
register int i, j;
|
||||
|
||||
@ -141,11 +142,12 @@ clrest () {
|
||||
curmove (r,c);
|
||||
}
|
||||
|
||||
int
|
||||
brdeq (b1,b2)
|
||||
register int *b1, *b2;
|
||||
const int *b1, *b2;
|
||||
|
||||
{
|
||||
register int *e;
|
||||
const int *e;
|
||||
|
||||
e = b1+26;
|
||||
while (b1 < e)
|
||||
|
@ -41,5 +41,23 @@ struct situatn {
|
||||
int mg[4];
|
||||
int new1;
|
||||
int new2;
|
||||
char *(*com[8]);
|
||||
const char *const (*com[8]);
|
||||
};
|
||||
|
||||
extern const char *const doubl[];
|
||||
extern const char *const endgame[];
|
||||
extern const char *const finis[];
|
||||
extern const char *const hello[];
|
||||
extern const char *const hits[];
|
||||
extern const char *const intro1[];
|
||||
extern const char *const intro2[];
|
||||
extern const char *const lastch[];
|
||||
extern const char *const list[];
|
||||
extern int maxmoves;
|
||||
extern const char *const moves[];
|
||||
extern const char *const opts;
|
||||
extern const char *const prog[];
|
||||
extern const char *const prompt;
|
||||
extern const char *const removepiece[];
|
||||
extern const char *const stragy[];
|
||||
extern const struct situatn test[];
|
||||
|
@ -44,7 +44,7 @@ battlestar \- a tropical adventure game
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.I Battlestar
|
||||
is an adventure game in the classic style. However, It's slightly less
|
||||
is an adventure game in the classic style. However, it's slightly less
|
||||
of a
|
||||
puzzle and more a game of exploration. There are a few magical words
|
||||
in the game, but on the whole, simple English
|
||||
|
@ -91,6 +91,6 @@ char **argv;
|
||||
case 0:
|
||||
goto start;
|
||||
default:
|
||||
exit(0);
|
||||
exit(1); /* Shouldn't happen */
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ int thataway, token;
|
||||
convert(tothis) /* Converts day to night and vice versa. */
|
||||
int tothis; /* Day objects are permanent. Night objects are added*/
|
||||
{ /* at dusk, and subtracted at dawn. */
|
||||
register struct objs *p;
|
||||
const struct objs *p;
|
||||
register i, j;
|
||||
|
||||
if (tothis == TONIGHT) {
|
||||
|
@ -140,6 +140,7 @@ use()
|
||||
else
|
||||
position = 229;
|
||||
gtime++;
|
||||
notes[CANTSEE] = 0;
|
||||
return(0);
|
||||
}
|
||||
else if (position == FINAL)
|
||||
|
@ -188,10 +188,10 @@ shoot()
|
||||
int firstnumber, value;
|
||||
register int n;
|
||||
|
||||
firstnumber = wordnumber;
|
||||
if (!testbit(inven,LASER))
|
||||
puts("You aren't holding a blaster.");
|
||||
else {
|
||||
firstnumber = wordnumber;
|
||||
while(wordtype[++wordnumber] == ADJS);
|
||||
while(wordnumber<=wordcount && wordtype[wordnumber] == OBJECT){
|
||||
value = wordvalue[wordnumber];
|
||||
|
@ -183,7 +183,7 @@ unsigned int from[];
|
||||
}
|
||||
|
||||
throw(name)
|
||||
char *name;
|
||||
const char *name;
|
||||
{
|
||||
int n;
|
||||
int deposit = 0;
|
||||
@ -263,7 +263,7 @@ throw(name)
|
||||
}
|
||||
|
||||
drop(name)
|
||||
char *name;
|
||||
const char *name;
|
||||
{
|
||||
|
||||
int firstnumber, value;
|
||||
|
@ -247,6 +247,19 @@ give()
|
||||
person = wordvalue[wordnumber];
|
||||
last2 = wordnumber;
|
||||
}
|
||||
/* Setting wordnumber to last1 - 1 looks wrong if last1 is 0, e.g.,
|
||||
* plain `give'. However, detecting this case is liable to detect
|
||||
* `give foo' as well, which would give a confusing error. We
|
||||
* need to make sure the -1 value can cause no problems if it arises.
|
||||
* If in the below we get to the drop("Given") then drop will look
|
||||
* at word 0 for an object to give, and fail, which is OK; then
|
||||
* result will be -1 and we get to the end, where wordnumber gets
|
||||
* set to something more sensible. If we get to "I don't think
|
||||
* that is possible" then again wordnumber is set to something
|
||||
* sensible. The wordnumber we leave with still isn't right if
|
||||
* you include words the game doesn't know in your command, but
|
||||
* that's no worse than what other commands than give do in
|
||||
* the same place. */
|
||||
wordnumber = last1 - 1;
|
||||
if (person && testbit(location[position].objects,person))
|
||||
if (person == NORMGOD && godready < 2 && !(obj == RING || obj == BRACELET))
|
||||
@ -255,6 +268,7 @@ give()
|
||||
result = drop("Given");
|
||||
else {
|
||||
puts("I don't think that is possible.");
|
||||
wordnumber = max(last1, last2) + 1;
|
||||
return(0);
|
||||
}
|
||||
if (result != -1 && (testbit(location[position].objects,obj) || obj == AMULET || obj == MEDALION || obj == TALISMAN)){
|
||||
@ -319,6 +333,6 @@ give()
|
||||
break;
|
||||
}
|
||||
}
|
||||
wordnumber = max(last1,last2);
|
||||
wordnumber = max(last1,last2) + 1;
|
||||
return(firstnumber);
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ char ch;
|
||||
sigsetmask(s);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
rate()
|
||||
{
|
||||
int score;
|
||||
|
@ -95,7 +95,7 @@ cypher()
|
||||
case SHOOT:
|
||||
if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
|
||||
for (n=0; n < NUMOFOBJECTS; n++)
|
||||
if (testbit(location[position].objects,n) && *objsht[n]){
|
||||
if (testbit(location[position].objects,n) && objsht[n]){
|
||||
wordvalue[wordnumber+1] = n;
|
||||
wordnumber = shoot();
|
||||
}
|
||||
@ -109,7 +109,7 @@ cypher()
|
||||
case TAKE:
|
||||
if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
|
||||
for (n=0; n < NUMOFOBJECTS; n++)
|
||||
if (testbit(location[position].objects,n) && *objsht[n]){
|
||||
if (testbit(location[position].objects,n) && objsht[n]){
|
||||
wordvalue[wordnumber+1] = n;
|
||||
wordnumber = take(location[position].objects);
|
||||
}
|
||||
@ -141,7 +141,7 @@ cypher()
|
||||
if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
|
||||
for (n=0; n < NUMOFOBJECTS; n++)
|
||||
if (testbit(inven,n) ||
|
||||
testbit(location[position].objects, n) && *objsht[n]){
|
||||
testbit(location[position].objects, n) && objsht[n]){
|
||||
wordvalue[wordnumber+1] = n;
|
||||
wordnumber = throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
|
||||
}
|
||||
@ -183,7 +183,7 @@ cypher()
|
||||
|
||||
if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
|
||||
for (n=0; n < NUMOFOBJECTS; n++)
|
||||
if (testbit(location[position].objects,n) && *objsht[n]){
|
||||
if (testbit(location[position].objects,n) && objsht[n]){
|
||||
wordvalue[wordnumber+1] = n;
|
||||
wordnumber = puton();
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ face downward on the carpet clutching his chest.*\n\
|
||||
The hallway leads -.**\n" },
|
||||
{ "You are in the dining hall.",
|
||||
0, 30, 31, 23, 0, 0, 0, 0,
|
||||
"This was the seen of a mass suicide. Hundreds of ambassadors and assorted\n\
|
||||
"This was the scene of a mass suicide. Hundreds of ambassadors and assorted\n\
|
||||
dignitaries sit slumped over their breakfast cereal. I suppose the news\n\
|
||||
of the cylon attack killed them. There is a strange chill in this room. I\n\
|
||||
would not linger here. * The kitchen is +. Entrances + and +.\n" },
|
||||
@ -445,7 +445,7 @@ outcroppings of lava to land. There is a nicer beach ***+.\n" },
|
||||
{ "You are lost in a sea of fog.",
|
||||
97, 104, 97, 97, 97, 1, 0, 1,
|
||||
"What have you gotten us into?\n\
|
||||
I cant see a thing! ****\n" },
|
||||
I can't see a thing! ****\n" },
|
||||
{ "You are on a gravel wash.",
|
||||
125, 126, 127, 128, 84, 0, 0, 0,
|
||||
"The sound of cascading water is the background for a diluted chorus of \n\
|
||||
@ -530,7 +530,7 @@ impossible to climb down to a small cave entrance below. Only at rare\n\
|
||||
minus tides would it be possible to enter.*** The beach is better +.\n" },
|
||||
{ "You are on the coast road.",
|
||||
158, 161, 162, 91, 79, 0, 0, 0,
|
||||
"The road is beginning to turn inland.* I can here the surf +. The road\n\
|
||||
"The road is beginning to turn inland.* I can hear the surf +. The road\n\
|
||||
continues +.*\n" },
|
||||
{ "The road winds deeper into the trees.",
|
||||
163, 142, 91, 164, 79, 0, 0, 0,
|
||||
|
@ -37,7 +37,7 @@ static char sccsid[] = "@(#)dayobjs.c 8.1 (Berkeley) 5/31/93";
|
||||
|
||||
#include "externs.h"
|
||||
|
||||
struct objs dayobjs[] = {
|
||||
const struct objs dayobjs[] = {
|
||||
{ 236, HORSE },
|
||||
{ 237, CAR },
|
||||
{ 275, POT },
|
||||
|
@ -218,7 +218,7 @@
|
||||
#define MAXCUMBER 10
|
||||
|
||||
struct room {
|
||||
char *name;
|
||||
const char *name;
|
||||
int link[8];
|
||||
#define north link[0]
|
||||
#define south link[1]
|
||||
@ -228,7 +228,7 @@ struct room {
|
||||
#define access link[5]
|
||||
#define down link[6]
|
||||
#define flyhere link[7]
|
||||
char *desc;
|
||||
const char *desc;
|
||||
int objects[NUMOFWORDS];
|
||||
};
|
||||
extern struct room dayfile[];
|
||||
@ -236,11 +236,11 @@ extern struct room nightfile[];
|
||||
struct room *location;
|
||||
|
||||
/* object characteristics */
|
||||
char *objdes[NUMOFOBJECTS];
|
||||
char *objsht[NUMOFOBJECTS];
|
||||
char *ouch[NUMOFINJURIES];
|
||||
int objwt[NUMOFOBJECTS];
|
||||
int objcumber[NUMOFOBJECTS];
|
||||
const char *const objdes[NUMOFOBJECTS];
|
||||
const char *const objsht[NUMOFOBJECTS];
|
||||
const char *const ouch[NUMOFINJURIES];
|
||||
const int objwt[NUMOFOBJECTS];
|
||||
const int objcumber[NUMOFOBJECTS];
|
||||
|
||||
/* current input line */
|
||||
#define NWORD 20 /* words per line */
|
||||
@ -249,7 +249,7 @@ int wordvalue[NWORD];
|
||||
int wordtype[NWORD];
|
||||
int wordcount, wordnumber;
|
||||
|
||||
char *truedirec(), *rate();
|
||||
const char *truedirec(), *rate();
|
||||
char *getcom(), *getword();
|
||||
|
||||
/* state of the game */
|
||||
@ -284,7 +284,7 @@ char injuries[NUMOFINJURIES];
|
||||
char uname[MAXLOGNAME];
|
||||
|
||||
struct wlist {
|
||||
char *string;
|
||||
const char *string;
|
||||
int value, article;
|
||||
struct wlist *next;
|
||||
};
|
||||
@ -298,7 +298,7 @@ struct objs {
|
||||
short room;
|
||||
short obj;
|
||||
};
|
||||
extern struct objs dayobjs[];
|
||||
extern struct objs nightobjs[];
|
||||
extern const struct objs dayobjs[];
|
||||
extern const struct objs nightobjs[];
|
||||
|
||||
gid_t egid;
|
||||
|
@ -42,7 +42,7 @@ char *
|
||||
getcom(buf, size, prompt, error)
|
||||
char *buf;
|
||||
int size;
|
||||
char *prompt, *error;
|
||||
const char *prompt, *error;
|
||||
{
|
||||
for (;;) {
|
||||
fputs(prompt, stdout);
|
||||
|
@ -40,7 +40,7 @@ static char sccsid[] = "@(#)globals.c 8.1 (Berkeley) 5/31/93";
|
||||
int WEIGHT = MAXWEIGHT;
|
||||
int CUMBER = MAXCUMBER;
|
||||
|
||||
char *objdes[NUMOFOBJECTS] = {
|
||||
const char *const objdes[NUMOFOBJECTS] = {
|
||||
"There is a knife here",
|
||||
"There is an exquisitely crafted sword and scabbard here.",
|
||||
0, /* can land from here */
|
||||
@ -108,7 +108,7 @@ char *objdes[NUMOFOBJECTS] = {
|
||||
|
||||
};
|
||||
|
||||
char *objsht[NUMOFOBJECTS] = {
|
||||
const char *const objsht[NUMOFOBJECTS] = {
|
||||
"knife",
|
||||
"fine sword",
|
||||
0,
|
||||
@ -175,7 +175,7 @@ char *objsht[NUMOFOBJECTS] = {
|
||||
"diamond block"
|
||||
};
|
||||
|
||||
char *ouch[NUMOFINJURIES] = {
|
||||
const char *const ouch[NUMOFINJURIES] = {
|
||||
"some minor abrasions",
|
||||
"some minor lacerations",
|
||||
"a minor puncture wound",
|
||||
@ -191,7 +191,7 @@ char *ouch[NUMOFINJURIES] = {
|
||||
"a broken neck"
|
||||
};
|
||||
|
||||
int objwt[NUMOFOBJECTS] = {
|
||||
const int objwt[NUMOFOBJECTS] = {
|
||||
1, 5, 0, 10, 15, 2, 10, 10,
|
||||
3, 5, 50, 2500, 2, 1, 100, 1,
|
||||
2, 1, 1, 1, 60, 10, 5, 0,
|
||||
@ -202,7 +202,7 @@ int objwt[NUMOFOBJECTS] = {
|
||||
50, 45, 45, 100, 2000, 30, 20, 10
|
||||
};
|
||||
|
||||
int objcumber[NUMOFOBJECTS] = {
|
||||
const int objcumber[NUMOFOBJECTS] = {
|
||||
1, 5, 0, 150, 10, 1, 5, 2,
|
||||
2, 1, 5, 10, 1, 1, 10, 1,
|
||||
1, 1, 1, 1, 7, 5, 4, 0,
|
||||
|
@ -43,7 +43,7 @@ static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93";
|
||||
initialize(startup)
|
||||
char startup;
|
||||
{
|
||||
register struct objs *p;
|
||||
const struct objs *p;
|
||||
void die();
|
||||
|
||||
puts("Version 4.2, fall 1984.");
|
||||
@ -79,7 +79,7 @@ getutmp(uname)
|
||||
strcpy(uname, ptr ? ptr->pw_name : "");
|
||||
}
|
||||
|
||||
char *list[] = { /* hereditary wizards */
|
||||
const char *const list[] = { /* hereditary wizards */
|
||||
"riggle",
|
||||
"chris",
|
||||
"edward",
|
||||
@ -90,15 +90,16 @@ char *list[] = { /* hereditary wizards */
|
||||
0
|
||||
};
|
||||
|
||||
char *badguys[] = {
|
||||
const char *const badguys[] = {
|
||||
"wnj",
|
||||
"root",
|
||||
"ted",
|
||||
0
|
||||
};
|
||||
|
||||
int
|
||||
wizard(uname)
|
||||
char *uname;
|
||||
const char *uname;
|
||||
{
|
||||
char flag;
|
||||
|
||||
@ -107,10 +108,11 @@ wizard(uname)
|
||||
return flag;
|
||||
}
|
||||
|
||||
int
|
||||
checkout(uname)
|
||||
register char *uname;
|
||||
const char *uname;
|
||||
{
|
||||
register char **ptr;
|
||||
const char *const *ptr;
|
||||
|
||||
for (ptr = list; *ptr; ptr++)
|
||||
if (strcmp(*ptr, uname) == 0)
|
||||
|
@ -37,11 +37,12 @@ static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93";
|
||||
|
||||
#include "externs.h"
|
||||
|
||||
int
|
||||
card(array, size) /* for beenthere, injuries */
|
||||
register char *array;
|
||||
const char *array;
|
||||
int size;
|
||||
{
|
||||
register char *end = array + size;
|
||||
const char *end = array + size;
|
||||
register int i = 0;
|
||||
|
||||
while (array < end)
|
||||
@ -50,8 +51,9 @@ card(array, size) /* for beenthere, injuries */
|
||||
return (i);
|
||||
}
|
||||
|
||||
int
|
||||
ucard(array)
|
||||
register unsigned *array;
|
||||
const unsigned int *array;
|
||||
{
|
||||
register int j = 0, n;
|
||||
|
||||
|
@ -180,7 +180,7 @@ face downward on the carpet clutching his chest.*\n\
|
||||
The hallway leads -.**\n" },
|
||||
{ "You are in the dining hall.",
|
||||
0, 30, 31, 23, 0, 0, 0, 0,
|
||||
"This was the seen of a mass suicide. Hundreds of ambassadors and assorted\n\
|
||||
"This was the scene of a mass suicide. Hundreds of ambassadors and assorted\n\
|
||||
dignitaries sit slumped over their breakfast cereal. I suppose the news\n\
|
||||
of the cylon attack killed them. There is a strange chill in this room. I\n\
|
||||
would not linger here. * The kitchen is +. Entrances + and +.\n" },
|
||||
@ -433,7 +433,7 @@ The very tip of the island is +.*\n" },
|
||||
{ "You are lost in a sea of fog.",
|
||||
97, 104, 97, 97, 97, 1, 0, 1,
|
||||
"What have you gotten us into?\n\
|
||||
I cant see a thing! ****\n" },
|
||||
I can't see a thing! ****\n" },
|
||||
{ "You are on a gravel wash.",
|
||||
125, 126, 127, 128, 84, 0, 0, 0,
|
||||
"It is very dark here. A cool breeze is blowing from +. No moonlight can\n\
|
||||
@ -512,7 +512,7 @@ small cave entrance below. Large rocks would usually churn the waves\n\
|
||||
asunder.*** The beach goes -.\n" },
|
||||
{ "You are on the coast road.",
|
||||
158, 161, 162, 91, 79, 0, 0, 0,
|
||||
"The road is beginning to turn slightly -. I can here the surf +. The road\n\
|
||||
"The road is beginning to turn slightly -. I can hear the surf +. The road\n\
|
||||
continues into the dark forest +.*\n" },
|
||||
{ "The road winds deeper into the trees.",
|
||||
163, 142, 91, 164, 79, 0, 0, 0,
|
||||
|
@ -37,7 +37,7 @@ static char sccsid[] = "@(#)nightobjs.c 8.1 (Berkeley) 5/31/93";
|
||||
|
||||
#include "externs.h"
|
||||
|
||||
struct objs nightobjs[] = {
|
||||
const struct objs nightobjs[] = {
|
||||
{ 218, PAJAMAS },
|
||||
{ 235, NATIVE },
|
||||
{ 92, PAPAYAS },
|
||||
|
@ -45,8 +45,9 @@ wordinit()
|
||||
install(w);
|
||||
}
|
||||
|
||||
int
|
||||
hash(s)
|
||||
register char *s;
|
||||
const char *s;
|
||||
{
|
||||
register hashval = 0;
|
||||
|
||||
@ -60,7 +61,7 @@ hash(s)
|
||||
|
||||
struct wlist *
|
||||
lookup(s)
|
||||
char *s;
|
||||
const char *s;
|
||||
{
|
||||
register struct wlist *wp;
|
||||
|
||||
|
@ -40,7 +40,7 @@ static char sccsid[] = "@(#)room.c 8.1 (Berkeley) 5/31/93";
|
||||
writedes()
|
||||
{
|
||||
int compass;
|
||||
register char *p;
|
||||
const char *p;
|
||||
register c;
|
||||
|
||||
printf("\n\t%s\n", location[position].name);
|
||||
@ -104,7 +104,7 @@ struct room here;
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
truedirec(way, option)
|
||||
int way;
|
||||
char option;
|
||||
|
@ -40,6 +40,7 @@ static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93";
|
||||
#include <sys/param.h> /* MAXPATHLEN */
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include "externs.h"
|
||||
|
||||
void
|
||||
@ -93,7 +94,10 @@ restore()
|
||||
fread(&loved, sizeof loved, 1, fp);
|
||||
fread(&pleasure, sizeof pleasure, 1, fp);
|
||||
fread(&power, sizeof power, 1, fp);
|
||||
fread(&ego, sizeof ego, 1, fp);
|
||||
/* We must check the last read, to catch truncated save files. */
|
||||
if (fread(&ego, sizeof ego, 1, fp) < 1)
|
||||
errx(1, "save file %s too short", home1);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -127,6 +127,9 @@ main(argc, argv)
|
||||
{
|
||||
char cardline[80];
|
||||
|
||||
/* revoke setgid privileges */
|
||||
setgid(getgid());
|
||||
|
||||
/*
|
||||
* The original bcd prompts with a "%" when reading from stdin,
|
||||
* but this seems kind of silly. So this one doesn't.
|
||||
|
@ -83,6 +83,9 @@ void main(argc, argv)
|
||||
register char *inbuf;
|
||||
int obs[26], try, winner;
|
||||
|
||||
/* revoke setgid privileges */
|
||||
setgid(getgid());
|
||||
|
||||
if (argc > 1)
|
||||
printit(argv[1]);
|
||||
|
||||
|
@ -61,6 +61,7 @@ static char sccsid[] = "@(#)canfield.c 8.1 (Berkeley) 5/31/93";
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "pathnames.h"
|
||||
|
||||
@ -1325,7 +1326,7 @@ suspend()
|
||||
move(21, 0);
|
||||
refresh();
|
||||
if (dbfd != -1) {
|
||||
lseek(dbfd, uid * sizeof(struct betinfo), 0);
|
||||
lseek(dbfd, uid * sizeof(struct betinfo), SEEK_SET);
|
||||
write(dbfd, (char *)&total, sizeof(total));
|
||||
}
|
||||
kill(getpid(), SIGTSTP);
|
||||
@ -1577,7 +1578,7 @@ initall()
|
||||
initdeck(deck);
|
||||
uid = getuid();
|
||||
|
||||
i = lseek(dbfd, uid * sizeof(struct betinfo), 0);
|
||||
i = lseek(dbfd, uid * sizeof(struct betinfo), SEEK_SET);
|
||||
if (i < 0) {
|
||||
close(dbfd);
|
||||
dbfd = -1;
|
||||
@ -1640,7 +1641,7 @@ cleanup()
|
||||
status = NOBOX;
|
||||
updatebettinginfo();
|
||||
if (dbfd != -1) {
|
||||
lseek(dbfd, uid * sizeof(struct betinfo), 0);
|
||||
lseek(dbfd, uid * sizeof(struct betinfo), SEEK_SET);
|
||||
write(dbfd, (char *)&total, sizeof(total));
|
||||
close(dbfd);
|
||||
}
|
||||
@ -1672,11 +1673,9 @@ askquit()
|
||||
/*
|
||||
* Can you tell that this used to be a Pascal program?
|
||||
*/
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
main()
|
||||
{
|
||||
dbfd = open(_PATH_SCORE, 2);
|
||||
dbfd = open(_PATH_SCORE, O_RDWR);
|
||||
|
||||
/* revoke */
|
||||
setgid(getgid());
|
||||
|
@ -43,6 +43,8 @@ static char sccsid[] = "@(#)cfscores.c 8.1 (Berkeley) 5/31/93";
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "pathnames.h"
|
||||
|
||||
struct betinfo {
|
||||
@ -69,7 +71,7 @@ main(argc, argv)
|
||||
printf("Usage: cfscores [user]\n");
|
||||
exit(1);
|
||||
}
|
||||
dbfd = open(_PATH_SCORE, 0);
|
||||
dbfd = open(_PATH_SCORE, O_RDONLY);
|
||||
if (dbfd < 0) {
|
||||
perror(_PATH_SCORE);
|
||||
exit(2);
|
||||
@ -114,7 +116,7 @@ printuser(pw, printfail)
|
||||
printf("Bad uid %d\n", pw->pw_uid);
|
||||
return;
|
||||
}
|
||||
i = lseek(dbfd, pw->pw_uid * sizeof(struct betinfo), 0);
|
||||
i = lseek(dbfd, pw->pw_uid * sizeof(struct betinfo), SEEK_SET);
|
||||
if (i < 0) {
|
||||
perror("lseek");
|
||||
return;
|
||||
|
@ -78,6 +78,7 @@ main(argc, argv)
|
||||
exit(0);
|
||||
|
||||
gametty = ttyname(0);
|
||||
unsetenv("TZ");
|
||||
(void)time(&now);
|
||||
read_config();
|
||||
#ifdef LOG
|
||||
|
@ -37,6 +37,8 @@
|
||||
/
|
||||
*************************************************************************/
|
||||
|
||||
void Error();
|
||||
|
||||
static char *files[] = { /* all files to create */
|
||||
_SPATH_MONST,
|
||||
_SPATH_PEOPLE,
|
||||
@ -221,6 +223,7 @@ main(argc, argv)
|
||||
/
|
||||
*************************************************************************/
|
||||
|
||||
void
|
||||
Error(str, file)
|
||||
char *str, *file;
|
||||
{
|
||||
|
@ -57,7 +57,9 @@ static const char sccsid[] = "@(#)pom.c 8.1 (Berkeley) 5/31/93";
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#define PI 3.141592654
|
||||
#ifndef PI
|
||||
#define PI 3.14159265358979323846
|
||||
#endif
|
||||
#define EPOCH 85
|
||||
#define EPSILONg 279.611371 /* solar ecliptic long at EPOCH */
|
||||
#define RHOg 282.680403 /* solar ecliptic long of perigee at EPOCH */
|
||||
|
@ -1,10 +1,15 @@
|
||||
Albania:Tirana|Tirane"
|
||||
Andorra:Andorra la V[ell|iej]a
|
||||
Austria:Vienna|Wien
|
||||
Belarus|Byelorussia:M[i|e]nsk
|
||||
Belgium:Brussel[s|]|Bruxelles
|
||||
Bosnia[-Herzegovina|]:Sarajevo
|
||||
Bulgaria:Sofi[a|ya]
|
||||
Czechoslovakia:Prague|Praha
|
||||
Croatia:Zagreb
|
||||
Czech Republic:Prague|Praha
|
||||
Denmark:Copenhagen|K[o|o/]benhavn
|
||||
Estonia:Tallinn
|
||||
Georgia:Tbilisi
|
||||
Germany:Berlin
|
||||
United Kingdom|England|Great Britain|UK:London
|
||||
Finland:Helsinki
|
||||
@ -14,19 +19,26 @@ Hungary:Budapest
|
||||
Iceland:Reykjavik
|
||||
Ireland|Eire:Dublin
|
||||
Italy:Rom[e|a]
|
||||
Latvia:Riga
|
||||
Liechtenstein:Vaduz
|
||||
Lithuania:Vilnius
|
||||
Luxembourg:Luxembourg
|
||||
[|Former Yugoslav Republic Of ]Macedonia:Skop[|l]je
|
||||
Malta:Valletta
|
||||
Moldova:Chisinau|Kishinev
|
||||
Monaco:Monte Carlo
|
||||
Netherlands|Holland:The Hague|'sGravenhage|den Haag|Amsterdam
|
||||
Norway:Oslo
|
||||
Poland:Wars[aw|zawa]
|
||||
Portugal:Lisbo[n|a]
|
||||
R[u|o]mania:Bucharest|Bucuresti
|
||||
Russia:Mos[cow|kva]
|
||||
San Marino:San Marino
|
||||
Slovakia|Slovak Republic:Bratislava
|
||||
Slovenia:Ljubljana
|
||||
Spain:Madrid
|
||||
Sweden:Stockholm
|
||||
Switzerland:Bern{e}
|
||||
Turkey:Ankara
|
||||
Russia:Mos[cow|kva]
|
||||
Ukraine:Kiev|Kyiv
|
||||
Yugoslavia:Belgrade|Beograd
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
PROG= rain
|
||||
MAN6= rain.6
|
||||
DPADD= ${LIBTERMCAP} ${LIBCOMPAT}
|
||||
LDADD= -ltermcap -lcompat
|
||||
DPADD= ${LIBCURSES} ${LIBCOMPAT}
|
||||
LDADD= -lcurses -lcompat
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -60,7 +60,8 @@ get_move()
|
||||
lastmove = *Next_move;
|
||||
else
|
||||
lastmove = -1; /* flag for "first time in" */
|
||||
}
|
||||
} else
|
||||
lastmove = 0; /* Shut up gcc */
|
||||
#endif
|
||||
for (;;) {
|
||||
if (Teleport && must_telep())
|
||||
|
@ -63,7 +63,7 @@ mon_hit(monster)
|
||||
register object *monster;
|
||||
{
|
||||
short damage, hit_chance;
|
||||
char *mn;
|
||||
const char *mn;
|
||||
float minus;
|
||||
|
||||
if (fight_monster && (monster != fight_monster)) {
|
||||
@ -175,7 +175,7 @@ short other;
|
||||
}
|
||||
|
||||
get_damage(ds, r)
|
||||
char *ds;
|
||||
const char *ds;
|
||||
boolean r;
|
||||
{
|
||||
register i = 0, j, n, d, total = 0;
|
||||
@ -201,7 +201,7 @@ boolean r;
|
||||
}
|
||||
|
||||
get_w_damage(obj)
|
||||
object *obj;
|
||||
const object *obj;
|
||||
{
|
||||
char new_damage[12];
|
||||
register to_hit, damage;
|
||||
@ -220,7 +220,7 @@ object *obj;
|
||||
}
|
||||
|
||||
get_number(s)
|
||||
register char *s;
|
||||
const char *s;
|
||||
{
|
||||
register i = 0;
|
||||
register total = 0;
|
||||
@ -234,7 +234,7 @@ register char *s;
|
||||
|
||||
long
|
||||
lget_number(s)
|
||||
char *s;
|
||||
const char *s;
|
||||
{
|
||||
short i = 0;
|
||||
long total = 0;
|
||||
@ -247,7 +247,7 @@ char *s;
|
||||
}
|
||||
|
||||
to_hit(obj)
|
||||
object *obj;
|
||||
const object *obj;
|
||||
{
|
||||
if (!obj) {
|
||||
return(1);
|
||||
@ -289,7 +289,7 @@ mon_damage(monster, damage)
|
||||
object *monster;
|
||||
short damage;
|
||||
{
|
||||
char *mn;
|
||||
const char *mn;
|
||||
short row, col;
|
||||
|
||||
monster->hp_to_kill -= damage;
|
||||
@ -423,7 +423,7 @@ short allow_off_screen;
|
||||
}
|
||||
|
||||
get_hit_chance(weapon)
|
||||
object *weapon;
|
||||
const object *weapon;
|
||||
{
|
||||
short hit_chance;
|
||||
|
||||
@ -434,7 +434,7 @@ object *weapon;
|
||||
}
|
||||
|
||||
get_weapon_damage(weapon)
|
||||
object *weapon;
|
||||
const object *weapon;
|
||||
{
|
||||
short damage;
|
||||
|
||||
|
@ -65,8 +65,8 @@ boolean ask_quit = 1;
|
||||
boolean no_skull = 0;
|
||||
boolean passgo = 0;
|
||||
boolean flush = 1;
|
||||
char *error_file = "rogue.esave";
|
||||
char *byebye_string = "Okay, bye bye!";
|
||||
const char *error_file = "rogue.esave";
|
||||
const char *byebye_string = "Okay, bye bye!";
|
||||
|
||||
extern char *fruit;
|
||||
extern char *save_file;
|
||||
@ -77,7 +77,7 @@ init(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
char *pn;
|
||||
const char *pn;
|
||||
int seed;
|
||||
|
||||
pn = md_gln();
|
||||
@ -173,7 +173,7 @@ player_init()
|
||||
}
|
||||
|
||||
clean_up(estr)
|
||||
char *estr;
|
||||
const char *estr;
|
||||
{
|
||||
if (save_is_interactive) {
|
||||
if (init_curses) {
|
||||
@ -310,7 +310,7 @@ char **s, *e;
|
||||
boolean add_blank;
|
||||
{
|
||||
short i = 0;
|
||||
char *t;
|
||||
const char *t;
|
||||
|
||||
t = e;
|
||||
|
||||
@ -332,7 +332,8 @@ boolean add_blank;
|
||||
}
|
||||
|
||||
init_str(str, dflt)
|
||||
char **str, *dflt;
|
||||
char **str;
|
||||
const char *dflt;
|
||||
{
|
||||
if (!(*str)) {
|
||||
*str = md_malloc(MAX_OPT_LEN + 2);
|
||||
|
@ -53,9 +53,9 @@ static char sccsid[] = "@(#)inventory.c 8.1 (Berkeley) 5/31/93";
|
||||
#include "rogue.h"
|
||||
|
||||
boolean is_wood[WANDS];
|
||||
char *press_space = " --press space to continue--";
|
||||
const char *press_space = " --press space to continue--";
|
||||
|
||||
char *wand_materials[WAND_MATERIALS] = {
|
||||
const char *const wand_materials[WAND_MATERIALS] = {
|
||||
"steel ",
|
||||
"bronze ",
|
||||
"gold ",
|
||||
@ -89,7 +89,7 @@ char *wand_materials[WAND_MATERIALS] = {
|
||||
"wooden "
|
||||
};
|
||||
|
||||
char *gems[GEMS] = {
|
||||
const char *const gems[GEMS] = {
|
||||
"diamond ",
|
||||
"stibotantalite ",
|
||||
"lapi-lazuli ",
|
||||
@ -106,7 +106,7 @@ char *gems[GEMS] = {
|
||||
"garnet "
|
||||
};
|
||||
|
||||
char *syllables[MAXSYLLABLES] = {
|
||||
const char *const syllables[MAXSYLLABLES] = {
|
||||
"blech ",
|
||||
"foo ",
|
||||
"barf ",
|
||||
@ -153,10 +153,10 @@ char *syllables[MAXSYLLABLES] = {
|
||||
|
||||
struct id_com_s {
|
||||
short com_char;
|
||||
char *com_desc;
|
||||
const char *com_desc;
|
||||
};
|
||||
|
||||
struct id_com_s com_id_tab[COMS] = {
|
||||
const struct id_com_s com_id_tab[COMS] = {
|
||||
'?', "? prints help",
|
||||
'r', "r read scroll",
|
||||
'/', "/ identify object",
|
||||
@ -211,7 +211,7 @@ extern boolean wizard;
|
||||
extern char *m_names[], *more;
|
||||
|
||||
inventory(pack, mask)
|
||||
object *pack;
|
||||
const object *pack;
|
||||
unsigned short mask;
|
||||
{
|
||||
object *obj;
|
||||
@ -441,10 +441,10 @@ make_scroll_titles()
|
||||
}
|
||||
|
||||
get_desc(obj, desc)
|
||||
object *obj;
|
||||
const object *obj;
|
||||
char *desc;
|
||||
{
|
||||
char *item_name;
|
||||
const char *item_name;
|
||||
struct id *id_table;
|
||||
char more_info[32];
|
||||
short i;
|
||||
@ -657,7 +657,7 @@ short ichar;
|
||||
|
||||
struct id *
|
||||
get_id_table(obj)
|
||||
object *obj;
|
||||
const object *obj;
|
||||
{
|
||||
switch(obj->what_is) {
|
||||
case SCROL:
|
||||
@ -696,7 +696,7 @@ boolean is_weapon;
|
||||
|
||||
id_type()
|
||||
{
|
||||
char *id;
|
||||
const char *id;
|
||||
int ch;
|
||||
char buf[DCOLS];
|
||||
|
||||
|
@ -57,11 +57,11 @@ static char sccsid[] = "@(#)level.c 8.1 (Berkeley) 5/31/93";
|
||||
short cur_level = 0;
|
||||
short max_level = 1;
|
||||
short cur_room;
|
||||
char *new_level_message = 0;
|
||||
const char *new_level_message = 0;
|
||||
short party_room = NO_ROOM;
|
||||
short r_de;
|
||||
|
||||
long level_points[MAX_EXP_LEVEL] = {
|
||||
const long level_points[MAX_EXP_LEVEL] = {
|
||||
10L,
|
||||
20L,
|
||||
40L,
|
||||
@ -572,7 +572,7 @@ boolean do_rec_de;
|
||||
|
||||
recursive_deadend(rn, offsets, srow, scol)
|
||||
short rn;
|
||||
short *offsets;
|
||||
const short *offsets;
|
||||
short srow, scol;
|
||||
{
|
||||
short i, de;
|
||||
|
@ -254,7 +254,7 @@ md_ignore_signals()
|
||||
|
||||
int
|
||||
md_get_file_id(fname)
|
||||
char *fname;
|
||||
const char *fname;
|
||||
{
|
||||
struct stat sbuf;
|
||||
|
||||
@ -274,7 +274,7 @@ char *fname;
|
||||
|
||||
int
|
||||
md_link_count(fname)
|
||||
char *fname;
|
||||
const char *fname;
|
||||
{
|
||||
struct stat sbuf;
|
||||
|
||||
@ -330,7 +330,7 @@ struct rogue_time *rt_buf;
|
||||
*/
|
||||
|
||||
md_gfmt(fname, rt_buf)
|
||||
char *fname;
|
||||
const char *fname;
|
||||
struct rogue_time *rt_buf;
|
||||
{
|
||||
struct stat sbuf;
|
||||
@ -362,7 +362,7 @@ struct rogue_time *rt_buf;
|
||||
|
||||
boolean
|
||||
md_df(fname)
|
||||
char *fname;
|
||||
const char *fname;
|
||||
{
|
||||
if (unlink(fname)) {
|
||||
return(0);
|
||||
@ -379,7 +379,7 @@ char *fname;
|
||||
* function, but then the score file would only have one name in it.
|
||||
*/
|
||||
|
||||
char *
|
||||
const char *
|
||||
md_gln()
|
||||
{
|
||||
struct passwd *p;
|
||||
@ -446,7 +446,7 @@ int nsecs;
|
||||
|
||||
char *
|
||||
md_getenv(name)
|
||||
char *name;
|
||||
const char *name;
|
||||
{
|
||||
char *value;
|
||||
|
||||
@ -493,7 +493,10 @@ int n;
|
||||
|
||||
md_gseed()
|
||||
{
|
||||
return(getpid());
|
||||
time_t seconds;
|
||||
|
||||
time(&seconds);
|
||||
return((int) seconds);
|
||||
}
|
||||
|
||||
/* md_exit():
|
||||
@ -550,7 +553,7 @@ boolean l;
|
||||
*/
|
||||
|
||||
md_shell(shell)
|
||||
char *shell;
|
||||
const char *shell;
|
||||
{
|
||||
long w[2];
|
||||
|
||||
|
@ -57,14 +57,14 @@ char msgs[NMESSAGES][DCOLS] = {"", "", "", "", ""};
|
||||
short msg_col = 0, imsg = -1;
|
||||
boolean msg_cleared = 1, rmsg = 0;
|
||||
char hunger_str[8] = "";
|
||||
char *more = "-more-";
|
||||
const char *more = "-more-";
|
||||
|
||||
extern boolean cant_int, did_int, interrupted, save_is_interactive, flush;
|
||||
extern short add_strength;
|
||||
extern short cur_level;
|
||||
|
||||
message(msg, intrpt)
|
||||
char *msg;
|
||||
const char *msg;
|
||||
boolean intrpt;
|
||||
{
|
||||
cant_int = 1;
|
||||
@ -130,8 +130,9 @@ check_message()
|
||||
}
|
||||
|
||||
get_input_line(prompt, insert, buf, if_cancelled, add_blank, do_echo)
|
||||
char *prompt, *buf, *insert;
|
||||
char *if_cancelled;
|
||||
const char *prompt, *insert;
|
||||
char *buf;
|
||||
const char *if_cancelled;
|
||||
boolean add_blank;
|
||||
boolean do_echo;
|
||||
{
|
||||
@ -305,7 +306,7 @@ register stat_mask;
|
||||
}
|
||||
|
||||
pad(s, n)
|
||||
char *s;
|
||||
const char *s;
|
||||
short n;
|
||||
{
|
||||
short i;
|
||||
@ -357,7 +358,7 @@ short ch;
|
||||
}
|
||||
|
||||
r_index(str, ch, last)
|
||||
char *str;
|
||||
const char *str;
|
||||
int ch;
|
||||
boolean last;
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ static char sccsid[] = "@(#)monster.c 8.1 (Berkeley) 5/31/93";
|
||||
object level_monsters;
|
||||
boolean mon_disappeared;
|
||||
|
||||
char *m_names[] = {
|
||||
const char *const m_names[] = {
|
||||
"aquator",
|
||||
"bat",
|
||||
"centaur",
|
||||
@ -171,7 +171,7 @@ register mn;
|
||||
|
||||
mv_mons()
|
||||
{
|
||||
register object *monster, *next_monster;
|
||||
register object *monster, *next_monster, *test_mons;
|
||||
boolean flew;
|
||||
|
||||
if (haste_self % 2) {
|
||||
@ -210,7 +210,17 @@ mv_mons()
|
||||
if (!(flew && mon_can_go(monster, rogue.row, rogue.col))) {
|
||||
mv_1_monster(monster, rogue.row, rogue.col);
|
||||
}
|
||||
NM: monster = next_monster;
|
||||
NM: test_mons = level_monsters.next_monster;
|
||||
monster = NULL;
|
||||
while(test_mons)
|
||||
{
|
||||
if(next_monster == test_mons)
|
||||
{
|
||||
monster = next_monster;
|
||||
break;
|
||||
}
|
||||
test_mons = test_mons->next_monster;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -488,7 +498,7 @@ register short row, col;
|
||||
}
|
||||
|
||||
mon_can_go(monster, row, col)
|
||||
register object *monster;
|
||||
const object *monster;
|
||||
register short row, col;
|
||||
{
|
||||
object *obj;
|
||||
@ -572,9 +582,9 @@ short row, col;
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
mon_name(monster)
|
||||
object *monster;
|
||||
const object *monster;
|
||||
{
|
||||
short ch;
|
||||
|
||||
@ -790,7 +800,7 @@ object *monster;
|
||||
gr_obj_char()
|
||||
{
|
||||
short r;
|
||||
char *rs = "%!?]=/):*";
|
||||
const char *rs = "%!?]=/):*";
|
||||
|
||||
r = get_rand(0, 8);
|
||||
|
||||
@ -832,7 +842,8 @@ aggravate()
|
||||
|
||||
boolean
|
||||
mon_sees(monster, row, col)
|
||||
object *monster;
|
||||
const object *monster;
|
||||
int row, col;
|
||||
{
|
||||
short rn, rdif, cdif, retval;
|
||||
|
||||
|
@ -54,7 +54,7 @@ static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93";
|
||||
|
||||
short m_moves = 0;
|
||||
boolean jump = 0;
|
||||
char *you_can_move_again = "you can move again";
|
||||
const char *you_can_move_again = "you can move again";
|
||||
|
||||
extern short cur_room, halluc, blind, levitate;
|
||||
extern short cur_level, max_level;
|
||||
|
@ -228,6 +228,7 @@ boolean is_maze;
|
||||
|
||||
place_at(obj, row, col)
|
||||
object *obj;
|
||||
int row, col;
|
||||
{
|
||||
obj->row = row;
|
||||
obj->col = col;
|
||||
@ -257,6 +258,7 @@ short row, col;
|
||||
|
||||
object *
|
||||
get_letter_object(ch)
|
||||
int ch;
|
||||
{
|
||||
object *obj;
|
||||
|
||||
@ -281,11 +283,11 @@ object *objlist;
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
name_of(obj)
|
||||
object *obj;
|
||||
const object *obj;
|
||||
{
|
||||
char *retstring;
|
||||
const char *retstring;
|
||||
|
||||
switch(obj->what_is) {
|
||||
case SCROL:
|
||||
@ -602,7 +604,7 @@ put_stairs()
|
||||
}
|
||||
|
||||
get_armor_class(obj)
|
||||
object *obj;
|
||||
const object *obj;
|
||||
{
|
||||
if (obj) {
|
||||
return(obj->class + obj->d_enchant);
|
||||
|
@ -52,13 +52,14 @@ static char sccsid[] = "@(#)pack.c 8.1 (Berkeley) 5/31/93";
|
||||
|
||||
#include "rogue.h"
|
||||
|
||||
char *curse_message = "you can't, it appears to be cursed";
|
||||
const char *curse_message = "you can't, it appears to be cursed";
|
||||
|
||||
extern short levitate;
|
||||
|
||||
object *
|
||||
add_to_pack(obj, pack, condense)
|
||||
object *obj, *pack;
|
||||
int condense;
|
||||
{
|
||||
object *op;
|
||||
|
||||
@ -99,6 +100,7 @@ object *obj, *pack;
|
||||
|
||||
object *
|
||||
pick_up(row, col, status)
|
||||
int row, col;
|
||||
short *status;
|
||||
{
|
||||
object *obj;
|
||||
@ -270,7 +272,7 @@ wait_for_ack()
|
||||
}
|
||||
|
||||
pack_letter(prompt, mask)
|
||||
char *prompt;
|
||||
const char *prompt;
|
||||
unsigned short mask;
|
||||
{
|
||||
short ch;
|
||||
@ -460,7 +462,7 @@ call_it()
|
||||
}
|
||||
|
||||
pack_count(new_obj)
|
||||
object *new_obj;
|
||||
const object *new_obj;
|
||||
{
|
||||
object *obj;
|
||||
short count = 0;
|
||||
@ -488,7 +490,7 @@ object *new_obj;
|
||||
|
||||
boolean
|
||||
mask_pack(pack, mask)
|
||||
object *pack;
|
||||
const object *pack;
|
||||
unsigned short mask;
|
||||
{
|
||||
while (pack->next_object) {
|
||||
|
@ -53,7 +53,7 @@ static char sccsid[] = "@(#)play.c 8.1 (Berkeley) 5/31/93";
|
||||
#include "rogue.h"
|
||||
|
||||
boolean interrupted = 0;
|
||||
char *unknown_command = "unknown command";
|
||||
const char *unknown_command = "unknown command";
|
||||
|
||||
extern short party_room, bear_trap;
|
||||
extern char hit_message[];
|
||||
|
@ -52,8 +52,8 @@ static char sccsid[] = "@(#)ring.c 8.1 (Berkeley) 5/31/93";
|
||||
|
||||
#include "rogue.h"
|
||||
|
||||
char *left_or_right = "left or right hand?";
|
||||
char *no_ring = "there's no ring on that hand";
|
||||
const char *left_or_right = "left or right hand?";
|
||||
const char *no_ring = "there's no ring on that hand";
|
||||
short stealthy;
|
||||
short r_rings;
|
||||
short add_strength;
|
||||
|
@ -221,7 +221,7 @@ struct id {
|
||||
|
||||
struct obj { /* comment is monster meaning */
|
||||
unsigned long m_flags; /* monster flags */
|
||||
char *damage; /* damage it does */
|
||||
const char *damage; /* damage it does */
|
||||
short quantity; /* hit points to kill */
|
||||
short ichar; /* 'A' is for aquatar */
|
||||
short kill_exp; /* exp for killing it */
|
||||
@ -427,10 +427,10 @@ extern object level_monsters;
|
||||
|
||||
/* external routine declarations.
|
||||
*/
|
||||
char *mon_name();
|
||||
char *get_ench_color();
|
||||
char *name_of();
|
||||
char *md_gln();
|
||||
const char *mon_name();
|
||||
const char *get_ench_color();
|
||||
const char *name_of();
|
||||
const char *md_gln();
|
||||
char *md_getenv();
|
||||
char *md_malloc();
|
||||
boolean is_direction();
|
||||
|
@ -62,7 +62,7 @@ extern char *nick_name, *fruit, *save_file, *press_space;
|
||||
#define NOPTS 8
|
||||
|
||||
struct option {
|
||||
char *prompt;
|
||||
const char *prompt;
|
||||
boolean is_bool;
|
||||
char **strval;
|
||||
boolean *bval;
|
||||
@ -129,6 +129,7 @@ int rn;
|
||||
}
|
||||
|
||||
light_passage(row, col)
|
||||
int row, col;
|
||||
{
|
||||
short i, j, i_end, j_end;
|
||||
|
||||
@ -604,7 +605,7 @@ edit_opts()
|
||||
opt_show(i)
|
||||
int i;
|
||||
{
|
||||
char *s;
|
||||
const char *s;
|
||||
struct option *opt = &options[i];
|
||||
|
||||
opt_erase(i);
|
||||
@ -635,7 +636,7 @@ int i;
|
||||
do_shell()
|
||||
{
|
||||
#ifdef UNIX
|
||||
char *sh;
|
||||
const char *sh;
|
||||
|
||||
md_ignore_signals();
|
||||
if (!(sh = md_getenv("SHELL"))) {
|
||||
|
@ -94,7 +94,7 @@ save_game()
|
||||
}
|
||||
|
||||
save_into_file(sfile)
|
||||
char *sfile;
|
||||
const char *sfile;
|
||||
{
|
||||
FILE *fp;
|
||||
int file_id;
|
||||
@ -176,7 +176,7 @@ static del_save_file()
|
||||
}
|
||||
|
||||
restore(fname)
|
||||
char *fname;
|
||||
const char *fname;
|
||||
{
|
||||
FILE *fp;
|
||||
struct rogue_time saved_time, mod_time;
|
||||
@ -257,16 +257,16 @@ char *fname;
|
||||
}
|
||||
|
||||
write_pack(pack, fp)
|
||||
object *pack;
|
||||
const object *pack;
|
||||
FILE *fp;
|
||||
{
|
||||
object t;
|
||||
|
||||
while (pack = pack->next_object) {
|
||||
r_write(fp, (char *) pack, sizeof(object));
|
||||
r_write(fp, (const char *) pack, sizeof(object));
|
||||
}
|
||||
t.ichar = t.what_is = 0;
|
||||
r_write(fp, (char *) &t, sizeof(object));
|
||||
r_write(fp, (const char *) &t, sizeof(object));
|
||||
}
|
||||
|
||||
read_pack(pack, fp, is_rogue)
|
||||
@ -333,8 +333,8 @@ boolean wr;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (wr) {
|
||||
r_write(fp, (char *) &(id_table[i].value), sizeof(short));
|
||||
r_write(fp, (char *) &(id_table[i].id_status),
|
||||
r_write(fp, (const char *) &(id_table[i].value), sizeof(short));
|
||||
r_write(fp, (const char *) &(id_table[i].id_status),
|
||||
sizeof(unsigned short));
|
||||
write_string(id_table[i].title, fp);
|
||||
} else {
|
||||
@ -393,7 +393,7 @@ int n;
|
||||
|
||||
r_write(fp, buf, n)
|
||||
FILE *fp;
|
||||
char *buf;
|
||||
const char *buf;
|
||||
int n;
|
||||
{
|
||||
if (!write_failed) {
|
||||
@ -407,7 +407,7 @@ int n;
|
||||
|
||||
boolean
|
||||
has_been_touched(saved_time, mod_time)
|
||||
struct rogue_time *saved_time, *mod_time;
|
||||
const struct rogue_time *saved_time, *mod_time;
|
||||
{
|
||||
if (saved_time->year < mod_time->year) {
|
||||
return(1);
|
||||
|
@ -61,7 +61,7 @@ extern boolean score_only, no_skull, msg_cleared;
|
||||
extern char *byebye_string, *nick_name;
|
||||
|
||||
killed_by(monster, other)
|
||||
object *monster;
|
||||
const object *monster;
|
||||
short other;
|
||||
{
|
||||
char buf[128];
|
||||
@ -193,7 +193,7 @@ boolean from_intrpt;
|
||||
}
|
||||
|
||||
put_scores(monster, other)
|
||||
object *monster;
|
||||
const object *monster;
|
||||
short other;
|
||||
{
|
||||
short i, n, rank = 10, x, ne = 0, found_player = -1;
|
||||
@ -321,9 +321,9 @@ short other;
|
||||
insert_score(scores, n_names, n_name, rank, n, monster, other)
|
||||
char scores[][82];
|
||||
char n_names[][30];
|
||||
char *n_name;
|
||||
const char *n_name;
|
||||
short rank, n;
|
||||
object *monster;
|
||||
const object *monster;
|
||||
{
|
||||
short i;
|
||||
char buf[128];
|
||||
@ -423,7 +423,7 @@ sell_pack()
|
||||
}
|
||||
|
||||
get_value(obj)
|
||||
object *obj;
|
||||
const object *obj;
|
||||
{
|
||||
short wc;
|
||||
int val;
|
||||
@ -491,7 +491,8 @@ id_all()
|
||||
}
|
||||
|
||||
name_cmp(s1, s2)
|
||||
char *s1, *s2;
|
||||
char *s1;
|
||||
const char *s2;
|
||||
{
|
||||
short i = 0;
|
||||
int r;
|
||||
@ -540,7 +541,8 @@ boolean st;
|
||||
}
|
||||
|
||||
nickize(buf, score, n_name)
|
||||
char *buf, *score, *n_name;
|
||||
char *buf;
|
||||
const char *score, *n_name;
|
||||
{
|
||||
short i = 15, j;
|
||||
|
||||
@ -566,7 +568,7 @@ char *buf, *score, *n_name;
|
||||
|
||||
center(row, buf)
|
||||
short row;
|
||||
char *buf;
|
||||
const char *buf;
|
||||
{
|
||||
short margin;
|
||||
|
||||
|
@ -261,7 +261,7 @@ short row, col;
|
||||
rand_around(i, r, c)
|
||||
short i, *r, *c;
|
||||
{
|
||||
static char* pos = "\010\007\001\003\004\005\002\006\0";
|
||||
static char pos[] = "\010\007\001\003\004\005\002\006\0";
|
||||
static short row, col;
|
||||
short j;
|
||||
|
||||
|
@ -56,7 +56,7 @@ trap traps[MAX_TRAPS];
|
||||
boolean trap_door = 0;
|
||||
short bear_trap = 0;
|
||||
|
||||
char *trap_strings[TRAPS * 2] = {
|
||||
const char *const trap_strings[TRAPS * 2] = {
|
||||
"trap door",
|
||||
"you fell down a trap",
|
||||
"bear trap",
|
||||
@ -72,7 +72,7 @@ char *trap_strings[TRAPS * 2] = {
|
||||
};
|
||||
|
||||
extern short cur_level, party_room;
|
||||
extern char *new_level_message;
|
||||
extern const char *new_level_message;
|
||||
extern boolean interrupted;
|
||||
extern short ring_exp;
|
||||
extern boolean sustain_strength;
|
||||
|
@ -61,7 +61,7 @@ boolean see_invisible = 0;
|
||||
short extra_hp = 0;
|
||||
boolean detect_monster = 0;
|
||||
boolean con_mon = 0;
|
||||
char *strange_feeling = "you have a strange feeling for a moment, then it passes";
|
||||
const char *strange_feeling = "you have a strange feeling for a moment, then it passes";
|
||||
|
||||
extern short bear_trap;
|
||||
extern char hunger_str[];
|
||||
@ -580,7 +580,7 @@ go_blind()
|
||||
mvaddch(rogue.row, rogue.col, rogue.fchar);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
get_ench_color()
|
||||
{
|
||||
if (halluc) {
|
||||
|
@ -275,7 +275,8 @@ bounce(ball, dir, row, col, r)
|
||||
short ball, dir, row, col, r;
|
||||
{
|
||||
short orow, ocol;
|
||||
char buf[DCOLS], *s;
|
||||
char buf[DCOLS];
|
||||
const char *s;
|
||||
short i, ch, new_dir = -1, damage;
|
||||
static short btime;
|
||||
|
||||
|
@ -157,7 +157,7 @@ char onlytemp;
|
||||
row = fp->row;
|
||||
col = fp->col;
|
||||
drift = fp->drift;
|
||||
move(movement, ship, &fp->dir, &fp->row, &fp->col, &drift);
|
||||
sail_move(movement, ship, &fp->dir, &fp->row, &fp->col, &drift);
|
||||
if (!*movement)
|
||||
(void) strcpy(movement, "d");
|
||||
|
||||
@ -176,7 +176,7 @@ char onlytemp;
|
||||
return total;
|
||||
}
|
||||
|
||||
move(p, ship, dir, row, col, drift)
|
||||
sail_move(p, ship, dir, row, col, drift)
|
||||
register char *p;
|
||||
register struct ship *ship;
|
||||
register char *dir;
|
||||
@ -222,7 +222,7 @@ register char *drift;
|
||||
|
||||
try(command, temp, ma, ta, af, vma, dir, f, t, high, rakeme)
|
||||
register struct ship *f, *t;
|
||||
int ma, ta, af, *high, rakeme;
|
||||
int ma, ta, af, vma, dir, *high, rakeme;
|
||||
char command[], temp[];
|
||||
{
|
||||
register int new, n;
|
||||
|
@ -70,6 +70,7 @@ makesignal(from, fmt, ship, a, b, c)
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
sync_exists(game)
|
||||
int game;
|
||||
{
|
||||
char buf[sizeof sync_file];
|
||||
struct stat s;
|
||||
|
@ -35,6 +35,8 @@
|
||||
static char sccsid[] = "@(#)dumpgame.c 8.1 (Berkeley) 5/31/93";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
# include "trek.h"
|
||||
|
||||
/*** THIS CONSTANT MUST CHANGE AS THE DATA SPACES CHANGE ***/
|
||||
@ -111,7 +113,7 @@ restartgame()
|
||||
register int fd;
|
||||
int version;
|
||||
|
||||
if ((fd = open("trek.dump", 0)) < 0 ||
|
||||
if ((fd = open("trek.dump", O_RDONLY)) < 0 ||
|
||||
read(fd, &version, sizeof version) != sizeof version ||
|
||||
version != VERSION ||
|
||||
readdump(fd))
|
||||
|
@ -51,8 +51,10 @@ static char sccsid[] = "@(#)wump.c 8.1 (Berkeley) 5/31/93";
|
||||
* would care to remember.
|
||||
*/
|
||||
|
||||
#include <err.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/wait.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -679,7 +681,10 @@ int_compare(a, b)
|
||||
|
||||
instructions()
|
||||
{
|
||||
char buf[120], *p, *getenv();
|
||||
const char *pager;
|
||||
pid_t pid;
|
||||
int status;
|
||||
int fd;
|
||||
|
||||
/*
|
||||
* read the instructions file, if needed, and show the user how to
|
||||
@ -695,12 +700,26 @@ puff of greasy black smoke! (poof)\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(p = getenv("PAGER")) ||
|
||||
strlen(p) > sizeof(buf) + strlen(_PATH_WUMPINFO) + 5)
|
||||
p = _PATH_PAGER;
|
||||
|
||||
(void)sprintf(buf, "%s %s", p, _PATH_WUMPINFO);
|
||||
(void)system(buf);
|
||||
if (!isatty(1))
|
||||
pager = "cat";
|
||||
else {
|
||||
if (!(pager = getenv("PAGER")) || (*pager == 0))
|
||||
pager = _PATH_PAGER;
|
||||
}
|
||||
switch (pid = fork()) {
|
||||
case 0: /* child */
|
||||
if ((fd = open(_PATH_WUMPINFO, O_RDONLY)) == -1)
|
||||
err(1, "open %s", _PATH_WUMPINFO);
|
||||
if (dup2(fd, 0) == -1)
|
||||
err(1, "dup2");
|
||||
(void)execl("/bin/sh", "sh", "-c", pager, NULL);
|
||||
err(1, "exec sh -c %s", pager);
|
||||
case -1:
|
||||
err(1, "fork");
|
||||
default:
|
||||
(void)waitpid(pid, &status, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
usage()
|
||||
|
Loading…
Reference in New Issue
Block a user