summaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-09-01 18:13:21 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-09-01 18:13:21 +0000
commit380f0870e4aafdd13a6050959648e2e735f2ea56 (patch)
tree973b59d6e1f493c1109524c804f193b62de56759 /games
parentc5cbec643fb6a50e791eafdc5a04ed929af464e8 (diff)
Remove trailing spaces on lines, use sane pathname sizes, and
use warn instead of perror.
Diffstat (limited to 'games')
-rw-r--r--games/battlestar/com1.c6
-rw-r--r--games/battlestar/com2.c8
-rw-r--r--games/battlestar/com4.c8
-rw-r--r--games/battlestar/com6.c6
-rw-r--r--games/battlestar/com7.c4
-rw-r--r--games/battlestar/cypher.c32
-rw-r--r--games/battlestar/extern.h4
-rw-r--r--games/battlestar/getcom.c4
-rw-r--r--games/battlestar/init.c18
-rw-r--r--games/battlestar/save.c16
10 files changed, 55 insertions, 51 deletions
diff --git a/games/battlestar/com1.c b/games/battlestar/com1.c
index 31e6b6297f2..10ad2d967bd 100644
--- a/games/battlestar/com1.c
+++ b/games/battlestar/com1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: com1.c,v 1.3 1997/08/24 21:55:01 deraadt Exp $ */
+/* $OpenBSD: com1.c,v 1.4 1997/09/01 18:13:08 millert Exp $ */
/* $NetBSD: com1.c,v 1.3 1995/03/21 15:06:51 cgd Exp $ */
/*
@@ -153,7 +153,7 @@ news()
fight(WOODSMAN,50);
}
switch(position){
-
+
case 267:
case 257: /* entering a cave */
case 274:
@@ -239,7 +239,7 @@ crash()
if (!location[position].flyhere || (testbit(location[position].objects,LAND) && fuel <= 0)){
if (!location[position].flyhere)
puts("You're flying too low. We're going to crash!");
- else{
+ else{
puts("You're out of fuel. We'll have to crash land!");
if (!location[position].down){
puts("Your viper strikes the ground and explodes into firey fragments.");
diff --git a/games/battlestar/com2.c b/games/battlestar/com2.c
index b1a17647e6f..69d24e9e582 100644
--- a/games/battlestar/com2.c
+++ b/games/battlestar/com2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: com2.c,v 1.3 1997/08/24 21:55:02 deraadt Exp $ */
+/* $OpenBSD: com2.c,v 1.4 1997/09/01 18:13:10 millert Exp $ */
/* $NetBSD: com2.c,v 1.3 1995/03/21 15:06:55 cgd Exp $ */
/*
@@ -94,11 +94,11 @@ wearit() /* synonyms = {sheathe, sheath} */
}
else if (testbit(wear,value))
printf("You are already wearing the %s.\n", objsht[value]);
- else
+ else
printf("You aren't holding the %s.\n", objsht[value]);
if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
wordnumber++;
- else
+ else
return(firstnumber);
} /* end switch */
} /* end while */
@@ -305,7 +305,7 @@ follow()
notes[CANTSEE] = 1;
return(0);
}
- else
+ else
puts("There is no one to follow.");
return(-1);
}
diff --git a/games/battlestar/com4.c b/games/battlestar/com4.c
index 3018582ba15..813485520ec 100644
--- a/games/battlestar/com4.c
+++ b/games/battlestar/com4.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: com4.c,v 1.3 1997/08/24 21:55:03 deraadt Exp $ */
+/* $OpenBSD: com4.c,v 1.4 1997/09/01 18:13:11 millert Exp $ */
/* $NetBSD: com4.c,v 1.3 1995/03/21 15:07:04 cgd Exp $ */
/*
@@ -177,7 +177,7 @@ unsigned int from[];
clearbit(location[position].objects,BATHGOD);
} else if (!testbit(location[position].objects,BATHGOD))
puts("You're in no position to take her.");
- else
+ else
puts("She moves away from you.");
break;
@@ -262,7 +262,7 @@ throw(name)
}
if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
wordnumber++;
- else
+ else
return(first);
}
return(first);
@@ -384,7 +384,7 @@ eat()
printf("You aren't holding the %s.\n", objsht[value]);
if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
wordnumber++;
- else
+ else
return(firstnumber);
} /* end switch */
} /* end while */
diff --git a/games/battlestar/com6.c b/games/battlestar/com6.c
index 49f5d40dff0..d48c32efe9d 100644
--- a/games/battlestar/com6.c
+++ b/games/battlestar/com6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: com6.c,v 1.5 1997/08/24 21:55:04 deraadt Exp $ */
+/* $OpenBSD: com6.c,v 1.6 1997/09/01 18:13:13 millert Exp $ */
/* $NetBSD: com6.c,v 1.5 1995/04/27 21:30:23 mycroft Exp $ */
/*
@@ -105,8 +105,8 @@ static FILE *score_fp;
open_score_file()
{
- if ((score_fp = fopen(_PATH_SCORE,"a")) == NULL)
- perror(_PATH_SCORE);
+ if ((score_fp = fopen(_PATH_SCORE, "a")) == NULL)
+ warn("can't append to %s", _PATH_SCORE);
}
void
diff --git a/games/battlestar/com7.c b/games/battlestar/com7.c
index 74d5c1b91e8..c9d3ca35f0f 100644
--- a/games/battlestar/com7.c
+++ b/games/battlestar/com7.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: com7.c,v 1.3 1997/08/24 21:55:04 deraadt Exp $ */
+/* $OpenBSD: com7.c,v 1.4 1997/09/01 18:13:14 millert Exp $ */
/* $NetBSD: com7.c,v 1.3 1995/03/21 15:07:12 cgd Exp $ */
/*
@@ -80,7 +80,7 @@ fighton:
hurt = rnd(50)%(WEIGHT-carrying)-card(injuries,NUMOFINJURIES)-encumber - exhaustion;
else if (testbit(inven,KNIFE) || testbit(inven,MALLET) || testbit(inven,CHAIN) || testbit(inven,MACE) || testbit(inven,HALBERD))
hurt = rnd(15) - card(injuries,NUMOFINJURIES) - exhaustion;
- else
+ else
hurt = rnd(7) - encumber;
if (hurt < 5)
switch(rnd(3)){
diff --git a/games/battlestar/cypher.c b/games/battlestar/cypher.c
index f3c78fe324e..5f5e4125175 100644
--- a/games/battlestar/cypher.c
+++ b/games/battlestar/cypher.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cypher.c,v 1.3 1997/08/24 21:55:05 deraadt Exp $ */
+/* $OpenBSD: cypher.c,v 1.4 1997/09/01 18:13:15 millert Exp $ */
/* $NetBSD: cypher.c,v 1.3 1995/03/21 15:07:15 cgd Exp $ */
/*
@@ -87,19 +87,19 @@ cypher()
return(-1);
lflag = 0;
break;
-
+
case AHEAD:
if (!move(ahead, AHEAD))
return(-1);
lflag = 0;
break;
-
+
case BACK:
if (!move(back, BACK))
return(-1);
lflag = 0;
break;
-
+
case SHOOT:
if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
for (n=0; n < NUMOFOBJECTS; n++)
@@ -110,7 +110,7 @@ cypher()
wordnumber++;
wordnumber++;
}
- else
+ else
shoot();
break;
@@ -127,7 +127,7 @@ cypher()
wordnumber++;
wordnumber++;
}
- else
+ else
take(location[position].objects);
break;
@@ -142,7 +142,7 @@ cypher()
wordnumber++;
wordnumber++;
}
- else
+ else
drop("Dropped");
break;
@@ -157,7 +157,7 @@ cypher()
wordnumber = throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
}
wordnumber += 2;
- } else
+ } else
throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
break;
@@ -170,7 +170,7 @@ cypher()
}
wordnumber += 2;
}
- else
+ else
takeoff();
break;
@@ -185,7 +185,7 @@ cypher()
}
wordnumber += 2;
}
- else
+ else
draw();
break;
@@ -200,7 +200,7 @@ cypher()
}
wordnumber += 2;
}
- else
+ else
puton();
break;
@@ -214,7 +214,7 @@ cypher()
}
wordnumber += 2;
}
- else
+ else
wearit();
break;
@@ -229,7 +229,7 @@ cypher()
}
wordnumber += 2;
}
- else
+ else
eat();
break;
@@ -283,7 +283,7 @@ cypher()
puts("\nYour match splutters out.");
matchlight = 0;
}
- } else
+ } else
puts("I can't see anything.");
return(-1);
break;
@@ -384,7 +384,7 @@ cypher()
case LAUNCH:
if (!launch())
return(-1);
- else
+ else
lflag = 0;
break;
@@ -431,7 +431,7 @@ cypher()
return(-1);
break;
-
+
}
if (wordnumber < wordcount && *words[wordnumber++] == ',')
continue;
diff --git a/games/battlestar/extern.h b/games/battlestar/extern.h
index 783727d3ef8..64d34921682 100644
--- a/games/battlestar/extern.h
+++ b/games/battlestar/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.1 1997/08/24 21:55:07 deraadt Exp $ */
+/* $OpenBSD: extern.h,v 1.2 1997/09/01 18:13:16 millert Exp $ */
/* $NetBSD: extern.h,v 1.5 1995/04/24 12:22:18 cgd Exp $ */
/*
@@ -44,7 +44,9 @@
#include <sys/time.h>
#undef _KERNEL
+#include <err.h>
#include <errno.h>
+#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
diff --git a/games/battlestar/getcom.c b/games/battlestar/getcom.c
index 585ea64caea..2635a1b2e15 100644
--- a/games/battlestar/getcom.c
+++ b/games/battlestar/getcom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getcom.c,v 1.3 1997/08/24 21:55:08 deraadt Exp $ */
+/* $OpenBSD: getcom.c,v 1.4 1997/09/01 18:13:18 millert Exp $ */
/* $NetBSD: getcom.c,v 1.3 1995/03/21 15:07:30 cgd Exp $ */
/*
@@ -53,7 +53,7 @@ getcom(buf, size, prompt, error)
char *prompt, *error;
{
for (;;) {
- fputs(prompt, stdout);
+ fputs(prompt, stdout);
if (fgets(buf, size, stdin) == 0) {
clearerr(stdin);
continue;
diff --git a/games/battlestar/init.c b/games/battlestar/init.c
index 170816cdd3d..4dc79b982f1 100644
--- a/games/battlestar/init.c
+++ b/games/battlestar/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.3 1997/08/24 21:55:09 deraadt Exp $ */
+/* $OpenBSD: init.c,v 1.4 1997/09/01 18:13:19 millert Exp $ */
/* $NetBSD: init.c,v 1.4 1995/03/21 15:07:35 cgd Exp $ */
/*
@@ -132,13 +132,15 @@ checkout(uname)
if (strcmp(*ptr, uname) == 0) {
printf("You are the Poor anti-wizard %s. Good Luck!\n",
uname);
- CUMBER = 3;
- WEIGHT = 9; /* that'll get him! */
- bclock = 10;
- setbit(location[7].objects, WOODSMAN); /* viper room */
- setbit(location[20].objects, WOODSMAN); /* laser " */
- setbit(location[13].objects, DARK); /* amulet " */
- setbit(location[8].objects, ELF); /* closet */
+ if (location != NULL) {
+ CUMBER = 3;
+ WEIGHT = 9; /* that'll get him! */
+ bclock = 10;
+ setbit(location[7].objects, WOODSMAN); /* viper room */
+ setbit(location[20].objects, WOODSMAN); /* laser " */
+ setbit(location[13].objects, DARK); /* amulet " */
+ setbit(location[8].objects, ELF); /* closet */
+ }
return 0; /* anything else, Chris? */
}
return 0;
diff --git a/games/battlestar/save.c b/games/battlestar/save.c
index dba31c8795e..a0ca3ae6984 100644
--- a/games/battlestar/save.c
+++ b/games/battlestar/save.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: save.c,v 1.5 1997/08/24 21:55:13 deraadt Exp $ */
+/* $OpenBSD: save.c,v 1.6 1997/09/01 18:13:20 millert Exp $ */
/* $NetBSD: save.c,v 1.3 1995/03/21 15:07:57 cgd Exp $ */
/*
@@ -48,7 +48,7 @@ void
restore()
{
char *home;
- char home1[1024];
+ char home1[PATH_MAX];
register int n;
int tmp;
register FILE *fp;
@@ -62,10 +62,10 @@ restore()
return;
}
setegid(egid);
- if ((fp = fopen(home1, "r")) == 0) {
- perror(home1);
+ if ((fp = fopen(home1, "r")) == NULL) {
+ warn("can't open %s for reading", home1);
setegid(getgid());
- exit(1);
+ return;
}
setegid(getgid());
fread(&WEIGHT, sizeof WEIGHT, 1, fp);
@@ -110,7 +110,7 @@ void
save()
{
char *home;
- char home1[100];
+ char home1[PATH_MAX];
register int n;
int tmp;
FILE *fp;
@@ -124,8 +124,8 @@ save()
return;
}
setegid(egid);
- if ((fp = fopen(home1, "w")) == 0) {
- perror(home1);
+ if ((fp = fopen(home1, "w")) == NULL) {
+ warn("can't open %s for writing", home1);
setegid(getgid());
return;
}