summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2020-07-12 02:34:54 +0000
committerdholland <dholland@NetBSD.org>2020-07-12 02:34:54 +0000
commit41ea0dbfd0fa937c96c965324e8f01aa9864130e (patch)
tree8d6917c151062f62330c51b73ffc7e8f60fc46a2
parentdf5cc7cf1cf61077ac0dcd2b376e61b3ed7fc388 (diff)
downloadbsdgames-darwin-41ea0dbfd0fa937c96c965324e8f01aa9864130e.tar.gz
bsdgames-darwin-41ea0dbfd0fa937c96c965324e8f01aa9864130e.tar.zst
bsdgames-darwin-41ea0dbfd0fa937c96c965324e8f01aa9864130e.zip
Avoid messing up the display when too many letters are guessed at once.
The field to put them in was made 26 characters wide... but includes the string "Guessed: ". So if you get to 17 it wraps to the next line and clreol()'s it. Instead, when reaching this point step on the "Guessed:" string instead. Reported by phil@.
-rw-r--r--hangman/prdata.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/hangman/prdata.c b/hangman/prdata.c
index 5ade009f..279e41ad 100644
--- a/hangman/prdata.c
+++ b/hangman/prdata.c
@@ -1,4 +1,4 @@
-/* $NetBSD: prdata.c,v 1.7 2012/10/13 21:03:09 dholland Exp $ */
+/* $NetBSD: prdata.c,v 1.8 2020/07/12 02:34:54 dholland Exp $ */
/*-
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)prdata.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: prdata.c,v 1.7 2012/10/13 21:03:09 dholland Exp $");
+__RCSID("$NetBSD: prdata.c,v 1.8 2020/07/12 02:34:54 dholland Exp $");
#endif
#endif /* not lint */
@@ -47,9 +47,17 @@ __RCSID("$NetBSD: prdata.c,v 1.7 2012/10/13 21:03:09 dholland Exp $");
void
prdata(void)
{
- int i;
+ int i, n, l;
- move(GUESSY, GUESSX + sizeof "Guessed: ");
+ for (i = n = 0; i < 26; i++)
+ if (Guessed[i])
+ n++;
+
+ move(GUESSY, GUESSX);
+ l = sizeof "Guessed: ";
+ if (GUESSX + l + n < COLS) {
+ addstr("Guessed: ");
+ }
for (i = 0; i < 26; i++)
if (Guessed[i])
addch(i + 'a');