summaryrefslogtreecommitdiffstats
path: root/battlestar
diff options
context:
space:
mode:
authorjsm <jsm@NetBSD.org>2000-09-24 09:41:53 +0000
committerjsm <jsm@NetBSD.org>2000-09-24 09:41:53 +0000
commit643584bcfcd68daf078c95da21cab1a3e3188155 (patch)
treea7b1d9bdedcba181e0ccfc0585850a5849bbf932 /battlestar
parentf55810a947cd7ac1e0a30fc324fd8dd7794aadf8 (diff)
downloadbsdgames-darwin-643584bcfcd68daf078c95da21cab1a3e3188155.tar.gz
bsdgames-darwin-643584bcfcd68daf078c95da21cab1a3e3188155.tar.zst
bsdgames-darwin-643584bcfcd68daf078c95da21cab1a3e3188155.zip
Prevent CUMBER from going negative; avoid division by zero if it is
zero.
Diffstat (limited to 'battlestar')
-rw-r--r--battlestar/com1.c14
-rw-r--r--battlestar/cypher.c7
2 files changed, 14 insertions, 7 deletions
diff --git a/battlestar/com1.c b/battlestar/com1.c
index b3e4f6ff..ab569228 100644
--- a/battlestar/com1.c
+++ b/battlestar/com1.c
@@ -1,4 +1,4 @@
-/* $NetBSD: com1.c,v 1.12 2000/09/17 23:04:17 jsm Exp $ */
+/* $NetBSD: com1.c,v 1.13 2000/09/24 09:41:53 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)com1.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: com1.c,v 1.12 2000/09/17 23:04:17 jsm Exp $");
+__RCSID("$NetBSD: com1.c,v 1.13 2000/09/24 09:41:53 jsm Exp $");
#endif
#endif /* not lint */
@@ -214,11 +214,17 @@ news()
WEIGHT = 0;
}
if (injuries[ARM] == 2) {
- CUMBER -= 5;
+ if (CUMBER > 5)
+ CUMBER -= 5;
+ else
+ CUMBER = 0;
injuries[ARM]++;
}
if (injuries[RIBS] == 2) {
- CUMBER -= 2;
+ if (CUMBER > 2)
+ CUMBER -= 2;
+ else
+ CUMBER = 0;
injuries[RIBS]++;
}
if (injuries[SPINE] == 2) {
diff --git a/battlestar/cypher.c b/battlestar/cypher.c
index ef697edc..6fd3c7df 100644
--- a/battlestar/cypher.c
+++ b/battlestar/cypher.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cypher.c,v 1.17 2000/09/22 08:19:57 jsm Exp $ */
+/* $NetBSD: cypher.c,v 1.18 2000/09/24 09:41:53 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cypher.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: cypher.c,v 1.17 2000/09/22 08:19:57 jsm Exp $");
+__RCSID("$NetBSD: cypher.c,v 1.18 2000/09/24 09:41:53 jsm Exp $");
#endif
#endif /* not lint */
@@ -312,7 +312,8 @@ cypher()
if (testbit(inven, n))
printf("\t%s\n", objsht[n]);
printf("\n= %d kilogram%s (%d%%)\n", carrying, (carrying == 1 ? "." : "s."), (WEIGHT ? carrying * 100 / WEIGHT : -1));
- printf("Your arms are %d%% full.\n", encumber * 100 / CUMBER);
+ printf("Your arms are %d%% full.\n",
+ (CUMBER ? encumber * 100 / CUMBER : -1));
} else
puts("You aren't carrying anything.");