Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/hangman Avoid messing up the display when too many let...
details: https://anonhg.NetBSD.org/src/rev/3c0b36ede064
branches: trunk
changeset: 1011796:3c0b36ede064
user: dholland <dholland%NetBSD.org@localhost>
date: Sun Jul 12 02:34:54 2020 +0000
description:
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@.
diffstat:
games/hangman/prdata.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diffs (38 lines):
diff -r ced61f22f31a -r 3c0b36ede064 games/hangman/prdata.c
--- a/games/hangman/prdata.c Sun Jul 12 02:09:51 2020 +0000
+++ b/games/hangman/prdata.c Sun Jul 12 02:34:54 2020 +0000
@@ -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 @@
void
prdata(void)
{
- int i;
+ int i, n, l;
+
+ for (i = n = 0; i < 26; i++)
+ if (Guessed[i])
+ n++;
- move(GUESSY, GUESSX + sizeof "Guessed: ");
+ 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');
Home |
Main Index |
Thread Index |
Old Index