From 643584bcfcd68daf078c95da21cab1a3e3188155 Mon Sep 17 00:00:00 2001 From: jsm Date: Sun, 24 Sep 2000 09:41:53 +0000 Subject: Prevent CUMBER from going negative; avoid division by zero if it is zero. --- battlestar/com1.c | 14 ++++++++++---- battlestar/cypher.c | 7 ++++--- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'battlestar') 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."); -- cgit v1.2.3-56-ge451