summaryrefslogtreecommitdiffstats
path: root/games/battlestar
diff options
context:
space:
mode:
authorsteve <steve@FreeBSD.org>1999-04-19 03:59:02 +0000
committersteve <steve@FreeBSD.org>1999-04-19 03:59:02 +0000
commitd59a3ca336bac3dac6ad8918ff6cb28fcbbba718 (patch)
treec2b57d23128f242645f8e3e16274a587229383ec /games/battlestar
parent390eb1b3d201760a5e8b76e2431c1f667648718f (diff)
downloadFreeBSD-src-d59a3ca336bac3dac6ad8918ff6cb28fcbbba718.zip
FreeBSD-src-d59a3ca336bac3dac6ad8918ff6cb28fcbbba718.tar.gz
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
Diffstat (limited to 'games/battlestar')
-rw-r--r--games/battlestar/battlestar.62
-rw-r--r--games/battlestar/battlestar.c2
-rw-r--r--games/battlestar/com1.c2
-rw-r--r--games/battlestar/com2.c1
-rw-r--r--games/battlestar/com3.c2
-rw-r--r--games/battlestar/com4.c4
-rw-r--r--games/battlestar/com5.c16
-rw-r--r--games/battlestar/com6.c2
-rw-r--r--games/battlestar/cypher.c8
-rw-r--r--games/battlestar/dayfile.c6
-rw-r--r--games/battlestar/dayobjs.c2
-rw-r--r--games/battlestar/externs.h22
-rw-r--r--games/battlestar/getcom.c2
-rw-r--r--games/battlestar/globals.c10
-rw-r--r--games/battlestar/init.c14
-rw-r--r--games/battlestar/misc.c8
-rw-r--r--games/battlestar/nightfile.c6
-rw-r--r--games/battlestar/nightobjs.c2
-rw-r--r--games/battlestar/parse.c5
-rw-r--r--games/battlestar/room.c4
-rw-r--r--games/battlestar/save.c6
21 files changed, 75 insertions, 51 deletions
diff --git a/games/battlestar/battlestar.6 b/games/battlestar/battlestar.6
index 12a9192..2298aae 100644
--- a/games/battlestar/battlestar.6
+++ b/games/battlestar/battlestar.6
@@ -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
diff --git a/games/battlestar/battlestar.c b/games/battlestar/battlestar.c
index 2499ff3..4cbbefd 100644
--- a/games/battlestar/battlestar.c
+++ b/games/battlestar/battlestar.c
@@ -91,6 +91,6 @@ run:
case 0:
goto start;
default:
- exit(0);
+ exit(1); /* Shouldn't happen */
}
}
diff --git a/games/battlestar/com1.c b/games/battlestar/com1.c
index c099f76..37cf253 100644
--- a/games/battlestar/com1.c
+++ b/games/battlestar/com1.c
@@ -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) {
diff --git a/games/battlestar/com2.c b/games/battlestar/com2.c
index e7d1af6..dd0eea4 100644
--- a/games/battlestar/com2.c
+++ b/games/battlestar/com2.c
@@ -140,6 +140,7 @@ use()
else
position = 229;
gtime++;
+ notes[CANTSEE] = 0;
return(0);
}
else if (position == FINAL)
diff --git a/games/battlestar/com3.c b/games/battlestar/com3.c
index 619c43f..fb05667 100644
--- a/games/battlestar/com3.c
+++ b/games/battlestar/com3.c
@@ -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];
diff --git a/games/battlestar/com4.c b/games/battlestar/com4.c
index 8a11664..8afc04f 100644
--- a/games/battlestar/com4.c
+++ b/games/battlestar/com4.c
@@ -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;
diff --git a/games/battlestar/com5.c b/games/battlestar/com5.c
index 5bdea6a..3027afd 100644
--- a/games/battlestar/com5.c
+++ b/games/battlestar/com5.c
@@ -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);
}
diff --git a/games/battlestar/com6.c b/games/battlestar/com6.c
index ddfac67..ec01b11 100644
--- a/games/battlestar/com6.c
+++ b/games/battlestar/com6.c
@@ -123,7 +123,7 @@ char ch;
sigsetmask(s);
}
-char *
+const char *
rate()
{
int score;
diff --git a/games/battlestar/cypher.c b/games/battlestar/cypher.c
index ff5da4e..4835327 100644
--- a/games/battlestar/cypher.c
+++ b/games/battlestar/cypher.c
@@ -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();
}
diff --git a/games/battlestar/dayfile.c b/games/battlestar/dayfile.c
index 79acf37..e11e883 100644
--- a/games/battlestar/dayfile.c
+++ b/games/battlestar/dayfile.c
@@ -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,
diff --git a/games/battlestar/dayobjs.c b/games/battlestar/dayobjs.c
index fba3585..300dbbd 100644
--- a/games/battlestar/dayobjs.c
+++ b/games/battlestar/dayobjs.c
@@ -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 },
diff --git a/games/battlestar/externs.h b/games/battlestar/externs.h
index d0ee589..8cb2b69 100644
--- a/games/battlestar/externs.h
+++ b/games/battlestar/externs.h
@@ -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;
diff --git a/games/battlestar/getcom.c b/games/battlestar/getcom.c
index d441921..2ec0feb 100644
--- a/games/battlestar/getcom.c
+++ b/games/battlestar/getcom.c
@@ -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);
diff --git a/games/battlestar/globals.c b/games/battlestar/globals.c
index 1e079aa..7a5e2df 100644
--- a/games/battlestar/globals.c
+++ b/games/battlestar/globals.c
@@ -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,
diff --git a/games/battlestar/init.c b/games/battlestar/init.c
index a06ad3c..afe692f 100644
--- a/games/battlestar/init.c
+++ b/games/battlestar/init.c
@@ -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)
diff --git a/games/battlestar/misc.c b/games/battlestar/misc.c
index 8ce68b1..1ba9e41 100644
--- a/games/battlestar/misc.c
+++ b/games/battlestar/misc.c
@@ -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;
diff --git a/games/battlestar/nightfile.c b/games/battlestar/nightfile.c
index c1d312d..670587f 100644
--- a/games/battlestar/nightfile.c
+++ b/games/battlestar/nightfile.c
@@ -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,
diff --git a/games/battlestar/nightobjs.c b/games/battlestar/nightobjs.c
index 53531d5..0b9fcd4 100644
--- a/games/battlestar/nightobjs.c
+++ b/games/battlestar/nightobjs.c
@@ -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 },
diff --git a/games/battlestar/parse.c b/games/battlestar/parse.c
index dbc99fe..8aaf66d 100644
--- a/games/battlestar/parse.c
+++ b/games/battlestar/parse.c
@@ -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;
diff --git a/games/battlestar/room.c b/games/battlestar/room.c
index db585ea..7c34dad 100644
--- a/games/battlestar/room.c
+++ b/games/battlestar/room.c
@@ -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;
diff --git a/games/battlestar/save.c b/games/battlestar/save.c
index df61213..9e44d70 100644
--- a/games/battlestar/save.c
+++ b/games/battlestar/save.c
@@ -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
OpenPOWER on IntegriCloud