Module Name: src
Committed By: dholland
Date: Sun Jul 12 02:34:54 UTC 2020
Modified Files:
src/games/hangman: prdata.c
Log Message:
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@.
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/games/hangman/prdata.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/games/hangman/prdata.c
diff -u src/games/hangman/prdata.c:1.7 src/games/hangman/prdata.c:1.8
--- src/games/hangman/prdata.c:1.7 Sat Oct 13 21:03:09 2012
+++ src/games/hangman/prdata.c Sun Jul 12 02:34:54 2020
@@ -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
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');